Package com.helger.pdflayout.spec
Class LoadedFont
- java.lang.Object
-
- com.helger.pdflayout.spec.LoadedFont
-
@Immutable @MustImplementEqualsAndHashcode public class LoadedFont extends Object
This class represents a wrapper around aPDFontthat is uniquely assigned to a PDDocument.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description LoadedFont(org.apache.pdfbox.pdmodel.font.PDFont aFont, int nFallbackCodePoint)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static com.helger.pdflayout.spec.LoadedFont.EncodedCodePointencodeCodepointWithFallback(org.apache.pdfbox.pdmodel.font.PDFont aFont, int nCodepoint, int nFallbackCodepoint)booleanequals(Object o)floatgetDescent(float fFontSize)byte[]getEncodedForPageContentStream(String sText)A quick version to encode the passed text so that it can be written withCOSWriter.writeStringcom.helger.commons.collection.impl.ICommonsList<TextAndWidthSpec>getFitToWidth(String sText, float fFontSize, float fMaxWidth)org.apache.pdfbox.pdmodel.font.PDFontgetFont()floatgetStringWidth(String sText, float fFontSize)floatgetTextHeight(float fFontSize)inthashCode()StringtoString()
-
-
-
Constructor Detail
-
LoadedFont
public LoadedFont(@Nonnull org.apache.pdfbox.pdmodel.font.PDFont aFont, int nFallbackCodePoint)
-
-
Method Detail
-
getFont
@Nonnull public final org.apache.pdfbox.pdmodel.font.PDFont getFont()
- Returns:
- The underlying font. Never
null.
-
getDescent
@Nonnegative public final float getDescent(@Nonnegative float fFontSize)
-
getTextHeight
@Nonnegative public final float getTextHeight(@Nonnegative float fFontSize)
-
encodeCodepointWithFallback
@Nonnull public static com.helger.pdflayout.spec.LoadedFont.EncodedCodePoint encodeCodepointWithFallback(@Nonnull org.apache.pdfbox.pdmodel.font.PDFont aFont, int nCodepoint, int nFallbackCodepoint) throws IOException
- Throws:
IOException
-
getStringWidth
@Nonnegative public float getStringWidth(@Nonnull String sText, @Nonnegative float fFontSize) throws IOException
- Throws:
IOException
-
getEncodedForPageContentStream
@Nonnull public byte[] getEncodedForPageContentStream(@Nonnull String sText) throws IOException
A quick version to encode the passed text so that it can be written withCOSWriter.writeString- Parameters:
sText- Text to be written.- Returns:
- The byte array that can be written with the COSWrite. Never
null. - Throws:
IOException- In case something goes wrong
-
getFitToWidth
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<TextAndWidthSpec> getFitToWidth(@Nullable String sText, @Nonnegative float fFontSize, @Nonnegative float fMaxWidth) throws IOException
- Throws:
IOException
-
-