Package org.verapdf.pd.font.type1
Class Type1FontProgram
- java.lang.Object
-
- org.verapdf.parser.NotSeekableBaseParser
-
- org.verapdf.parser.NotSeekableCOSParser
-
- org.verapdf.parser.postscript.PSParser
-
- org.verapdf.pd.font.type1.Type1FontProgram
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FontProgram
public class Type1FontProgram extends PSParser implements FontProgram
This class does parsing of Type 1 font files.- Author:
- Sergey Shemyakov
-
-
Field Summary
Fields Modifier and Type Field Description static Logger
LOGGER
static Set<String>
OPERATORS_KEYWORDS
-
Fields inherited from class org.verapdf.parser.postscript.PSParser
operandStack, userDict
-
Fields inherited from class org.verapdf.parser.NotSeekableCOSParser
document, flag, integers, keyOfCurrentObject, objects
-
Fields inherited from class org.verapdf.parser.NotSeekableBaseParser
isPSParser, source
-
-
Constructor Summary
Constructors Constructor Description Type1FontProgram(ASInputStream fileStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsCID(int cid)
Method works only for fonts where cid notation is used.boolean
containsCode(int code)
Checks if font contains character with given code.boolean
containsGlyph(String glyphName)
Checks if this font program has glyph for given glyph name.Double
getAscent()
Set<String>
getCharSet()
Double
getDescent()
String[]
getEncoding()
ASFileStreamCloser
getFontProgramResource()
String
getGlyphName(int code)
Returns glyph name for glyph with given code.String
getWeight()
float
getWidth(int charCode)
Returns width of glyph for given character code.float
getWidth(String glyphName)
Returns width of glyph for given glyph name.boolean
isAttemptedParsing()
boolean
isSuccessfulParsing()
void
parseFont()
This method is entry point for parsing process.protected void
skipSpacesExceptNullByte()
-
Methods inherited from class org.verapdf.parser.postscript.PSParser
getCloseDictionary, getDictionary, getObjectFromUserDict
-
Methods inherited from class org.verapdf.parser.NotSeekableCOSParser
getArray, getName, nextObject
-
Methods inherited from class org.verapdf.parser.NotSeekableBaseParser
close, extendArray, findKeyword, findKeyword, getLineBytes, getToken, initializeToken, isCR, isDigit, isDigit, isEndOfComment, isFF, isLF, nextToken, readLine, readNumber, readUntilDelimiter, skipSpaces, skipSpaces, skipStreamSpaces
-
-
-
-
Constructor Detail
-
Type1FontProgram
public Type1FontProgram(ASInputStream fileStream) throws IOException
- Throws:
IOException
-
-
Method Detail
-
parseFont
public void parseFont() throws IOException
This method is entry point for parsing process.- Specified by:
parseFont
in interfaceFontProgram
- Throws:
IOException
- if stream reading error occurs.
-
getWidth
public float getWidth(int charCode)
Description copied from interface:FontProgram
Returns width of glyph for given character code.- Specified by:
getWidth
in interfaceFontProgram
- Parameters:
charCode
- is code for glyph.- Returns:
- width of corresponding glyph or -1 if glyph is not found.
-
getWidth
public float getWidth(String glyphName)
Description copied from interface:FontProgram
Returns width of glyph for given glyph name.- Specified by:
getWidth
in interfaceFontProgram
- Parameters:
glyphName
- is name for glyph.- Returns:
- width of corresponding glyph or -1 if glyph is not found.
-
skipSpacesExceptNullByte
protected void skipSpacesExceptNullByte() throws IOException
- Throws:
IOException
-
containsCode
public boolean containsCode(int code)
Description copied from interface:FontProgram
Checks if font contains character with given code.- Specified by:
containsCode
in interfaceFontProgram
- Parameters:
code
- is character code.- Returns:
- true if font contains character with given code.
-
containsGlyph
public boolean containsGlyph(String glyphName)
Description copied from interface:FontProgram
Checks if this font program has glyph for given glyph name.- Specified by:
containsGlyph
in interfaceFontProgram
- Parameters:
glyphName
- is the name of glyph.- Returns:
- true if this font program has glyph for given name.
-
containsCID
public boolean containsCID(int cid)
Description copied from interface:FontProgram
Method works only for fonts where cid notation is used.- Specified by:
containsCID
in interfaceFontProgram
- Returns:
- true if font a is cid font and contains given cid.
-
isAttemptedParsing
public boolean isAttemptedParsing()
- Specified by:
isAttemptedParsing
in interfaceFontProgram
- Returns:
- true if font parsing has been attempted.
-
isSuccessfulParsing
public boolean isSuccessfulParsing()
- Specified by:
isSuccessfulParsing
in interfaceFontProgram
- Returns:
- true if font was successfully parsed.
-
getEncoding
public String[] getEncoding()
- Returns:
- encoding from embedded font program as array of strings. encoding[i] = glyphName <-> i has name glyphName.
-
getCharSet
public Set<String> getCharSet()
- Returns:
- charset from embedded program, i. e. set of all glyph names defined in the embedded font program.
-
getGlyphName
public String getGlyphName(int code)
Description copied from interface:FontProgram
Returns glyph name for glyph with given code.- Specified by:
getGlyphName
in interfaceFontProgram
- Parameters:
code
- is code of glyph.- Returns:
- glyph name.
-
getFontProgramResource
public ASFileStreamCloser getFontProgramResource()
- Specified by:
getFontProgramResource
in interfaceFontProgram
- Returns:
- the closeable object that closes source stream of this font program.
-
getWeight
public String getWeight()
- Specified by:
getWeight
in interfaceFontProgram
-
getAscent
public Double getAscent()
- Specified by:
getAscent
in interfaceFontProgram
-
getDescent
public Double getDescent()
- Specified by:
getDescent
in interfaceFontProgram
-
-