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.

CIDSet.java 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.util.BitSet;
  20. import java.util.Map;
  21. /**
  22. * Declares methods to retrieve font information (glyph indices, widths, unicode values) from a CID font.
  23. */
  24. public interface CIDSet {
  25. /**
  26. * Returns the original index of the glyph inside the (non-subset) font's glyph list. This
  27. * index can be used to access the character width information, for example.
  28. * @param index the subset index (character selector) to access the glyph
  29. * @return the original index (or -1 if no glyph index is available for the subset index)
  30. */
  31. int getOriginalGlyphIndex(int index);
  32. /**
  33. * Returns the Unicode value for a subset index (character selector). If there's no such
  34. * Unicode value, the "NOT A CHARACTER" (0xFFFF) is returned.
  35. * @param index the subset index (character selector)
  36. * @return the Unicode value or "NOT A CHARACTER" (0xFFFF)
  37. */
  38. int getUnicode(int index);
  39. /**
  40. * Gets the unicode character from the original font glyph index
  41. * @param glyphIndex The original glyph index of the character in the font
  42. * @return The character represented by the passed GID
  43. */
  44. char getUnicodeFromGID(int glyphIndex);
  45. /**
  46. * Returns the glyph index from the original font from a character
  47. * @param ch The character
  48. * @return The glyph index in the original font.
  49. */
  50. int getGIDFromChar(char ch);
  51. /**
  52. * Maps a character to a character selector for a font subset. If the character isn't in the
  53. * subset, yet, it is added and a new character selector returned. Otherwise, the already
  54. * allocated character selector is returned from the existing map/subset.
  55. * @param glyphIndex the glyph index of the character
  56. * @param unicode the Unicode index of the character
  57. * @return the subset index
  58. */
  59. int mapChar(int glyphIndex, char unicode);
  60. /**
  61. * Maps a character to a character selector for a font subset. If the character isn't in the
  62. * subset yet, it is added and a new character selector returned. Otherwise, the already
  63. * allocated character selector is returned from the existing map/subset.
  64. * @param glyphIndex the glyph index of the character
  65. * @param codePoint the Unicode index of the character
  66. * @return the subset index
  67. */
  68. int mapCodePoint(int glyphIndex, int codePoint);
  69. /**
  70. * Returns an unmodifiable Map of the font subset. It maps from glyph index to
  71. * character selector (i.e. the subset index in this case).
  72. * @return Map Map<Integer, Integer> of the font subset
  73. */
  74. Map<Integer, Integer> getGlyphs();
  75. /**
  76. * Returns a char array containing all Unicode characters that are in the subset.
  77. * @return a char array with all used Unicode characters
  78. */
  79. char[] getChars();
  80. /**
  81. * Returns the number of glyphs in the subset.
  82. * @return the number of glyphs in the subset
  83. */
  84. int getNumberOfGlyphs();
  85. /**
  86. * Returns a BitSet with bits set for each available glyph index in the subset.
  87. * @return a BitSet indicating available glyph indices
  88. */
  89. BitSet getGlyphIndices();
  90. /**
  91. * Return the array of widths.
  92. * <p>
  93. * This is used to get an array for inserting in an output format.
  94. * It should not be used for lookup.
  95. * @return an array of widths
  96. */
  97. int[] getWidths();
  98. }