public final class FontUtils extends Object
Utility methods for fonts
| Modifier and Type | Method and Description |
|---|---|
static void |
addDefaultFonts(org.apache.pdfbox.pdmodel.font.PDFont font,
org.apache.pdfbox.pdmodel.font.PDFont fontBold,
org.apache.pdfbox.pdmodel.font.PDFont fontItalic,
org.apache.pdfbox.pdmodel.font.PDFont fontBoldItalic) |
static float |
getAscent(org.apache.pdfbox.pdmodel.font.PDFont font,
float fontSize)
Calculate the font ascent distance.
|
static Map<String,org.apache.pdfbox.pdmodel.font.PDFont> |
getDefaultfonts() |
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. |
static void |
setSansFontsAsDefault(org.apache.pdfbox.pdmodel.PDDocument document) |
public static final 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.
document - PDDocument where fonts will be loadedfontPath - font path which will be loadedPDType0Fontpublic 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 - PDFont from which the height will be calculated.fontSize - font size for current PDFont.PDFont's heightpublic static void addDefaultFonts(org.apache.pdfbox.pdmodel.font.PDFont font,
org.apache.pdfbox.pdmodel.font.PDFont fontBold,
org.apache.pdfbox.pdmodel.font.PDFont fontItalic,
org.apache.pdfbox.pdmodel.font.PDFont fontBoldItalic)
public static void setSansFontsAsDefault(org.apache.pdfbox.pdmodel.PDDocument document)
Copyright © 2020. All rights reserved.