Package org.verapdf.pd.font
Class PDFont
java.lang.Object
org.verapdf.pd.PDObject
org.verapdf.pd.PDResource
org.verapdf.pd.font.PDFont
- Direct Known Subclasses:
PDCIDFont,PDSimpleFont
This is PD representation of font.
- Author:
- Sergey Shemyakov
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double[]protected COSDictionaryprotected Encodingprotected PDFontDescriptorprotected FontProgramprotected booleanprotected PDCMap -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected EncodingcMapToUnicode(int code) Gets toUnicode value just from toUnicode cMap.double[]abstract FontProgramgetName()getType()getWidth(int code) Gets width for glyph with given code in this font.abstract floatgetWidthFromProgram(int code) Gets width of given code from font program.abstract booleanglyphIsPresent(int code) Checks if glyph for given code is present in this font.protected booleanisSubset()booleanbooleanintreadCode(InputStream stream) Method reads next character code from stream according to font data.voidsetSuccessfullyParsed(boolean successfullyParsed) Sets flag indicating successful parsing of embedded font program.toUnicode(int code) Gets Unicode string for given character code.Methods inherited from class org.verapdf.pd.PDResource
isInherited, setInheritedMethods inherited from class org.verapdf.pd.PDObject
clear, empty, getBooleanKey, getIntegerKey, getKey, getNameKey, getNameKeyStringValue, getObject, getRealKey, getStringKey, knownKey, removeKey, setBooleanKey, setIntegerKey, setKey, setNameKey, setObject, setObject, setStringKey, updateFromObject, updateToObject
-
Field Details
-
dictionary
-
fontDescriptor
-
toUnicodeCMap
-
isFontParsed
protected boolean isFontParsed -
fontProgram
-
encoding
-
boundingBox
protected double[] boundingBox
-
-
Constructor Details
-
PDFont
Constructor from COSDictionary.- Parameters:
dictionary- is font dictionary.
-
-
Method Details
-
getDictionary
- Returns:
- font COSDictionary.
-
getFontDescriptor
- Returns:
- font descriptor COSDictionary.
-
getType
- Returns:
- font type (Type entry).
-
getSubtype
- Returns:
- font subtype (Subtype entry).
-
getSubtypeEntryValue
-
isSymbolic
public boolean isSymbolic()- Returns:
- true if the font flags in the font descriptor dictionary mark indicate that the font is symbolic (the entry /Flags has bit 3 set to 1 and bit 6 set to 0). descriptor is null.
-
getEncodingMapping
- Returns:
- encoding mapping object for this font.
-
calculateEncodingMapping
-
getFontWeight
-
getName
- Returns:
- name of the font as specified in BaseFont key of font dictionary.
-
getNameWithoutSubset
- Returns:
- name of the font without subset as specified in BaseFont key of font dictionary.
-
getBoundingBox
public double[] getBoundingBox() -
getEncoding
- Returns:
- encoding of the font as specified in Encoding key of font dictionary.
-
getDifferences
- Returns:
- map of differences as given in Differences key in Encoding of this font.
-
getDifferencesFromCosEncoding
- Returns:
- map of differences as given in Differences key in Encoding.
-
getWidths
- Returns:
- widths of the font as specified in Widths key of font dictionary.
-
getFirstChar
- Returns:
- first char in the font as specified in FirstChar key of font dictionary.
-
getLastChar
- Returns:
- last char in the font as specified in LastChar key of font dictionary.
-
readCode
Method reads next character code from stream according to font data. It can contain from 1 to 4 bytes.- Parameters:
stream- is stream with raw data.- Returns:
- next character code read.
- Throws:
IOException- if reading fails.
-
getFontProgram
- Returns:
- embedded font program fo this PDFont.
-
getWidthFromProgram
public abstract float getWidthFromProgram(int code) Gets width of given code from font program.- Parameters:
code- is code of character in strings to display.- Returns:
- width of glyph for this code.
-
glyphIsPresent
public abstract boolean glyphIsPresent(int code) Checks if glyph for given code is present in this font.- Parameters:
code- is code for glyph in this font.- Returns:
- true if glyph is present.
-
toUnicode
Gets Unicode string for given character code. This method returns null in case when no toUnicode mapping for this character was found, so some inherited classes need to call this method, check return value on null and then implement their special logic.- Parameters:
code- is code for character.- Returns:
- Unicode string
-
cMapToUnicode
Gets toUnicode value just from toUnicode cMap.- Parameters:
code- is character code.- Returns:
- Unicode value as specified in toUnicode cMap.
-
getProgramSubtype
- Returns:
- value of Subtype key in embedded font program stream or null if no value available.
-
getWidth
Gets width for glyph with given code in this font.- Parameters:
code- is code of glyph.- Returns:
- width for glyph with given code as specified in Widths array.
-
getDefaultWidth
- Returns:
- default width for this font as specified in font descriptor.
-
isSuccessfullyParsed
public boolean isSuccessfullyParsed()- Returns:
- true if font program for this font has been successfully parsed.
-
setSuccessfullyParsed
public void setSuccessfullyParsed(boolean successfullyParsed) Sets flag indicating successful parsing of embedded font program. -
isSubset
protected boolean isSubset() -
getAscent
-
getDescent
-