Class MultiByteFont
java.lang.Object
org.apache.fop.fonts.Typeface
org.apache.fop.fonts.CustomFont
org.apache.fop.fonts.CIDFont
org.apache.fop.fonts.MultiByteFont
- All Implemented Interfaces:
Positionable, Substitutable, FontDescriptor, FontMetrics, MutableFont
- Direct Known Subclasses:
CFFToType1Font
Generic MultiByte (CID) font
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Rectangle[]Contains the character bounding boxes for all characters in the fontprotected final CIDSetprivate CIDFontTypeprivate intprivate Stringprivate intprivate intprivate GlyphDefinitionTableprivate GlyphPositioningTableprivate GlyphSubstitutionTableprivate booleanprivate intprivate intprivate static final org.apache.commons.logging.Loglogging instanceprivate int[]private intprivate static final intprivate intprivate intprivate Stringprivate LinkedHashMap<Integer, String> Fields inherited from class CustomFont
additionalEncodings, cmap, svgs, unencodedCharactersFields inherited from class Typeface
eventListener, NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionMultiByteFont(InternalResourceResolver resourceResolver, EmbeddingMode embeddingMode) Default constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddPrivateUseMapping(int pu, int gi) Add a private use mapping {PU,GI} to the existing character map.charSequenceToGlyphSequence(CharSequence charSequence, List associations) private intcreatePrivateUseMapping(int gi) Given a glyph index, create a new private use mapping, augmenting the bfentries table.private CharSequencedecompose(CharSequence cs, List associations) private static GlyphSequenceRemoves the glyphs associated with elidable control characters.private intfindCharacterFromGlyphIndex(int gi) private intfindCharacterFromGlyphIndex(int gi, boolean augment) Returns the Unicode scalar value that corresponds to the glyph index.intfindGlyphIndex(int c) Returns the glyph index for a Unicode character.getBoundingBox(int glyphIndex, int size) Returns the bounding box of the glyph at the given index, for the given font size.protected char[]getChars()Returns the subset information for this font.Returns the type of the CID font.intReturns the default width for this font.Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").Get the encoding of the font.getGDEF()Obtain glyph definition table.intgetGIDFromChar(char ch) Gets the original glyph index in the font from a character.protected BitSetgetGPOS()Obtain glyph positioning table.getGSUB()Obtain glyph substitution table.Returns a font name for use within a registry.Returns the name of the issuer of the font.intReturns the supplement number of the character collection.getSVG(int c) Returns the TrueType Collection Name.chargetUnicodeFromGID(int glyphIndex) Returns the character from it's original glyph index in the fontprotected int[]Returns a Map of used Glyphs.intgetWidth(int i, int size) Return the width (in 1/1000ths of point size) of the character at code point i.int[]Return the array of widths.booleanhasChar(char c) Determines whether this font contains a particular character/glyph.booleanhasCodePoint(int cp) Determines whether this font contains a particular code point/glyph.private booleanprivate static booleanbooleanhasFeature(int tableType, String script, String language, String feature) Determine if metrics supports specific feature in specified font table.private static booleanisElidableControl(int ch) booleanIndicates if this font may be embedded.booleanbooleanIndicates whether this font is subset embedded.charmapChar(char c) Map a Unicode character to a code point in the font.private GlyphSequencemapCharsToGlyphs(CharSequence cs, List associations) Map sequence CS, comprising a sequence of UTF-16 encoded Unicode Code Points, to an output character sequence GS, comprising a sequence of Glyph Indices.intmapCodePoint(int cp) Map a Unicode code point to a code point in the font.private CharSequenceMap sequence GS, comprising a sequence of Glyph Indices, to output sequence CS, comprising a sequence of UTF-16 encoded Unicode Code Points.voidmapUsedGlyphName(int gid, String value) private CharSequencenormalize(CharSequence cs, List associations) int[][]performPositioning(CharSequence cs, String script, String language) Perform glyph positioning using an implied font size.int[][]performPositioning(CharSequence cs, String script, String language, int fontSize) Perform glyph positioning.booleanDetermines if font performs glyph positioning.booleanDetermines if font performs glyph substitution.performSubstitution(CharSequence charSequence, String script, String language, List associations, boolean retainControls) Perform substitutions on characters to effect glyph substitution.reorderCombiningMarks(CharSequence cs, int[][] gpa, String script, String language, List associations) Reorder combining marks in character sequence so that they precede (within the sequence) the base character to which they are applied.private int[][]scaleAdjustments(int[][] adjustments, int fontSize) voidsetBBoxArray(Rectangle[] boundingBoxes) Sets the bounding boxes array.voidsetCIDType(CIDFontType cidType) Sets the CIDType.voidsetDefaultWidth(int defaultWidth) Sets the defaultWidth.voidsetGDEF(GlyphDefinitionTable gdef) Establishes the glyph definition table.voidsetGPOS(GlyphPositioningTable gpos) Establishes the glyph positioning table.voidEstablishes the glyph substitution table.voidsetIsOTFFile(boolean isOTFFile) voidsetTTCName(String ttcName) Sets the the TrueType Collection Name.voidsetWidthArray(int[] wds) Sets the width array.Methods inherited from class CIDFont
isMultiByteMethods inherited from class CustomFont
addUnencodedCharacter, getAdditionalEncoding, getAdditionalEncodingCount, getAscender, getAscender, getCapHeight, getCapHeight, getCMap, getDescender, getDescender, getEmbeddingMode, getEmbedFileURI, getEmbedResourceName, getFamilyNames, getFirstChar, getFlags, getFontBBox, getFontName, getFontSubName, getFontType, getFontURI, getFullName, getInputStream, getItalicAngle, getKerningInfo, getLastChar, getMissingWidth, getSimulateStyle, getStemV, getStrikeoutPosition, getStrikeoutThickness, getStrippedFontName, getUnderlinePosition, getUnderlineThickness, getWeight, getXHeight, hasAdditionalEncodings, hasKerningInfo, hasSVG, isAdvancedEnabled, isKerningEnabled, isSymbolicFont, mapUnencodedChar, putKerningEntry, replaceKerningMap, setAdvancedEnabled, setAscender, setCapHeight, setCMap, setDescender, setEmbeddingMode, setEmbedResourceName, setEmbedURI, setFamilyNames, setFirstChar, setFlags, setFontBBox, setFontName, setFontSubFamilyName, setFontType, setFontURI, setFullName, setItalicAngle, setKerningEnabled, setLastChar, setMissingWidth, setSimulateStyle, setStemV, setStrikeoutPosition, setStrikeoutThickness, setSVG, setUnderlinePosition, setUnderlineThickness, setWeight, setXHeightMethods inherited from class Typeface
getMaxAscent, hadMappingOperations, isCID, notifyMapOperation, setEventListener, toString, warnMissingGlyphMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface FontMetrics
getMaxAscent
-
Field Details
-
log
private static final org.apache.commons.logging.Log loglogging instance -
ttcName
-
encoding
-
defaultWidth
private int defaultWidth -
cidType
-
cidSet
-
gdef
-
gsub
-
gpos
-
numMapped
private int numMapped -
numUnmapped
private int numUnmapped -
nextPrivateUse
private int nextPrivateUse -
firstPrivate
private int firstPrivate -
lastPrivate
private int lastPrivate -
firstUnmapped
private int firstUnmapped -
lastUnmapped
private int lastUnmapped -
boundingBoxes
Contains the character bounding boxes for all characters in the font -
isOTFFile
private boolean isOTFFile -
NUM_MOST_LIKELY_GLYPHS
private static final int NUM_MOST_LIKELY_GLYPHS- See Also:
-
mostLikelyGlyphs
private int[] mostLikelyGlyphs -
usedGlyphNames
-
-
Constructor Details
-
MultiByteFont
Default constructor
-
-
Method Details
-
getDefaultWidth
public int getDefaultWidth()Returns the default width for this font.- Overrides:
getDefaultWidthin classCIDFont- Returns:
- the default width
-
getRegistry
Returns the name of the issuer of the font.- Specified by:
getRegistryin classCIDFont- Returns:
- a String identifying an issuer of character collections - for example, Adobe
-
getOrdering
Returns a font name for use within a registry.- Specified by:
getOrderingin classCIDFont- Returns:
- a String that uniquely names a character collection issued by a specific registry - for example, Japan1.
-
getSupplement
public int getSupplement()Returns the supplement number of the character collection.- Specified by:
getSupplementin classCIDFont- Returns:
- the supplement number
-
getCIDType
Returns the type of the CID font.- Specified by:
getCIDTypein classCIDFont- Returns:
- the type of the CID font
-
setIsOTFFile
public void setIsOTFFile(boolean isOTFFile) -
isOTFFile
public boolean isOTFFile() -
setCIDType
Sets the CIDType.- Parameters:
cidType- The cidType to set
-
getEmbedFontName
Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").- Specified by:
getEmbedFontNamein interfaceFontMetrics- Overrides:
getEmbedFontNamein classCustomFont- Returns:
- the name for font embedding
-
isEmbeddable
public boolean isEmbeddable()Indicates if this font may be embedded.- Specified by:
isEmbeddablein interfaceFontDescriptor- Returns:
- True, if embedding is possible/permitted
-
isSubsetEmbedded
public boolean isSubsetEmbedded()Description copied from interface:FontDescriptorIndicates whether this font is subset embedded.- Specified by:
isSubsetEmbeddedin interfaceFontDescriptor- Returns:
- true if this font is subset embedded
-
getCIDSet
-
mapUsedGlyphName
-
getUsedGlyphNames
-
getEncodingName
Get the encoding of the font.- Specified by:
getEncodingNamein classTypeface- Returns:
- the encoding
-
getWidth
public int getWidth(int i, int size) Return the width (in 1/1000ths of point size) of the character at code point i.- Specified by:
getWidthin interfaceFontMetrics- Parameters:
i- code point indexsize- font size- Returns:
- the width of the character
-
getWidths
public int[] getWidths()Return the array of widths.This is used to get an array for inserting in an output format. It should not be used for lookup.
- Specified by:
getWidthsin interfaceFontMetrics- Returns:
- an array of widths
-
getBoundingBox
Description copied from interface:FontMetricsReturns the bounding box of the glyph at the given index, for the given font size.- Specified by:
getBoundingBoxin interfaceFontMetrics- Parameters:
glyphIndex- glyph indexsize- font size- Returns:
- the scaled bounding box scaled in 1/1000ths of the given size
-
findGlyphIndex
public int findGlyphIndex(int c) Returns the glyph index for a Unicode character. The method returns 0 if there's no such glyph in the character map.- Parameters:
c- the Unicode character index- Returns:
- the glyph index (or 0 if the glyph is not available)
-
addPrivateUseMapping
protected void addPrivateUseMapping(int pu, int gi) Add a private use mapping {PU,GI} to the existing character map. N.B. Does not insert in order, merely appends to end of existing map. -
createPrivateUseMapping
private int createPrivateUseMapping(int gi) Given a glyph index, create a new private use mapping, augmenting the bfentries table. This is needed to accommodate the presence of an (output) glyph index in a complex script glyph substitution that does not correspond to a character in the font's CMAP. The creation of such private use mappings is deferred until an attempt is actually made to perform the reverse lookup from the glyph index. This is necessary in order to avoid exhausting the private use space on fonts containing many such non-mapped glyph indices, if these mappings had been created statically at font load time.- Parameters:
gi- glyph index
-
findCharacterFromGlyphIndex
private int findCharacterFromGlyphIndex(int gi, boolean augment) Returns the Unicode scalar value that corresponds to the glyph index. If more than one correspondence exists, then the first one is returned (ordered by bfentries[]).- Parameters:
gi- glyph index- Returns:
- unicode scalar value
-
findCharacterFromGlyphIndex
private int findCharacterFromGlyphIndex(int gi) -
getGlyphIndices
-
getChars
protected char[] getChars() -
mapChar
-
mapCodePoint
public int mapCodePoint(int cp) Map a Unicode code point to a code point in the font.- Specified by:
mapCodePointin classCIDFont- Parameters:
cp- code point to map- Returns:
- the mapped code point
-
hasChar
-
hasCodePoint
public boolean hasCodePoint(int cp) Determines whether this font contains a particular code point/glyph.- Specified by:
hasCodePointin classCIDFont- Parameters:
cp- character to check- Returns:
- True if the character is supported, False otherwise
-
setDefaultWidth
public void setDefaultWidth(int defaultWidth) Sets the defaultWidth.- Parameters:
defaultWidth- The defaultWidth to set
-
getTTCName
Returns the TrueType Collection Name.- Returns:
- the TrueType Collection Name
-
setTTCName
Sets the the TrueType Collection Name.- Parameters:
ttcName- the TrueType Collection Name
-
setWidthArray
public void setWidthArray(int[] wds) Sets the width array.- Parameters:
wds- array of widths.
-
setBBoxArray
Sets the bounding boxes array.- Parameters:
boundingBoxes- array of bounding boxes.
-
getUsedGlyphs
Returns a Map of used Glyphs.- Specified by:
getUsedGlyphsin classCustomFont- Returns:
- Map Map of used Glyphs
-
getUnicodeFromGID
public char getUnicodeFromGID(int glyphIndex) Returns the character from it's original glyph index in the font- Specified by:
getUnicodeFromGIDin classCustomFont- Parameters:
glyphIndex- The original index of the character- Returns:
- The character
-
getGIDFromChar
public int getGIDFromChar(char ch) Gets the original glyph index in the font from a character.- Parameters:
ch- The character- Returns:
- The glyph index in the font
-
setGDEF
Establishes the glyph definition table.- Parameters:
gdef- the glyph definition table to be used by this font
-
getGDEF
Obtain glyph definition table.- Returns:
- glyph definition table or null if none is associated with font
-
setGSUB
Establishes the glyph substitution table.- Parameters:
gsub- the glyph substitution table to be used by this font
-
getGSUB
Obtain glyph substitution table.- Returns:
- glyph substitution table or null if none is associated with font
-
setGPOS
Establishes the glyph positioning table.- Parameters:
gpos- the glyph positioning table to be used by this font
-
getGPOS
Obtain glyph positioning table.- Returns:
- glyph positioning table or null if none is associated with font
-
performsSubstitution
public boolean performsSubstitution()Determines if font performs glyph substitution.- Specified by:
performsSubstitutionin interfaceSubstitutable- Returns:
- true if performs substitution.
-
performSubstitution
public CharSequence performSubstitution(CharSequence charSequence, String script, String language, List associations, boolean retainControls) Perform substitutions on characters to effect glyph substitution. If some substitution is performed, it entails mapping from one or more input characters denoting textual character information to one or more output character codes denoting glyphs in this font, where the output character codes may make use of private character code values that have significance only for this font.- Specified by:
performSubstitutionin interfaceSubstitutable- Parameters:
charSequence- character sequence to map to output font encoding character sequencescript- a script identifierlanguage- a language identifierassociations- optional list to receive list of character associationsretainControls- if true, then retain control characters and their glyph mappings, otherwise remove- Returns:
- output sequence (represented as a character sequence, where each character in the returned sequence denotes "font characters", i.e., character codes that map directly (1-1) to their associated glyphs
-
charSequenceToGlyphSequence
-
reorderCombiningMarks
public CharSequence reorderCombiningMarks(CharSequence cs, int[][] gpa, String script, String language, List associations) Reorder combining marks in character sequence so that they precede (within the sequence) the base character to which they are applied. N.B. In the case of LTR segments, marks are not reordered by this, method since when the segment is reversed by BIDI processing, marks are automatically reordered to precede their base character.- Specified by:
reorderCombiningMarksin interfaceSubstitutable- Parameters:
cs- character sequence within which combining marks to be reorderedgpa- associated glyph position adjustments (also reordered)script- a script identifierlanguage- a language identifierassociations- optional list of associations to be reordered- Returns:
- output sequence containing reordered "font characters"
-
getUnscaledWidths
-
performsPositioning
public boolean performsPositioning()Determines if font performs glyph positioning.- Specified by:
performsPositioningin interfacePositionable- Returns:
- true if performs positioning
-
performPositioning
Perform glyph positioning.- Specified by:
performPositioningin interfacePositionable- Parameters:
cs- character sequence to map to position offsets (advancement adjustments)script- a script identifierlanguage- a language identifierfontSize- font size- Returns:
- array (sequence) of 4-tuples of placement [PX,PY] and advance [AX,AY] adjustments, in that order, with one 4-tuple for each element of glyph sequence, or null if no non-zero adjustment applies
-
performPositioning
Perform glyph positioning using an implied font size.- Specified by:
performPositioningin interfacePositionable- Parameters:
cs- character sequence to map to position offsets (advancement adjustments)script- a script identifierlanguage- a language identifier- Returns:
- array (sequence) of 4-tuples of placement [PX,PY] and advance [AX,AY] adjustments, in that order, with one 4-tuple for each element of glyph sequence, or null if no non-zero adjustment applies
-
scaleAdjustments
private int[][] scaleAdjustments(int[][] adjustments, int fontSize) -
mapCharsToGlyphs
Map sequence CS, comprising a sequence of UTF-16 encoded Unicode Code Points, to an output character sequence GS, comprising a sequence of Glyph Indices. N.B. Unlike mapChar(), this method does not make use of embedded subset encodings.- Parameters:
cs- a CharSequence containing UTF-16 encoded Unicode characters
-
mapGlyphsToChars
Map sequence GS, comprising a sequence of Glyph Indices, to output sequence CS, comprising a sequence of UTF-16 encoded Unicode Code Points.- Parameters:
gs- a GlyphSequence containing glyph indices
-
normalize
-
hasDecomposable
-
decompose
-
elideControls
Removes the glyphs associated with elidable control characters. All the characters in an association must be elidable in order to remove the corresponding glyph.- Parameters:
gs- GlyphSequence that may contains the elidable glyphs- Returns:
- GlyphSequence without the elidable glyphs
-
hasElidableControl
-
isElidableControl
private static boolean isElidableControl(int ch) -
hasFeature
Description copied from class:TypefaceDetermine if metrics supports specific feature in specified font table.- Specified by:
hasFeaturein interfaceFontMetrics- Overrides:
hasFeaturein classTypeface- Parameters:
tableType- type of table (GSUB, GPOS, ...), see GlyphTable.GLYPH_TABLE_TYPE_*script- to qualify feature lookuplanguage- to qualify feature lookupfeature- to test- Returns:
- true if feature supported (and has at least one lookup)
-
getWidthsMap
-
getCmapStream
-
getSVG
-