Font

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.font.IFont, com.aspose.font.IGlyphAccessor, com.aspose.font.IFontSaver

public abstract class Font implements IFont, IGlyphAccessor, IFontSaver

Represents base Font class.

Methods

MethodDescription
open(FontDefinition fontDefinition)Opens a font, using FontDefinition object.
open(FontType fontType, StreamSource fontStreamSource)Opens a font, using font type and stream source.
open(FontType fontType, String fileName)Opens a font, using font type and font file name.
open(FontType fontType, byte[] fontData)Opens a font, using font type and font data byte array.
save(OutputStream stream)Saves the Font into original format.
save(String fileName)Saves the Font into original format.
saveToFormat(OutputStream stream, FontSavingFormats outFormat)Saves the Font into format specified.
convert(FontType fontType)Converts the Font into another format.
getGlyphsForText(String text)Gets glyphs representation for text.
getFontType()Gets Font type.
getStyle()Gets Font style.
setStyle(String value)Sets Font style.
getFontStyle()Gets Font style.
getFontFamily()Gets Font family.
setFontFamily(String value)Sets Font family.
getFontName()Gets Font face name.
setFontName(String value)Sets Font face name.
getFontNames()Gets Font names.
getPostscriptNames()Gets postscript font names.
getNumGlyphs()Gets number of glyphs in the Font.
getMetrics()Gets Font metrics.
getEncoding()Gets Font encoding.
getGlyphAccessor()Font glyph accessor.
getGlyphById(GlyphId id)Returns glyph by glyph Id.
getAllGlyphIds()Returns all glyph ids, available in the Font.
getGlyphIdType()Glyph id type specification.
getFontDefinition()Gets Font definition.
getFontSaver()Gets Font save functionality.

open(FontDefinition fontDefinition)

public static Font open(FontDefinition fontDefinition)

Opens a font, using FontDefinition object.

Parameters:

ParameterTypeDescription
fontDefinitionFontDefinitionFont definition object.

Returns: Font - Font loaded.

open(FontType fontType, StreamSource fontStreamSource)

public static Font open(FontType fontType, StreamSource fontStreamSource)

Opens a font, using font type and stream source.

Parameters:

ParameterTypeDescription
fontTypeFontTypeFont type.
fontStreamSourceStreamSourceStream source for font.

Returns: Font - Font loaded.

open(FontType fontType, String fileName)

public static Font open(FontType fontType, String fileName)

Opens a font, using font type and font file name.

Parameters:

ParameterTypeDescription
fontTypeFontTypeFont type.
fileNamejava.lang.StringFont file name.

Returns: Font - Font loaded.

open(FontType fontType, byte[] fontData)

public static Font open(FontType fontType, byte[] fontData)

Opens a font, using font type and font data byte array.

Parameters:

ParameterTypeDescription
fontTypeFontTypeFont type.
fontDatabyte[]Byte array to load font from.

Returns: Font - Font loaded.

save(OutputStream stream)

public void save(OutputStream stream)

Saves the Font into original format.


Note: following Font types are supported for saving:
 New TTF fonts;
 TTF Font subsets;
 CFF Font subsets;
 Type1 Font subsets.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamStream to save font.

save(String fileName)

public void save(String fileName)

Saves the Font into original format.


Note: following Font types are supported for saving:
 New TTF fonts;
 TTF Font subsets;
 CFF Font subsets;
 Type1 Font subsets.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringFile to save font.

saveToFormat(OutputStream stream, FontSavingFormats outFormat)

public void saveToFormat(OutputStream stream, FontSavingFormats outFormat)

Saves the Font into format specified.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamstream to save font
outFormatFontSavingFormatsdesired format

convert(FontType fontType)

public abstract Font convert(FontType fontType)

Converts the Font into another format.


Note: TTF Font type is now supported only.

fontType Font format type to convert into.

Parameters:

ParameterTypeDescription
fontTypeFontType

