Package de.rototor.pdfbox.graphics2d
Class PdfBoxGraphics2DFontTextDrawerDefaultFonts
- java.lang.Object
-
- de.rototor.pdfbox.graphics2d.PdfBoxGraphics2DFontTextDrawer
-
- de.rototor.pdfbox.graphics2d.PdfBoxGraphics2DFontTextDrawerDefaultFonts
-
- All Implemented Interfaces:
IPdfBoxGraphics2DFontTextDrawer
,Closeable
,AutoCloseable
- Direct Known Subclasses:
PdfBoxGraphics2DFontTextForcedDrawer
public class PdfBoxGraphics2DFontTextDrawerDefaultFonts extends PdfBoxGraphics2DFontTextDrawer
LikePdfBoxGraphics2DFontTextDrawer
, but tries to use default fonts whenever possible. Default fonts are not embedded. You can register additional font files. If no font mapping is found, Helvetica is used. This will fallback to vectorized text if any kind of RTL text is rendered and/or any other not supported feature is used.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.rototor.pdfbox.graphics2d.IPdfBoxGraphics2DFontTextDrawer
IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv
-
-
Constructor Summary
Constructors Constructor Description PdfBoxGraphics2DFontTextDrawerDefaultFonts()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName
chooseMatchingCourier(Font font)
Get a PDType1Font.COURIER-variant, which matches the given fontstatic org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName
chooseMatchingHelvetica(Font font)
Get a PDType1Font.HELVETICA-variant, which matches the given fontstatic org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName
chooseMatchingTimes(Font font)
Get a PDType1Font.TIMES-variant, which matches the given fontstatic org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName
mapDefaultFonts(Font font)
Find a PDFont for the given font object, which does not need to be embedded.protected org.apache.pdfbox.pdmodel.font.PDFont
mapFont(Font font, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env)
Try to map the java.awt.Font to a PDFont.-
Methods inherited from class de.rototor.pdfbox.graphics2d.PdfBoxGraphics2DFontTextDrawer
canDrawText, close, drawText, getFontMetrics, hasDynamicFontMapping, registerFont, registerFont, registerFont, registerFont, registerFont
-
-
-
-
Method Detail
-
mapFont
protected org.apache.pdfbox.pdmodel.font.PDFont mapFont(Font font, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException
Description copied from class:PdfBoxGraphics2DFontTextDrawer
Try to map the java.awt.Font to a PDFont.- Overrides:
mapFont
in classPdfBoxGraphics2DFontTextDrawer
- Parameters:
font
- the java.awt.Font for which a mapping should be foundenv
- environment of the font mapper- Returns:
- the PDFont or null if none can be found.
- Throws:
IOException
- when the font can not be loadedFontFormatException
- when the font file can not be loaded
-
mapDefaultFonts
public static org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName mapDefaultFonts(Font font)
Find a PDFont for the given font object, which does not need to be embedded.- Parameters:
font
- font for which to find a suitable default font- Returns:
- null if no default font is found or a default font which does not need to be embedded.
-
chooseMatchingTimes
public static org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName chooseMatchingTimes(Font font)
Get a PDType1Font.TIMES-variant, which matches the given font- Parameters:
font
- Font to get the styles from- Returns:
- a PDFont Times variant which matches the style in the given Font object.
-
chooseMatchingCourier
public static org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName chooseMatchingCourier(Font font)
Get a PDType1Font.COURIER-variant, which matches the given font- Parameters:
font
- Font to get the styles from- Returns:
- a PDFont Courier variant which matches the style in the given Font object.
-
chooseMatchingHelvetica
public static org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName chooseMatchingHelvetica(Font font)
Get a PDType1Font.HELVETICA-variant, which matches the given font- Parameters:
font
- Font to get the styles from- Returns:
- a PDFont Helvetica variant which matches the style in the given Font object.
-
-