public final class FontUtils extends Object
Utility methods for fonts
| Modifier and Type | Method and Description |
|---|---|
static float |
getAscent(org.apache.pdfbox.pdmodel.font.PDFont font,
float fontSize)
Calculate the font ascent distance.
|
static float |
getDescent(org.apache.pdfbox.pdmodel.font.PDFont font,
float fontSize)
Calculate the font descent distance.
|
static float |
getHeight(org.apache.pdfbox.pdmodel.font.PDFont font,
float fontSize)
Calculate the font height.
|
static float |
getStringWidth(org.apache.pdfbox.pdmodel.font.PDFont font,
String text,
float fontSize)
Retrieving
String width depending on current font size. |
static org.apache.pdfbox.pdmodel.font.PDType0Font |
loadFont(org.apache.pdfbox.pdmodel.PDDocument document,
String fontPath)
Loads the
PDType0Font to be embedded in the specified
PDDocument. |
public static final org.apache.pdfbox.pdmodel.font.PDType0Font loadFont(org.apache.pdfbox.pdmodel.PDDocument document,
String fontPath)
throws IOException
Loads the PDType0Font to be embedded in the specified
PDDocument.
document - fontPath - PDType0FontIOException - If reading the font file failspublic static float getStringWidth(org.apache.pdfbox.pdmodel.font.PDFont font,
String text,
float fontSize)
Retrieving String width depending on current font size. The width
of the string in 1/1000 units of text space.
font - The font of text whose width will be retrievedtext - The text whose width will be retrievedfontSize - The font size of text whose width will be retrievedpublic static float getAscent(org.apache.pdfbox.pdmodel.font.PDFont font,
float fontSize)
Calculate the font ascent distance.
font - The font from which calculation will be appliedfontSize - The font size from which calculation will be appliedpublic static float getDescent(org.apache.pdfbox.pdmodel.font.PDFont font,
float fontSize)
Calculate the font descent distance.
font - The font from which calculation will be appliedfontSize - The font size from which calculation will be appliedpublic static float getHeight(org.apache.pdfbox.pdmodel.font.PDFont font,
float fontSize)
Calculate the font height.
font - fontSize - Copyright © 2016. All rights reserved.