Package net.atthegate.server.service.pdf
Class Font
java.lang.Object
net.atthegate.server.service.pdf.Font
Used to create font objects.
The font objects must added to the PDF before they can be used to draw text.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
protected int[]
protected float
protected float
protected float
protected float
protected float
protected float
protected float
protected boolean
protected int
protected float
protected int
protected int
protected String
protected int[]
protected String
protected boolean
protected boolean
protected boolean
static final String
protected int
protected int[][]
protected String
protected int
protected float
protected boolean
static final String
static final boolean
protected int
protected float
protected float
protected int[]
protected int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionFont
(Map<Integer, PDFobj> objects, InputStream inputStream, boolean flag) protected
Font
(PDF pdf, InputStream inputStream, boolean flag) Constructor for CJK - Chinese, Japanese and Korean fonts.Constructor for the 14 standard fonts. -
Method Summary
Modifier and TypeMethodDescriptionfloat
Returns the ascent of this font.float
Returns the height of the body of the font.protected int
protected int
float
Returns the descent of this font.protected int
int
getFitChars
(String str, double width) Returns the number of characters from the specified string that will fit within the specified width.int
getFitChars
(String str, float width) Returns the number of characters from the specified string that will fit within the specified width.protected int
float
Returns the height of this font.float
getSize()
Returns the current font size.protected int
float
float
protected int
protected void
setCidFontDictObjNumber
(int cidFontDictObjNumber) protected void
setCMapObjNumber
(int cMapObjNumber) protected void
setEncodingObjNumber
(int encodingObjNumber) protected void
setFontDescriptorObjNumber
(int fontDescriptorObjNumber) void
setItalic
(boolean skew15) Sets the skew15 private variable.void
setKernPairs
(boolean kernPairs) Sets the kerning for the selected font to 'true' or 'false' depending on the passed value of kernPairs parameter.setSize
(double fontSize) Sets the size of this font.setSize
(float fontSize) Sets the size of this font.protected void
setToUnicodeCMapObjNumber
(int toUnicodeCMapObjNumber) protected void
setWidthsArrayObjNumber
(int widthsArrayObjNumber) float
stringWidth
(String str) Returns the width of the specified string when drawn on the page with this font using the current font size.float
stringWidth
(Font font2, String str) Returns the width of a string drawn using two fonts.
-
Field Details
-
AdobeMingStd_Light
- See Also:
-
STHeitiSC_Light
- See Also:
-
KozMinProVI_Regular
- See Also:
-
AdobeMyungjoStd_Medium
- See Also:
-
STREAM
public static final boolean STREAM- See Also:
-
name
-
info
-
objNumber
protected int objNumber -
fileObjNumber
protected int fileObjNumber -
unitsPerEm
protected int unitsPerEm -
size
protected float size -
ascent
protected float ascent -
descent
protected float descent -
capHeight
protected float capHeight -
body_height
protected float body_height -
metrics
protected int[][] metrics -
isCoreFont
protected boolean isCoreFont -
isCJK
protected boolean isCJK -
firstChar
protected int firstChar -
lastChar
protected int lastChar -
skew15
protected boolean skew15 -
kernPairs
protected boolean kernPairs -
bBoxLLx
protected float bBoxLLx -
bBoxLLy
protected float bBoxLLy -
bBoxURx
protected float bBoxURx -
bBoxURy
protected float bBoxURy -
underlinePosition
protected float underlinePosition -
underlineThickness
protected float underlineThickness -
compressed_size
protected int compressed_size -
uncompressed_size
protected int uncompressed_size -
advanceWidth
protected int[] advanceWidth -
glyphWidth
protected int[] glyphWidth -
unicodeToGID
protected int[] unicodeToGID -
cff
protected boolean cff -
fontID
-
-
Constructor Details
-
Font
Constructor for the 14 standard fonts. Creates a font object and adds it to the PDF.Examples: Font font1 = new Font(pdf, CoreFont.HELVETICA); Font font2 = new Font(pdf, CoreFont.TIMES_ITALIC); Font font3 = new Font(pdf, CoreFont.ZAPF_DINGBATS); ...
- Parameters:
pdf
- the PDF to add this font to.coreFont
- the core font. Must be one the names defined in the CoreFont class.- Throws:
Exception
-
Font
-
Font
- Throws:
Exception
-
Font
Constructor for CJK - Chinese, Japanese and Korean fonts. Please see Example_04.- Parameters:
pdf
- the PDF to add this font to.fontName
- the font name. Please see Example_04.codePage
- the code page. Must be: CodePage.UNICODE- Throws:
Exception
-
Font
- Throws:
Exception
-
Font
- Throws:
Exception
-
-
Method Details
-
getFontDescriptorObjNumber
protected int getFontDescriptorObjNumber() -
getCMapObjNumber
protected int getCMapObjNumber() -
getCidFontDictObjNumber
protected int getCidFontDictObjNumber() -
getToUnicodeCMapObjNumber
protected int getToUnicodeCMapObjNumber() -
getWidthsArrayObjNumber
protected int getWidthsArrayObjNumber() -
getEncodingObjNumber
protected int getEncodingObjNumber() -
getUnderlinePosition
public float getUnderlinePosition() -
getUnderlineThickness
public float getUnderlineThickness() -
setFontDescriptorObjNumber
protected void setFontDescriptorObjNumber(int fontDescriptorObjNumber) -
setCMapObjNumber
protected void setCMapObjNumber(int cMapObjNumber) -
setCidFontDictObjNumber
protected void setCidFontDictObjNumber(int cidFontDictObjNumber) -
setToUnicodeCMapObjNumber
protected void setToUnicodeCMapObjNumber(int toUnicodeCMapObjNumber) -
setWidthsArrayObjNumber
protected void setWidthsArrayObjNumber(int widthsArrayObjNumber) -
setEncodingObjNumber
protected void setEncodingObjNumber(int encodingObjNumber) -
setSize
Sets the size of this font.- Parameters:
fontSize
- specifies the size of this font.- Returns:
- the font.
-
setSize
Sets the size of this font.- Parameters:
fontSize
- specifies the size of this font.- Returns:
- the font.
-
getSize
public float getSize()Returns the current font size.- Returns:
- the current size of the font.
-
setKernPairs
public void setKernPairs(boolean kernPairs) Sets the kerning for the selected font to 'true' or 'false' depending on the passed value of kernPairs parameter. The kerning is implemented only for the 14 standard fonts.- Parameters:
kernPairs
- if 'true' the kerning for this font is enabled.
-
stringWidth
Returns the width of the specified string when drawn on the page with this font using the current font size.- Parameters:
str
- the specified string.- Returns:
- the width of the string when draw on the page with this font using the current selected size.
-
getAscent
public float getAscent()Returns the ascent of this font.- Returns:
- the ascent of the font.
-
getDescent
public float getDescent()Returns the descent of this font.- Returns:
- the descent of the font.
-
getHeight
public float getHeight()Returns the height of this font.- Returns:
- the height of the font.
-
getBodyHeight
public float getBodyHeight()Returns the height of the body of the font.- Returns:
- float the height of the body of the font.
-
getFitChars
Returns the number of characters from the specified string that will fit within the specified width.- Parameters:
str
- the specified string.width
- the specified width.- Returns:
- the number of characters that will fit.
-
getFitChars
Returns the number of characters from the specified string that will fit within the specified width.- Parameters:
str
- the specified string.width
- the specified width.- Returns:
- the number of characters that will fit.
-
setItalic
public void setItalic(boolean skew15) Sets the skew15 private variable. When the variable is set to 'true' all glyphs in the font are skewed on 15 degrees. This makes a regular font look like an italic type font. Use this method when you don't have real italic font in the font family, or when you want to generate smaller PDF files. For example you could embed only the Regular and Bold fonts and synthesize the RegularItalic and BoldItalic.- Parameters:
skew15
- the skew flag.
-
stringWidth
Returns the width of a string drawn using two fonts.- Parameters:
font2
- the fallback font.str
- the string.- Returns:
- the width.
-