Package org.docx4j.fonts.fop.fonts
Class SingleByteFont
java.lang.Object
org.docx4j.fonts.fop.fonts.Typeface
org.docx4j.fonts.fop.fonts.CustomFont
org.docx4j.fonts.fop.fonts.SingleByteFont
- All Implemented Interfaces:
FontDescriptor,FontMetrics,MutableFont
public class SingleByteFont extends CustomFont
Generic SingleByte font
-
Field Summary
-
Constructor Summary
Constructors Constructor Description SingleByteFont()Main constructor. -
Method Summary
Modifier and Type Method Description voidaddUnencodedCharacter(NamedCharacter ch, int width)Adds an unencoded character (one that is not supported by the primary encoding).voidencodeAllUnencodedCharacters()Makes all unencoded characters available through additional encodings.SimpleSingleByteEncodinggetAdditionalEncoding(int index)Returns an additional encoding.intgetAdditionalEncodingCount()Returns the number of additional encodings this single-byte font maintains.int[]getAdditionalWidths(int index)Returns an array with the widths for an additional encoding.SingleByteEncodinggetEncoding()Returns the code point mapping (encoding) of this font.java.lang.StringgetEncodingName()Get the encoding of the font.intgetWidth(int i, int size)Return the width (in 1/1000ths of point size) of the character at code point i.int[]getWidths()Return the array of widths.booleanhasAdditionalEncodings()Indicates whether the encoding has additional encodings besides the primary encoding.booleanhasChar(char c)Determines whether this font contains a particular character/glyph.booleanisEmbeddable()Indicates if this font may be embedded.booleanisUsingNativeEncoding()Indicates whether this font is configured to use its native encoding.charmapChar(char c)Map a Unicode character to a code point in the font.voidsetEncoding(java.lang.String encoding)Sets the encoding of the font.voidsetEncoding(CodePointMapping encoding)Sets the encoding of the font.voidsetUseNativeEncoding(boolean value)Controls whether the font is configured to use its native encoding or if it may need to be re-encoded for the target format.voidsetWidth(int index, int w)Sets a width for a character.protected voidupdateMapping(java.lang.String encoding)Updates the mapping variable based on the encoding.Methods inherited from class org.docx4j.fonts.fop.fonts.CustomFont
getAscender, getAscender, getCapHeight, getCapHeight, getDescender, getDescender, getEmbedFileName, getEmbedFileSource, getEmbedFontName, getEmbedResourceName, getFamilyNames, getFirstChar, getFlags, getFontBBox, getFontName, getFontSubName, getFontType, getFullName, getItalicAngle, getKerningInfo, getLastChar, getMissingWidth, getPanose, getStemV, getStrippedFontName, getWeight, getXHeight, hasKerningInfo, isKerningEnabled, isSymbolicFont, putKerningEntry, replaceKerningMap, setAscender, setCapHeight, setDescender, setEmbeddable, setEmbedFileName, setEmbedResourceName, setFamilyNames, setFirstChar, setFlags, setFontBBox, setFontName, setFontSubFamilyName, setFontType, setFullName, setItalicAngle, setKerningEnabled, setLastChar, setMissingWidth, setPanose, setResolver, setStemV, setWeight, setXHeightMethods inherited from class org.docx4j.fonts.fop.fonts.Typeface
getMaxAscent, hadMappingOperations, isMultiByte, notifyMapOperation, setEventListener, toString, warnMissingGlyph
-
Constructor Details
-
SingleByteFont
public SingleByteFont()Main constructor.
-
-
Method Details
-
isEmbeddable
public boolean isEmbeddable()Indicates if this font may be embedded.- Specified by:
isEmbeddablein interfaceFontDescriptor- Overrides:
isEmbeddablein classCustomFont- Returns:
- True, if embedding is possible/permitted
-
getEncodingName
public java.lang.String getEncodingName()Get the encoding of the font.- Specified by:
getEncodingNamein classTypeface- Returns:
- the encoding
-
getEncoding
Returns the code point mapping (encoding) of this font.- Returns:
- the code point mapping
-
getWidth
public int getWidth(int i, int size)Return the width (in 1/1000ths of point size) of the character at code point i.- 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.
- Returns:
- an array of widths
-
mapChar
public char mapChar(char c)Map a Unicode character to a code point in the font. -
hasChar
public boolean hasChar(char c)Determines whether this font contains a particular character/glyph. -
updateMapping
protected void updateMapping(java.lang.String encoding)Updates the mapping variable based on the encoding.- Parameters:
encoding- the name of the encoding
-
setEncoding
public void setEncoding(java.lang.String encoding)Sets the encoding of the font.- Parameters:
encoding- the encoding (ex. "WinAnsiEncoding" or "SymbolEncoding")
-
setEncoding
Sets the encoding of the font.- Parameters:
encoding- the encoding information
-
setUseNativeEncoding
public void setUseNativeEncoding(boolean value)Controls whether the font is configured to use its native encoding or if it may need to be re-encoded for the target format.- Parameters:
value- true indicates that the configured encoding is the font's native encoding
-
isUsingNativeEncoding
public boolean isUsingNativeEncoding()Indicates whether this font is configured to use its native encoding. This method is used to determine whether the font needs to be re-encoded.- Returns:
- true if the font uses its native encoding.
-
setWidth
public void setWidth(int index, int w)Sets a width for a character.- Parameters:
index- index of the characterw- the width of the character
-
addUnencodedCharacter
Adds an unencoded character (one that is not supported by the primary encoding).- Parameters:
ch- the named characterwidth- the width of the character
-
encodeAllUnencodedCharacters
public void encodeAllUnencodedCharacters()Makes all unencoded characters available through additional encodings. This method is used in cases where the fonts need to be encoded in the target format before all text of the document is processed (for example in PostScript when resource optimization is disabled). -
hasAdditionalEncodings
public boolean hasAdditionalEncodings()Indicates whether the encoding has additional encodings besides the primary encoding.- Returns:
- true if there are additional encodings.
-
getAdditionalEncodingCount
public int getAdditionalEncodingCount()Returns the number of additional encodings this single-byte font maintains.- Returns:
- the number of additional encodings
-
getAdditionalEncoding
public SimpleSingleByteEncoding getAdditionalEncoding(int index) throws java.lang.IndexOutOfBoundsExceptionReturns an additional encoding.- Parameters:
index- the index of the additional encoding- Returns:
- the additional encoding
- Throws:
java.lang.IndexOutOfBoundsException- if the index is out of bounds
-
getAdditionalWidths
public int[] getAdditionalWidths(int index)Returns an array with the widths for an additional encoding.- Parameters:
index- the index of the additional encoding- Returns:
- the width array
-