public abstract class PdfFont extends PdfObjectWrapper<PdfDictionary>
Modifier and Type | Field and Description |
---|---|
protected boolean |
embedded
true if the font is to be embedded in the PDF.
|
protected static byte[] |
emptyBytes |
protected FontProgram |
fontProgram |
protected boolean |
newFont
false, if the font comes from PdfDocument.
|
protected Map<Integer,Glyph> |
notdefGlyphs |
protected boolean |
subset
Indicates if all the glyphs and widths for that particular encoding should be included in the document.
|
protected List |
subsetRanges |
Modifier | Constructor and Description |
---|---|
protected |
PdfFont() |
protected |
PdfFont(PdfDictionary fontDictionary) |
Modifier and Type | Method and Description |
---|---|
void |
addSubsetRange(int[] range)
Adds a character range when subsetting.
|
protected boolean |
checkFontDictionary(PdfDictionary fontDic, PdfName fontType) |
protected boolean |
checkTrueTypeFontDictionary(PdfDictionary fontDic) |
protected boolean |
checkTrueTypeFontDictionary(PdfDictionary fontDic, boolean isException) |
protected static int[] |
compactRanges(List |
boolean |
containsGlyph(char unicode) |
abstract byte[] |
convertToBytes(Glyph glyph) |
abstract byte[] |
convertToBytes(GlyphLine glyphLine) |
abstract byte[] |
convertToBytes(String text)
Converts the text into bytes to be placed in the document.
|
abstract GlyphLine |
createGlyphLine(String content) |
protected static String |
createSubsetPrefix()
Creates a unique subset prefix to be added to the font name when the font is embedded and subset.
|
abstract String |
decode(PdfString content) |
int |
getAscent(int unicode, float fontSize)
Gets the ascent of a char code in normalized 1000 units.
|
int |
getAscent(String text, float fontSize)
Gets the ascent of a String in points.
|
abstract float |
getContentWidth(PdfString content) |
int |
getDescent(int unicode, float fontSize)
Gets the descent of a char code in points.
|
int |
getDescent(String text, float fontSize)
Gets the descent of a String in points.
|
protected abstract PdfDictionary |
getFontDescriptor(String fontName) |
double[] |
getFontMatrix() |
FontProgram |
getFontProgram() |
abstract Glyph |
getGlyph(int unicode) |
protected PdfStream |
getPdfFontStream(byte[] fontStreamBytes, int[] fontStreamLengths)
Create PdfStream based on fontStreamBytes .
|
int |
getWidth(int unicode)
Returns the width of a certain character of this font in 1000 normalized units.
|
float |
getWidth(int unicode, float fontSize)
Returns the width of a certain character of this font in points.
|
int |
getWidth(String text)
Returns the width of a string of this font in 1000 normalized units.
|
float |
getWidth(String text, float fontSize)
Gets the width of a String in points.
|
boolean |
isEmbedded() |
boolean |
isSubset()
Indicates if all the glyphs and widths for that particular encoding should be included in the document.
|
protected boolean |
isWrappedObjectMustBeIndirect()
Defines if the object behind this wrapper must be an indirect object in the resultant document.
|
void |
setSubset(boolean subset)
Indicates if all the glyphs and widths for that particular encoding should be included in the document.
|
List<String> |
splitString(String text, int fontSize, float maxWidth) |
abstract void |
writeText(GlyphLine text, int from, int to, PdfOutputStream stream) |
void |
writeText(GlyphLine text, PdfOutputStream stream) |
abstract void |
writeText(String text, PdfOutputStream stream) |
ensureObjectIsAddedToDocument, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
protected FontProgram fontProgram
protected static final byte[] emptyBytes
protected boolean newFont
protected boolean embedded
protected boolean subset
protected ListsubsetRanges
protected PdfFont(PdfDictionary fontDictionary)
protected PdfFont()
public abstract Glyph getGlyph(int unicode)
public boolean containsGlyph(char unicode)
public abstract byte[] convertToBytes(String text)
text
- the text to convert
public abstract byte[] convertToBytes(GlyphLine glyphLine)
public abstract float getContentWidth(PdfString content)
public abstract byte[] convertToBytes(Glyph glyph)
public abstract void writeText(GlyphLine text, int from, int to, PdfOutputStream stream)
public abstract void writeText(String text, PdfOutputStream stream)
public void writeText(GlyphLine text, PdfOutputStream stream)
public double[] getFontMatrix()
public int getWidth(int unicode)
unicode
- a certain character.
public float getWidth(int unicode, float fontSize)
unicode
- a certain character.
fontSize
- the font size.
public int getWidth(String text)
text
- a string content.
public float getWidth(String text, float fontSize)
String
in points.
text
- the String
to get the width of
fontSize
- the font size
public int getDescent(String text, float fontSize)
String
in points. The descent will always be less than or equal to zero even if all the characters have an higher descent.
text
- the String
to get the descent of
fontSize
- the font size
public int getDescent(int unicode, float fontSize)
unicode
- the char code to get the descent of
fontSize
- the font size
public int getAscent(String text, float fontSize)
String
in points. The ascent will always be greater than or equal to zero even if all the characters have a lower ascent.
text
- the String
to get the ascent of
fontSize
- the font size
public int getAscent(int unicode, float fontSize)
unicode
- the char code to get the ascent of
fontSize
- the font size
public FontProgram getFontProgram()
public boolean isEmbedded()
public boolean isSubset()
false
to include all the glyphs and widths.
public void setSubset(boolean subset)
true
only the glyphs used will be included in the font. When set to false
and addSubsetRange(int[])
was not called the full font will be included otherwise just the characters ranges will be included.
subset
- new value of property subset
public void addSubsetRange(int[] range)
int
array where the first element is the start range inclusive and the second element is the end range inclusive. Several ranges are allowed in the same array.
range
- the character range
protected abstract PdfDictionary getFontDescriptor(String fontName)
protected boolean isWrappedObjectMustBeIndirect()
PdfObjectWrapper
isWrappedObjectMustBeIndirect
in class PdfObjectWrapper<PdfDictionary>
protected boolean checkFontDictionary(PdfDictionary fontDic, PdfName fontType)
protected boolean checkTrueTypeFontDictionary(PdfDictionary fontDic)
protected boolean checkTrueTypeFontDictionary(PdfDictionary fontDic, boolean isException)
protected static String createSubsetPrefix()
protected PdfStream getPdfFontStream(byte[] fontStreamBytes, int[] fontStreamLengths)
PdfStream
based on fontStreamBytes
.
fontStreamBytes
- original font data, must be not null.
fontStreamLengths
- array to generate Length*
keys, must be not null.
null
, if there is an error reading the font.
PdfException
- Method will throw exception if fontStreamBytes
is null
.
protected static int[] compactRanges(Listranges)
Copyright © 1998–2016 iText Group NV. All rights reserved.