EmbeddedFontStyle
Contents
[
Hide
]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
Field | Description |
---|---|
BOLD | Specifies the Bold embedded font. |
BOLD_ITALIC | Specifies the Bold-Italic embedded font. |
ITALIC | Specifies the Italic embedded font. |
REGULAR | Specifies the Regular embedded font. |
length |
Methods
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:
Parameter | Type | Description |
---|---|---|
embeddedFontStyleName | java.lang.String |
Returns: int
fromNames(Set embeddedFontStyleNames)
public static int fromNames(Set embeddedFontStyleNames)
Parameters:
Parameter | Type | Description |
---|---|---|
embeddedFontStyleNames | java.util.Set |
Returns: int
getName(int embeddedFontStyle)
public static String getName(int embeddedFontStyle)
Parameters:
Parameter | Type | Description |
---|---|---|
embeddedFontStyle | int |
Returns: java.lang.String
getNames(int embeddedFontStyle)
public static Set getNames(int embeddedFontStyle)
Parameters:
Parameter | Type | Description |
---|---|---|
embeddedFontStyle | int |
Returns: java.util.Set
getValues()
public static int[] getValues()
Returns: int[]
toString(int embeddedFontStyle)
public static String toString(int embeddedFontStyle)
Parameters:
Parameter | Type | Description |
---|---|---|
embeddedFontStyle | int |
Returns: java.lang.String
toStringSet(int attr)
public static String toStringSet(int attr)
Parameters:
Parameter | Type | Description |
---|---|---|
attr | int |
Returns: java.lang.String