You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FontMetrics.java 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fonts;
  19. import java.awt.Rectangle;
  20. import java.util.Map;
  21. import java.util.Set;
  22. /**
  23. * Main interface for access to font metrics.
  24. */
  25. public interface FontMetrics {
  26. /**
  27. * Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").
  28. * @return the font name
  29. */
  30. String getFontName();
  31. /**
  32. * Returns the font's full name (Example: "Helvetica Bold Oblique").
  33. * @return the font's full name
  34. */
  35. String getFullName();
  36. /**
  37. * Returns the font's family names as a Set of Strings (Example: "Helvetica").
  38. * @return the font's family names (a Set of Strings)
  39. */
  40. Set<String> getFamilyNames();
  41. /**
  42. * Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
  43. * @return the name for font embedding
  44. */
  45. String getEmbedFontName();
  46. /**
  47. * Returns the type of the font.
  48. * @return the font type
  49. */
  50. FontType getFontType();
  51. /**
  52. * Returns the maximum ascent of the font described by this
  53. * FontMetrics object. Note: This is not the same as getAscender().
  54. * @param size font size
  55. * @return ascent in milliponts
  56. */
  57. int getMaxAscent(int size);
  58. /**
  59. * Returns the ascent of the font described by this
  60. * FontMetrics object. It returns the nominal ascent within the em box.
  61. * @param size font size
  62. * @return ascent in milliponts
  63. */
  64. int getAscender(int size);
  65. /**
  66. * Returns the size of a capital letter measured from the font's baseline.
  67. * @param size font size
  68. * @return height of capital characters
  69. */
  70. int getCapHeight(int size);
  71. /**
  72. * Returns the descent of the font described by this
  73. * FontMetrics object.
  74. * @param size font size
  75. * @return descent in milliponts
  76. */
  77. int getDescender(int size);
  78. /**
  79. * Determines the typical font height of this
  80. * FontMetrics object
  81. * @param size font size
  82. * @return font height in millipoints
  83. */
  84. int getXHeight(int size);
  85. /**
  86. * Return the width (in 1/1000ths of point size) of the character at
  87. * code point i.
  88. * @param i code point index
  89. * @param size font size
  90. * @return the width of the character
  91. */
  92. int getWidth(int i, int size);
  93. /**
  94. * Return the array of widths.
  95. * <p>
  96. * This is used to get an array for inserting in an output format.
  97. * It should not be used for lookup.
  98. * @return an array of widths
  99. */
  100. int[] getWidths();
  101. /**
  102. * Returns the bounding box of the glyph at the given index, for the given font size.
  103. *
  104. * @param glyphIndex glyph index
  105. * @param size font size
  106. * @return the scaled bounding box scaled in 1/1000ths of the given size
  107. */
  108. Rectangle getBoundingBox(int glyphIndex, int size);
  109. /**
  110. * Indicates if the font has kering information.
  111. * @return True, if kerning is available.
  112. */
  113. boolean hasKerningInfo();
  114. /**
  115. * Returns the kerning map for the font.
  116. * @return the kerning map
  117. */
  118. Map<Integer, Map<Integer, Integer>> getKerningInfo();
  119. /**
  120. * Returns the distance from the baseline to the center of the underline (negative
  121. * value indicates below baseline).
  122. *
  123. * @param size font size
  124. * @return the position in 1/1000ths of the font size
  125. */
  126. int getUnderlinePosition(int size);
  127. /**
  128. * Returns the thickness of the underline.
  129. *
  130. * @param size font size
  131. * @return the thickness in 1/1000ths of the font size
  132. */
  133. int getUnderlineThickness(int size);
  134. /**
  135. * Returns the distance from the baseline to the center of the strikeout line
  136. * (negative value indicates below baseline).
  137. *
  138. * @param size font size
  139. * @return the position in 1/1000ths of the font size
  140. */
  141. int getStrikeoutPosition(int size);
  142. /**
  143. * Returns the thickness of the strikeout line.
  144. *
  145. * @param size font size
  146. * @return the thickness in 1/1000ths of the font size
  147. */
  148. int getStrikeoutThickness(int size);
  149. }