Returns: Font - Font converted into new format.

getGlyphsForText(String text)

public GlyphId[] getGlyphsForText(String text)

Gets glyphs representation for text.

Parameters:

ParameterTypeDescription
textjava.lang.StringInput text.

Returns: com.aspose.font.GlyphId[] - GlyphId array.

getFontType()

public abstract FontType getFontType()

Gets Font type.


Type1, TrueType etc.

Returns: FontType - Font type.

getStyle()

public abstract String getStyle()

Gets Font style. This is a raw string value provided by Font file.

Returns: java.lang.String - Font style.

setStyle(String value)

public abstract void setStyle(String value)

Sets Font style. This is a raw string value provided by Font file.

Parameters:

ParameterTypeDescription
valuejava.lang.StringNew Font style.

getFontStyle()

public abstract EnumSet<FontStyle> getFontStyle()

Gets Font style. This is a value computed and represented in generalized type.

Returns: java.util.EnumSet<com.aspose.font.FontStyle> - Font style. Usually, a combination of FontStyle class constant flag values or 0.

getFontFamily()

public abstract String getFontFamily()

Gets Font family.

Returns: java.lang.String - Font family.

setFontFamily(String value)

public abstract void setFontFamily(String value)

Sets Font family.

Parameters:

ParameterTypeDescription
valuejava.lang.StringNew Font family.

getFontName()

public abstract String getFontName()

Gets Font face name.

Returns: java.lang.String - Font face name.

setFontName(String value)

public abstract void setFontName(String value)

Sets Font face name.

Parameters:

ParameterTypeDescription
valuejava.lang.StringNew Font face name.

getFontNames()

public abstract MultiLanguageString getFontNames()

Gets Font names.

Returns: MultiLanguageString - Font names.

getPostscriptNames()

public abstract MultiLanguageString getPostscriptNames()

Gets postscript font names.

Returns: MultiLanguageString - Postscript font names.

getNumGlyphs()

public abstract int getNumGlyphs()

Gets number of glyphs in the Font.

Returns: int - Number of glyphs in the Font.

getMetrics()

public abstract IFontMetrics getMetrics()

Gets Font metrics.

Returns: IFontMetrics - Font metrics.

getEncoding()

public abstract IFontEncoding getEncoding()

Gets Font encoding.

Returns: IFontEncoding - Font encoding.

getGlyphAccessor()

public IGlyphAccessor getGlyphAccessor()

Font glyph accessor. Retrieves glyphs and glyph identifiers.

Returns: IGlyphAccessor - Font glyph accessor.

getGlyphById(GlyphId id)

public abstract Glyph getGlyphById(GlyphId id)

Returns glyph by glyph Id. Glyph id is a unique number for a glyph, which is font type dependent. GlyphId - derived object. for example: Type1’s id is a glyph name, instance of ( GlyphStringId ) class. TTF’s id is an int index, instance of ( GlyphInt32Id ) class.

Parameters:

ParameterTypeDescription
idGlyphIdGlyph id.

Returns: Glyph - Glyph.

getAllGlyphIds()

public abstract GlyphId[] getAllGlyphIds()

Returns all glyph ids, available in the Font. Glyph id is a unique number for a glyph, which is font type dependent. for example: Type1’s id is a glyph name, instance of ( GlyphStringId ) class. TTF’s id is an int index, instance of ( GlyphInt32Id ) class.

Returns: com.aspose.font.GlyphId[] - Glyph identifiers.

getGlyphIdType()

public abstract GlyphIdType getGlyphIdType()

Glyph id type specification. For consumers who needs to know the ‘bytes[]’ real type.

Returns: GlyphIdType - Id type specification

getFontDefinition()

public abstract FontDefinition getFontDefinition()

Gets Font definition.

Returns: FontDefinition - Font definition.

getFontSaver()

public IFontSaver getFontSaver()

Gets Font save functionality.

Returns: IFontSaver - Font save functionality.