Package org.apache.fop.fonts
Class CIDSubset
- java.lang.Object
-
- org.apache.fop.fonts.CIDSubset
-
- All Implemented Interfaces:
CIDSet
public class CIDSubset extends java.lang.Object implements CIDSet
Provides methods to get font information. Naming: glyph index: original index of the glyph in the non-subset font (!= unicode index) character selector: index into a set of glyphs. For subset CID fonts, this starts at 0. For non-subset fonts, this is the same as the glyph index. Unicode index: The Unicode codepoint of a character. Glyph name: the Adobe glyph name (as found in Glyphs.java)
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Integer,java.lang.Integer>
charToGIDs
A map between the original character and it's GID in the original font.private MultiByteFont
font
private java.util.Map<java.lang.Integer,java.lang.Integer>
usedCharsIndex
usedCharsIndex contains new glyph, original char (char selector -> Unicode)private java.util.Map<java.lang.Integer,java.lang.Integer>
usedGlyphs
usedGlyphs contains orginal, new glyph index (glyph index -> char selector)private int
usedGlyphsCount
private java.util.Map<java.lang.Integer,java.lang.Integer>
usedGlyphsIndex
usedGlyphsIndex contains new glyph, original index (char selector -> glyph index)
-
Constructor Summary
Constructors Constructor Description CIDSubset(MultiByteFont mbf)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description char[]
getChars()
Returns a char array containing all Unicode characters that are in the subset.int
getGIDFromChar(char ch)
Returns the glyph index from the original font from a characterjava.util.BitSet
getGlyphIndices()
Returns a BitSet with bits set for each available glyph index in the subset.java.util.Map<java.lang.Integer,java.lang.Integer>
getGlyphs()
Returns an unmodifiable Map of the font subset.int
getNumberOfGlyphs()
Returns the number of glyphs in the subset.int
getOriginalGlyphIndex(int index)
Returns the original index of the glyph inside the (non-subset) font's glyph list.int
getUnicode(int index)
Returns the Unicode value for a subset index (character selector).char
getUnicodeFromGID(int glyphIndex)
Gets the unicode character from the original font glyph indexint[]
getWidths()
Return the array of widths.int
mapChar(int glyphIndex, char unicode)
Maps a character to a character selector for a font subset.int
mapCodePoint(int glyphIndex, int codePoint)
Maps a character to a character selector for a font subset.
-
-
-
Field Detail
-
usedGlyphs
private java.util.Map<java.lang.Integer,java.lang.Integer> usedGlyphs
usedGlyphs contains orginal, new glyph index (glyph index -> char selector)
-
usedGlyphsIndex
private java.util.Map<java.lang.Integer,java.lang.Integer> usedGlyphsIndex
usedGlyphsIndex contains new glyph, original index (char selector -> glyph index)
-
usedGlyphsCount
private int usedGlyphsCount
-
usedCharsIndex
private java.util.Map<java.lang.Integer,java.lang.Integer> usedCharsIndex
usedCharsIndex contains new glyph, original char (char selector -> Unicode)
-
charToGIDs
private java.util.Map<java.lang.Integer,java.lang.Integer> charToGIDs
A map between the original character and it's GID in the original font.
-
font
private final MultiByteFont font
-
-
Constructor Detail
-
CIDSubset
public CIDSubset(MultiByteFont mbf)
-
-
Method Detail
-
getOriginalGlyphIndex
public int getOriginalGlyphIndex(int index)
Returns the original index of the glyph inside the (non-subset) font's glyph list. This index can be used to access the character width information, for example.- Specified by:
getOriginalGlyphIndex
in interfaceCIDSet
- Parameters:
index
- the subset index (character selector) to access the glyph- Returns:
- the original index (or -1 if no glyph index is available for the subset index)
-
getUnicode
public int getUnicode(int index)
Returns the Unicode value for a subset index (character selector). If there's no such Unicode value, the "NOT A CHARACTER" (0xFFFF) is returned.- Specified by:
getUnicode
in interfaceCIDSet
- Parameters:
index
- the subset index (character selector)- Returns:
- the Unicode value or "NOT A CHARACTER" (0xFFFF)
-
mapChar
public int mapChar(int glyphIndex, char unicode)
Maps a character to a character selector for a font subset. If the character isn't in the subset, yet, it is added and a new character selector returned. Otherwise, the already allocated character selector is returned from the existing map/subset.
-
mapCodePoint
public int mapCodePoint(int glyphIndex, int codePoint)
Maps a character to a character selector for a font subset. If the character isn't in the subset yet, it is added and a new character selector returned. Otherwise, the already allocated character selector is returned from the existing map/subset.- Specified by:
mapCodePoint
in interfaceCIDSet
- Parameters:
glyphIndex
- the glyph index of the charactercodePoint
- the Unicode index of the character- Returns:
- the subset index
-
getGlyphs
public java.util.Map<java.lang.Integer,java.lang.Integer> getGlyphs()
Returns an unmodifiable Map of the font subset. It maps from glyph index to character selector (i.e. the subset index in this case).
-
getUnicodeFromGID
public char getUnicodeFromGID(int glyphIndex)
Gets the unicode character from the original font glyph index- Specified by:
getUnicodeFromGID
in interfaceCIDSet
- Parameters:
glyphIndex
- The original glyph index of the character in the font- Returns:
- The character represented by the passed GID
-
getGIDFromChar
public int getGIDFromChar(char ch)
Returns the glyph index from the original font from a character- Specified by:
getGIDFromChar
in interfaceCIDSet
- Parameters:
ch
- The character- Returns:
- The glyph index in the original font.
-
getChars
public char[] getChars()
Returns a char array containing all Unicode characters that are in the subset.
-
getNumberOfGlyphs
public int getNumberOfGlyphs()
Returns the number of glyphs in the subset.- Specified by:
getNumberOfGlyphs
in interfaceCIDSet
- Returns:
- the number of glyphs in the subset
-
getGlyphIndices
public java.util.BitSet getGlyphIndices()
Returns a BitSet with bits set for each available glyph index in the subset.- Specified by:
getGlyphIndices
in interfaceCIDSet
- Returns:
- a BitSet indicating available glyph indices
-
-