EmbeddedFontStyle

Inheritance: java.lang.Object

public class EmbeddedFontStyle

Specifies the style of an embedded font inside a FontInfo object.

Examples:

Shows how to extract an embedded font from a document, and save it to the local file system.


 Document doc = new Document(getMyDir() + "Embedded font.docx");

 FontInfo embeddedFont = doc.getFontInfos().get("Alte DIN 1451 Mittelschrift");
 byte[] embeddedFontBytes = embeddedFont.getEmbeddedFont(EmbeddedFontFormat.OPEN_TYPE, EmbeddedFontStyle.REGULAR);
 FileUtils.writeByteArrayToFile(new File(getArtifactsDir() + "Alte DIN 1451 Mittelschrift.ttf"), embeddedFontBytes);

 // Embedded font formats may be different in other formats such as .doc.
 // We need to know the correct format before we can extract the font.
 doc = new Document(getMyDir() + "Embedded font.doc");

 Assert.assertNull(doc.getFontInfos().get("Alte DIN 1451 Mittelschrift").getEmbeddedFont(EmbeddedFontFormat.OPEN_TYPE, EmbeddedFontStyle.REGULAR));
 Assert.assertNotNull(doc.getFontInfos().get("Alte DIN 1451 Mittelschrift").getEmbeddedFont(EmbeddedFontFormat.EMBEDDED_OPEN_TYPE, EmbeddedFontStyle.REGULAR));

 // Also, we can convert embedded OpenType format, which comes from .doc documents, to OpenType.
 embeddedFontBytes = doc.getFontInfos().get("Alte DIN 1451 Mittelschrift").getEmbeddedFontAsOpenType(EmbeddedFontStyle.REGULAR);

 FileUtils.writeByteArrayToFile(new File(getArtifactsDir() + "Alte DIN 1451 Mittelschrift.otf"), embeddedFontBytes);
 

Fields

FieldDescription
BOLDSpecifies the Bold embedded font.
BOLD_ITALICSpecifies the Bold-Italic embedded font.
ITALICSpecifies the Italic embedded font.
REGULARSpecifies the Regular embedded font.
length

Methods

MethodDescription
fromName(String embeddedFontStyleName)
fromNames(Set embeddedFontStyleNames)
getName(int embeddedFontStyle)
getNames(int embeddedFontStyle)
getValues()
toString(int embeddedFontStyle)
toStringSet(int attr)

BOLD

public static int BOLD

Specifies the Bold embedded font.

BOLD_ITALIC

public static int BOLD_ITALIC

Specifies the Bold-Italic embedded font.

ITALIC

public static int ITALIC

Specifies the Italic embedded font.

REGULAR

public static int REGULAR

Specifies the Regular embedded font.

length

public static int length

fromName(String embeddedFontStyleName)

public static int fromName(String embeddedFontStyleName)

Parameters:

ParameterTypeDescription
embeddedFontStyleNamejava.lang.String

Returns: int

fromNames(Set embeddedFontStyleNames)

public static int fromNames(Set embeddedFontStyleNames)

Parameters:

ParameterTypeDescription
embeddedFontStyleNamesjava.util.Set

Returns: int

getName(int embeddedFontStyle)

public static String getName(int embeddedFontStyle)

Parameters:

ParameterTypeDescription
embeddedFontStyleint

Returns: java.lang.String

getNames(int embeddedFontStyle)

public static Set getNames(int embeddedFontStyle)

Parameters:

ParameterTypeDescription
embeddedFontStyleint

Returns: java.util.Set

getValues()

public static int[] getValues()

Returns: int[]

toString(int embeddedFontStyle)

public static String toString(int embeddedFontStyle)

Parameters:

ParameterTypeDescription
embeddedFontStyleint

Returns: java.lang.String

toStringSet(int attr)

public static String toStringSet(int attr)

Parameters:

ParameterTypeDescription
attrint

Returns: java.lang.String