Package be.quodlibet.boxable.utils
Class FontUtils
java.lang.Object
be.quodlibet.boxable.utils.FontUtils
Utility methods for fonts
- Author:
- hstimac, mkuehne
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDefaultFonts(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 floatgetAscent(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize) Calculate the font ascent distance.static floatgetDescent(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize) Calculate the font descent distance.static floatgetHeight(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize) Calculate the font height.static floatgetStringWidth(org.apache.pdfbox.pdmodel.font.PDFont font, String text, float fontSize) RetrievingStringwidth depending on current font size.static final org.apache.pdfbox.pdmodel.font.PDType0FontLoads thePDType0Fontto be embedded in the specifiedPDDocument.static voidsetSansFontsAsDefault(org.apache.pdfbox.pdmodel.PDDocument document)
-
Method Details
-
loadFont
public static final org.apache.pdfbox.pdmodel.font.PDType0Font loadFont(org.apache.pdfbox.pdmodel.PDDocument document, String fontPath) Loads the
PDType0Fontto be embedded in the specifiedPDDocument.- Parameters:
document-PDDocumentwhere fonts will be loadedfontPath- font path which will be loaded- Returns:
- The read
PDType0Font
-
getStringWidth
public static float getStringWidth(org.apache.pdfbox.pdmodel.font.PDFont font, String text, float fontSize) Retrieving
Stringwidth depending on current font size. The width of the string in 1/1000 units of text space.- Parameters:
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 retrieved- Returns:
- text width
-
getAscent
public static float getAscent(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize) Calculate the font ascent distance.
- Parameters:
font- The font from which calculation will be appliedfontSize- The font size from which calculation will be applied- Returns:
- Positive font ascent distance
-
getDescent
public static float getDescent(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize) Calculate the font descent distance.
- Parameters:
font- The font from which calculation will be appliedfontSize- The font size from which calculation will be applied- Returns:
- Negative font descent distance
-
getHeight
public static float getHeight(org.apache.pdfbox.pdmodel.font.PDFont font, float fontSize) Calculate the font height.
- Parameters:
font-PDFontfrom which the height will be calculated.fontSize- font size for currentPDFont.- Returns:
PDFont's height
-
addDefaultFonts
public 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) -
getDefaultfonts
-
setSansFontsAsDefault
public static void setSansFontsAsDefault(org.apache.pdfbox.pdmodel.PDDocument document)
-