Package org.docx4j.fonts.fop.fonts
Class CustomFont
java.lang.Object
org.docx4j.fonts.fop.fonts.Typeface
org.docx4j.fonts.fop.fonts.CustomFont
- All Implemented Interfaces:
FontDescriptor,FontMetrics,MutableFont
- Direct Known Subclasses:
CIDFont,SingleByteFont
public abstract class CustomFont extends Typeface implements FontDescriptor, MutableFont
Abstract base class for custom fonts loaded from files, for example.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CustomFont() -
Method Summary
Modifier and Type Method Description intgetAscender()Returns the ascender value of the font.intgetAscender(int size)Returns the ascent of the font described by this FontMetrics object.intgetCapHeight()Returns the capital height of the font.intgetCapHeight(int size)Returns the size of a capital letter measured from the font's baseline.intgetDescender()Returns the descender value of the font.intgetDescender(int size)Returns the descent of the font described by this FontMetrics object.java.lang.StringgetEmbedFileName()Returns an URI representing an embeddable font file.javax.xml.transform.SourcegetEmbedFileSource()Returns a Source representing an embeddable font file.java.lang.StringgetEmbedFontName()Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").java.lang.StringgetEmbedResourceName()Returns the lookup name to an embeddable font file available as a resource.java.util.SetgetFamilyNames()Returns the font family names.intgetFirstChar()Returns the index of the first character defined in this font.intgetFlags()Returns the flags for the font.int[]getFontBBox()Returns the font's bounding box.java.lang.StringgetFontName()Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").java.lang.StringgetFontSubName()Returns font's subfamily name.FontTypegetFontType()Returns the type of the font.java.lang.StringgetFullName()Returns the font's full name (Example: "Helvetica Bold Oblique").intgetItalicAngle()Returns the italic angle for the font.java.util.MapgetKerningInfo()Returns the kerning map for the font.intgetLastChar()Returns the index of the last character defined in this font.intgetMissingWidth()Returns the width to be used when no width is available.PanosegetPanose()intgetStemV()Returns the vertical stem width for the font.java.lang.StringgetStrippedFontName()Returns the font family name stripped of whitespace.intgetWeight()Returns the font weight (100, 200...800, 900).intgetXHeight(int size)Determines the typical font height of this FontMetrics objectbooleanhasKerningInfo()Indicates if the font has kering information.booleanisEmbeddable()Indicates if this font may be embedded.booleanisKerningEnabled()Used to determine if kerning is enabled.booleanisSymbolicFont()Indicates whether the font is a symbolic font.voidputKerningEntry(java.lang.Integer key, java.util.Map value)Adds an entry to the kerning table.voidreplaceKerningMap(java.util.Map kerningMap)Replaces the existing kerning map with a new one.voidsetAscender(int ascender)Sets the ascent value.voidsetCapHeight(int capHeight)Sets the capital height value.voidsetDescender(int descender)Sets the descent value.voidsetEmbeddable(boolean isEmbeddable)voidsetEmbedFileName(java.lang.String path)Sets the path to the embeddable font file.voidsetEmbedResourceName(java.lang.String name)Sets the resource name of the embeddable font file.voidsetFamilyNames(java.util.Set names)Sets the font's family names (Example: "Helvetica").voidsetFirstChar(int index)Sets the index of the first character in the character table.voidsetFlags(int flags)Sets the font's flagsvoidsetFontBBox(int[] bbox)Sets the font's bounding boxvoidsetFontName(java.lang.String name)Sets the "PostScript" font name (Example: "Helvetica-BoldOblique").voidsetFontSubFamilyName(java.lang.String subFamilyName)Sets the font's subfamily name.voidsetFontType(FontType fontType)Sets the font type.voidsetFullName(java.lang.String name)Sets the font's full name (usually the one that the operating system displays).voidsetItalicAngle(int italicAngle)Sets the font's italic angle.voidsetKerningEnabled(boolean enabled)Enables/disabled kerning.voidsetLastChar(int index)Sets the index of the last character in the character table.voidsetMissingWidth(int width)Sets the font's default widthvoidsetPanose(Panose panose)voidsetResolver(FontResolver resolver)Sets the font resolver.voidsetStemV(int stemV)Sets the font's StemV value.voidsetWeight(int weight)Sets the font weight.voidsetXHeight(int xHeight)Returns the XHeight value of the font.Methods inherited from class org.docx4j.fonts.fop.fonts.Typeface
getEncodingName, getMaxAscent, hadMappingOperations, hasChar, isMultiByte, mapChar, notifyMapOperation, setEventListener, toString, warnMissingGlyphMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.docx4j.fonts.fop.fonts.FontMetrics
getMaxAscent, getWidth, getWidths
-
Constructor Details
-
CustomFont
public CustomFont()
-
-
Method Details
-
isEmbeddable
public boolean isEmbeddable()Description copied from interface:FontDescriptorIndicates if this font may be embedded.- Specified by:
isEmbeddablein interfaceFontDescriptor- Returns:
- True, if embedding is possible/permitted
-
setEmbeddable
public void setEmbeddable(boolean isEmbeddable) -
getPanose
-
setPanose
-
getFontName
public java.lang.String getFontName()Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").- Specified by:
getFontNamein interfaceFontMetrics- Returns:
- the font name
-
getEmbedFontName
public java.lang.String getEmbedFontName()Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").- Specified by:
getEmbedFontNamein interfaceFontMetrics- Returns:
- the name for font embedding
-
getFullName
public java.lang.String getFullName()Returns the font's full name (Example: "Helvetica Bold Oblique").- Specified by:
getFullNamein interfaceFontMetrics- Returns:
- the font's full name
-
getFamilyNames
public java.util.Set getFamilyNames()Returns the font family names.- Specified by:
getFamilyNamesin interfaceFontMetrics- Returns:
- the font family names (a Set of Strings)
-
getStrippedFontName
public java.lang.String getStrippedFontName()Returns the font family name stripped of whitespace.- Returns:
- the stripped font family
- See Also:
FontUtil.stripWhiteSpace(String)
-
getFontSubName
public java.lang.String getFontSubName()Returns font's subfamily name.- Returns:
- the font's subfamily name
-
getEmbedFileName
public java.lang.String getEmbedFileName()Returns an URI representing an embeddable font file. The URI will often be a filename or an URL.- Returns:
- URI to an embeddable font file or null if not available.
-
getEmbedFileSource
public javax.xml.transform.Source getEmbedFileSource() throws java.io.IOExceptionReturns a Source representing an embeddable font file.- Returns:
- Source for an embeddable font file
- Throws:
java.io.IOException- if embedFileName is not null but Source is not found
-
getEmbedResourceName
public java.lang.String getEmbedResourceName()Returns the lookup name to an embeddable font file available as a resource. (todo) Remove this method, this should be done using a resource: URI.- Returns:
- the lookup name
-
getAscender
public int getAscender()Returns the ascender value of the font. (Ascent in pdf spec)- Specified by:
getAscenderin interfaceFontDescriptor- Returns:
- the ascender
-
getDescender
public int getDescender()Returns the descender value of the font. (Descent in pdf spec)- Specified by:
getDescenderin interfaceFontDescriptor- Returns:
- the descender value
-
getCapHeight
public int getCapHeight()Returns the capital height of the font.- Specified by:
getCapHeightin interfaceFontDescriptor- Returns:
- the capital height
-
getAscender
public int getAscender(int size)Returns the ascent of the font described by this FontMetrics object. It returns the nominal ascent within the em box.- Specified by:
getAscenderin interfaceFontMetrics- Parameters:
size- font size- Returns:
- ascent in milliponts
-
getDescender
public int getDescender(int size)Returns the descent of the font described by this FontMetrics object.- Specified by:
getDescenderin interfaceFontMetrics- Parameters:
size- font size- Returns:
- descent in milliponts
-
getCapHeight
public int getCapHeight(int size)Returns the size of a capital letter measured from the font's baseline.- Specified by:
getCapHeightin interfaceFontMetrics- Parameters:
size- font size- Returns:
- height of capital characters
-
getXHeight
public int getXHeight(int size)Determines the typical font height of this FontMetrics object- Specified by:
getXHeightin interfaceFontMetrics- Parameters:
size- font size- Returns:
- font height in millipoints
-
getFontBBox
public int[] getFontBBox()Returns the font's bounding box.- Specified by:
getFontBBoxin interfaceFontDescriptor- Returns:
- the bounding box
-
getFlags
public int getFlags()Returns the flags for the font. (See pdf spec)- Specified by:
getFlagsin interfaceFontDescriptor- Returns:
- the flags
-
isSymbolicFont
public boolean isSymbolicFont()Indicates whether the font is a symbolic font.- Specified by:
isSymbolicFontin interfaceFontDescriptor- Returns:
- true if the font is a symbolic font (i.e. Symbol or ZapfDingbats)
-
getWeight
public int getWeight()Returns the font weight (100, 200...800, 900). This value may be different from the one that was actually used to register the font.- Returns:
- the font weight (or 0 if the font weight is unknown)
-
getStemV
public int getStemV()Returns the vertical stem width for the font.- Specified by:
getStemVin interfaceFontDescriptor- Returns:
- the vertical stem width
-
getItalicAngle
public int getItalicAngle()Returns the italic angle for the font.- Specified by:
getItalicAnglein interfaceFontDescriptor- Returns:
- the italic angle
-
getMissingWidth
public int getMissingWidth()Returns the width to be used when no width is available.- Returns:
- a character width
-
getFontType
Returns the type of the font.- Specified by:
getFontTypein interfaceFontMetrics- Returns:
- the font type
-
getFirstChar
public int getFirstChar()Returns the index of the first character defined in this font.- Returns:
- the index of the first character
-
getLastChar
public int getLastChar()Returns the index of the last character defined in this font.- Returns:
- the index of the last character
-
isKerningEnabled
public boolean isKerningEnabled()Used to determine if kerning is enabled.- Returns:
- True if kerning is enabled.
-
hasKerningInfo
public final boolean hasKerningInfo()Indicates if the font has kering information.- Specified by:
hasKerningInfoin interfaceFontMetrics- Returns:
- True, if kerning is available.
-
getKerningInfo
public final java.util.Map getKerningInfo()Returns the kerning map for the font.- Specified by:
getKerningInfoin interfaceFontMetrics- Returns:
- the kerning map
-
setFontName
public void setFontName(java.lang.String name)Sets the "PostScript" font name (Example: "Helvetica-BoldOblique").- Specified by:
setFontNamein interfaceMutableFont- Parameters:
name- font name
-
setFullName
public void setFullName(java.lang.String name)Sets the font's full name (usually the one that the operating system displays). Example: "Helvetica Bold Oblique".- Specified by:
setFullNamein interfaceMutableFont- Parameters:
name- font' full name
-
setFamilyNames
public void setFamilyNames(java.util.Set names)Sets the font's family names (Example: "Helvetica").- Specified by:
setFamilyNamesin interfaceMutableFont- Parameters:
names- the font's family names (a Set of Strings)
-
setFontSubFamilyName
public void setFontSubFamilyName(java.lang.String subFamilyName)Sets the font's subfamily name.- Parameters:
subFamilyName- the subfamily name of the font
-
setEmbedFileName
public void setEmbedFileName(java.lang.String path)Sets the path to the embeddable font file.- Specified by:
setEmbedFileNamein interfaceMutableFont- Parameters:
path- URI to the file
-
setEmbedResourceName
public void setEmbedResourceName(java.lang.String name)Sets the resource name of the embeddable font file.- Specified by:
setEmbedResourceNamein interfaceMutableFont- Parameters:
name- resource name
-
setCapHeight
public void setCapHeight(int capHeight)Sets the capital height value.- Specified by:
setCapHeightin interfaceMutableFont- Parameters:
capHeight- capital height
-
setXHeight
public void setXHeight(int xHeight)Returns the XHeight value of the font.- Parameters:
xHeight- the XHeight value
-
setAscender
public void setAscender(int ascender)Sets the ascent value.- Specified by:
setAscenderin interfaceMutableFont- Parameters:
ascender- ascent height
-
setDescender
public void setDescender(int descender)Sets the descent value.- Specified by:
setDescenderin interfaceMutableFont- Parameters:
descender- descent value
-
setFontBBox
public void setFontBBox(int[] bbox)Sets the font's bounding box- Specified by:
setFontBBoxin interfaceMutableFont- Parameters:
bbox- bounding box
-
setFlags
public void setFlags(int flags)Sets the font's flags- Specified by:
setFlagsin interfaceMutableFont- Parameters:
flags- flags
-
setWeight
public void setWeight(int weight)Sets the font weight. Valid values are 100, 200...800, 900.- Parameters:
weight- the font weight
-
setStemV
public void setStemV(int stemV)Sets the font's StemV value.- Specified by:
setStemVin interfaceMutableFont- Parameters:
stemV- StemV
-
setItalicAngle
public void setItalicAngle(int italicAngle)Sets the font's italic angle.- Specified by:
setItalicAnglein interfaceMutableFont- Parameters:
italicAngle- italic angle
-
setMissingWidth
public void setMissingWidth(int width)Sets the font's default width- Specified by:
setMissingWidthin interfaceMutableFont- Parameters:
width- default width
-
setFontType
Sets the font type.- Specified by:
setFontTypein interfaceMutableFont- Parameters:
fontType- font type
-
setFirstChar
public void setFirstChar(int index)Sets the index of the first character in the character table.- Specified by:
setFirstCharin interfaceMutableFont- Parameters:
index- index of first character
-
setLastChar
public void setLastChar(int index)Sets the index of the last character in the character table.- Specified by:
setLastCharin interfaceMutableFont- Parameters:
index- index of the last character
-
setKerningEnabled
public void setKerningEnabled(boolean enabled)Enables/disabled kerning.- Specified by:
setKerningEnabledin interfaceMutableFont- Parameters:
enabled- True if kerning should be enabled if available
-
setResolver
Sets the font resolver. Needed for URI resolution.- Parameters:
resolver- the font resolver
-
putKerningEntry
public void putKerningEntry(java.lang.Integer key, java.util.Map value)Adds an entry to the kerning table.- Specified by:
putKerningEntryin interfaceMutableFont- Parameters:
key- Kerning keyvalue- Kerning value
-
replaceKerningMap
public void replaceKerningMap(java.util.Map kerningMap)Replaces the existing kerning map with a new one.- Parameters:
kerningMap- the kerning map (Map, the integers are character codes)
-