Package com.itextpdf.io.font
Class FontProgram
- java.lang.Object
-
- com.itextpdf.io.font.FontProgram
-
- Direct Known Subclasses:
CidFont
,TrueTypeFont
,Type1Font
,Type3Font
public abstract class FontProgram extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected int
avgWidth
protected java.util.Map<java.lang.Integer,Glyph>
codeToGlyph
static int
DEFAULT_WIDTH
protected java.lang.String
encodingScheme
The font's encoding name.protected FontIdentification
fontIdentification
protected FontMetrics
fontMetrics
protected FontNames
fontNames
static int
HORIZONTAL_SCALING_FACTOR
protected boolean
isFontSpecific
protected java.lang.String
registry
protected java.util.Map<java.lang.Integer,Glyph>
unicodeToGlyph
static int
UNITS_NORMALIZATION
-
Constructor Summary
Constructors Constructor Description FontProgram()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static double
convertGlyphSpaceToTextSpace(double value)
static float
convertGlyphSpaceToTextSpace(float value)
static int
convertGlyphSpaceToTextSpace(int value)
static float
convertTextSpaceToGlyphSpace(float value)
int
countOfGlyphs()
protected void
fixSpaceIssue()
int
getAvgWidth()
int[]
getCharBBox(int unicode)
Get glyph's bbox.FontIdentification
getFontIdentification()
FontMetrics
getFontMetrics()
FontNames
getFontNames()
Glyph
getGlyph(int unicode)
Glyph
getGlyphByCode(int charCode)
int
getKerning(int first, int second)
Gets the kerning between two glyphs.abstract int
getKerning(Glyph first, Glyph second)
Gets the kerning between two glyphs.abstract int
getPdfFontFlags()
java.lang.String
getRegistry()
int
getWidth(int unicode)
Get glyph's width.boolean
hasKernPairs()
boolean
isBuiltWith(java.lang.String fontName)
Checks whether theFontProgram
was built with corresponding fontName.boolean
isFontSpecific()
protected void
setBbox(int[] bbox)
protected void
setBold(boolean isBold)
protected void
setCapHeight(int capHeight)
Sets the capital letters height.protected void
setFixedPitch(boolean isFixedPitch)
protected void
setFontFamily(java.lang.String fontFamily)
Sets a preferred font family name.protected void
setFontName(java.lang.String fontName)
Sets the PostScript name of the font.protected void
setFontStretch(java.lang.String fontWidth)
Sets font width in css notation (font-stretch property)protected void
setFontWeight(int fontWeight)
Sets font weight.protected void
setItalicAngle(int italicAngle)
Sets the PostScript italic angle.protected void
setRegistry(java.lang.String registry)
protected void
setStemH(int stemH)
protected void
setStemV(int stemV)
protected void
setTypoAscender(int ascender)
Sets typo ascender.protected void
setTypoDescender(int descender)
Sets typo descender.protected void
setXHeight(int xHeight)
java.lang.String
toString()
(package private) static java.lang.String
trimFontStyle(java.lang.String name)
Gets the name without the modifiers Bold, Italic or BoldItalic.
-
-
-
Field Detail
-
HORIZONTAL_SCALING_FACTOR
public static final int HORIZONTAL_SCALING_FACTOR
- See Also:
- Constant Field Values
-
DEFAULT_WIDTH
public static final int DEFAULT_WIDTH
- See Also:
- Constant Field Values
-
UNITS_NORMALIZATION
public static final int UNITS_NORMALIZATION
- See Also:
- Constant Field Values
-
codeToGlyph
protected java.util.Map<java.lang.Integer,Glyph> codeToGlyph
-
unicodeToGlyph
protected java.util.Map<java.lang.Integer,Glyph> unicodeToGlyph
-
isFontSpecific
protected boolean isFontSpecific
-
fontNames
protected FontNames fontNames
-
fontMetrics
protected FontMetrics fontMetrics
-
fontIdentification
protected FontIdentification fontIdentification
-
avgWidth
protected int avgWidth
-
encodingScheme
protected java.lang.String encodingScheme
The font's encoding name. This encoding is 'StandardEncoding' or 'AdobeStandardEncoding' for a font that can be totally encoded according to the characters names. For all other names the font is treated as symbolic.
-
registry
protected java.lang.String registry
-
-
Method Detail
-
convertTextSpaceToGlyphSpace
public static float convertTextSpaceToGlyphSpace(float value)
-
convertGlyphSpaceToTextSpace
public static float convertGlyphSpaceToTextSpace(float value)
-
convertGlyphSpaceToTextSpace
public static double convertGlyphSpaceToTextSpace(double value)
-
convertGlyphSpaceToTextSpace
public static int convertGlyphSpaceToTextSpace(int value)
-
countOfGlyphs
public int countOfGlyphs()
-
getFontNames
public FontNames getFontNames()
-
getFontMetrics
public FontMetrics getFontMetrics()
-
getFontIdentification
public FontIdentification getFontIdentification()
-
getRegistry
public java.lang.String getRegistry()
-
getPdfFontFlags
public abstract int getPdfFontFlags()
-
isFontSpecific
public boolean isFontSpecific()
-
getWidth
public int getWidth(int unicode)
Get glyph's width.- Parameters:
unicode
- a unicode symbol or FontSpecif code.- Returns:
- Gets width in normalized 1000 units.
-
getAvgWidth
public int getAvgWidth()
-
getCharBBox
public int[] getCharBBox(int unicode)
Get glyph's bbox.- Parameters:
unicode
- a unicode symbol or FontSpecif code.- Returns:
- Gets bbox in normalized 1000 units.
-
getGlyph
public Glyph getGlyph(int unicode)
-
getGlyphByCode
public Glyph getGlyphByCode(int charCode)
-
hasKernPairs
public boolean hasKernPairs()
-
getKerning
public int getKerning(int first, int second)
Gets the kerning between two glyphs.- Parameters:
first
- the first unicode valuesecond
- the second unicode value- Returns:
- the kerning to be applied
-
getKerning
public abstract int getKerning(Glyph first, Glyph second)
Gets the kerning between two glyphs.- Parameters:
first
- the first glyphsecond
- the second glyph- Returns:
- the kerning to be applied
-
isBuiltWith
public boolean isBuiltWith(java.lang.String fontName)
Checks whether theFontProgram
was built with corresponding fontName. Default value is false unless overridden.- Parameters:
fontName
- a font name or path to a font program- Returns:
- true, if the FontProgram was built with the fontProgram. Otherwise false.
-
setRegistry
protected void setRegistry(java.lang.String registry)
-
trimFontStyle
static java.lang.String trimFontStyle(java.lang.String name)
Gets the name without the modifiers Bold, Italic or BoldItalic.- Parameters:
name
- the full name of the font- Returns:
- the name without the modifiers Bold, Italic or BoldItalic
-
setTypoAscender
protected void setTypoAscender(int ascender)
Sets typo ascender. See alsoFontMetrics.setTypoAscender(int)
.- Parameters:
ascender
- typo ascender value in 1000-units
-
setTypoDescender
protected void setTypoDescender(int descender)
Sets typo descender. See alsoFontMetrics.setTypoDescender(int)
.- Parameters:
descender
- typo descender value in 1000-units
-
setCapHeight
protected void setCapHeight(int capHeight)
Sets the capital letters height. See alsoFontMetrics.setCapHeight(int)
.- Parameters:
capHeight
- cap height in 1000-units
-
setXHeight
protected void setXHeight(int xHeight)
-
setItalicAngle
protected void setItalicAngle(int italicAngle)
Sets the PostScript italic angle.Italic angle in counter-clockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right (forward).
- Parameters:
italicAngle
- in counter-clockwise degrees from the vertical
-
setStemV
protected void setStemV(int stemV)
-
setStemH
protected void setStemH(int stemH)
-
setFontWeight
protected void setFontWeight(int fontWeight)
Sets font weight.- Parameters:
fontWeight
- integer form 100 to 900. SeeFontWeights
.
-
setFontStretch
protected void setFontStretch(java.lang.String fontWidth)
Sets font width in css notation (font-stretch property)- Parameters:
fontWidth
-FontStretches
.
-
setFixedPitch
protected void setFixedPitch(boolean isFixedPitch)
-
setBold
protected void setBold(boolean isBold)
-
setBbox
protected void setBbox(int[] bbox)
-
setFontFamily
protected void setFontFamily(java.lang.String fontFamily)
Sets a preferred font family name.- Parameters:
fontFamily
- a preferred font family name.
-
setFontName
protected void setFontName(java.lang.String fontName)
Sets the PostScript name of the font.If full name is null, it will be set as well.
- Parameters:
fontName
- the PostScript name of the font, shall not be null or empty.
-
fixSpaceIssue
protected void fixSpaceIssue()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-