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 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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.net.URI;
  21. import java.util.Map;
  22. import java.util.Set;
  23. /**
  24. * Main interface for access to font metrics.
  25. */
  26. public interface FontMetrics {
  27. /**
  28. * Returns the URI of the font file from which these metrics were loaded.
  29. * @return the font file's URI
  30. */
  31. URI getFontURI();
  32. /**
  33. * Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").
  34. * @return the font name
  35. */
  36. String getFontName();
  37. /**
  38. * Returns the font's full name (Example: "Helvetica Bold Oblique").
  39. * @return the font's full name
  40. */
  41. String getFullName();
  42. /**
  43. * Returns the font's family names as a Set of Strings (Example: "Helvetica").
  44. * @return the font's family names (a Set of Strings)
  45. */
  46. Set<String> getFamilyNames();
  47. /**
  48. * Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
  49. * @return the name for font embedding
  50. */
  51. String getEmbedFontName();
  52. /**
  53. * Returns the type of the font.
  54. * @return the font type
  55. */
  56. FontType getFontType();
  57. /**
  58. * Returns the maximum ascent of the font described by this
  59. * FontMetrics object. Note: This is not the same as getAscender().
  60. * @param size font size
  61. * @return ascent in milliponts
  62. */
  63. int getMaxAscent(int size);
  64. /**
  65. * Returns the ascent of the font described by this
  66. * FontMetrics object. It returns the nominal ascent within the em box.
  67. * @param size font size
  68. * @return ascent in milliponts
  69. */
  70. int getAscender(int size);
  71. /**
  72. * Returns the size of a capital letter measured from the font's baseline.
  73. * @param size font size
  74. * @return height of capital characters
  75. */
  76. int getCapHeight(int size);
  77. /**
  78. * Returns the descent of the font described by this
  79. * FontMetrics object.
  80. * @param size font size
  81. * @return descent in milliponts
  82. */
  83. int getDescender(int size);
  84. /**
  85. * Determines the typical font height of this
  86. * FontMetrics object
  87. * @param size font size
  88. * @return font height in millipoints
  89. */
  90. int getXHeight(int size);
  91. /**
  92. * Return the width (in 1/1000ths of point size) of the character at
  93. * code point i.
  94. * @param i code point index
  95. * @param size font size
  96. * @return the width of the character
  97. */
  98. int getWidth(int i, int size);
  99. /**
  100. * Return the array of widths.
  101. * <p>
  102. * This is used to get an array for inserting in an output format.
  103. * It should not be used for lookup.
  104. * @return an array of widths
  105. */
  106. int[] getWidths();
  107. /**
  108. * Returns the bounding box of the glyph at the given index, for the given font size.
  109. *
  110. * @param glyphIndex glyph index
  111. * @param size font size
  112. * @return the scaled bounding box scaled in 1/1000ths of the given size
  113. */
  114. Rectangle getBoundingBox(int glyphIndex, int size);
  115. /**
  116. * Indicates if the font has kerning information.
  117. * @return true if kerning is available.
  118. */
  119. boolean hasKerningInfo();
  120. /**
  121. * Returns the kerning map for the font.
  122. * @return the kerning map
  123. */
  124. Map<Integer, Map<Integer, Integer>> getKerningInfo();
  125. /**
  126. * Returns the distance from the baseline to the center of the underline (negative
  127. * value indicates below baseline).
  128. *
  129. * @param size font size
  130. * @return the position in 1/1000ths of the font size
  131. */
  132. int getUnderlinePosition(int size);
  133. /**
  134. * Returns the thickness of the underline.
  135. *
  136. * @param size font size
  137. * @return the thickness in 1/1000ths of the font size
  138. */
  139. int getUnderlineThickness(int size);
  140. /**
  141. * Returns the distance from the baseline to the center of the strikeout line
  142. * (negative value indicates below baseline).
  143. *
  144. * @param size font size
  145. * @return the position in 1/1000ths of the font size
  146. */
  147. int getStrikeoutPosition(int size);
  148. /**
  149. * Returns the thickness of the strikeout line.
  150. *
  151. * @param size font size
  152. * @return the thickness in 1/1000ths of the font size
  153. */
  154. int getStrikeoutThickness(int size);
  155. /**
  156. * Determine if metrics supports specific feature in specified font table.
  157. *
  158. * @param tableType type of table (GSUB, GPOS, ...), see GlyphTable.GLYPH_TABLE_TYPE_*
  159. * @param script to qualify feature lookup
  160. * @param language to qualify feature lookup
  161. * @param feature to test
  162. * @return true if feature supported (and has at least one lookup)
  163. */
  164. boolean hasFeature(int tableType, String script, String language, String feature);
  165. /**
  166. * Determines whether the font is a multibyte font.
  167. * @return True if it is multibyte
  168. */
  169. boolean isMultiByte();
  170. }