Class EmbeddedFontStyle

  • java.lang.Object
    • com.aspose.words.EmbeddedFontStyle
public class EmbeddedFontStyle 
extends java.lang.Object

Utility class containing constants. Specifies the style of an embedded font inside a FontInfo object.


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);

Field Summary
static final intREGULAR = 0
Specifies the Regular embedded font.
static final intBOLD = 1
Specifies the Bold embedded font.
static final intITALIC = 2
Specifies the Italic embedded font.
static final intBOLD_ITALIC = 3
Specifies the Bold-Italic embedded font.

    • Field Detail

      • REGULAR = 0

        public static final int REGULAR
        Specifies the Regular embedded font.
      • BOLD = 1

        public static final int BOLD
        Specifies the Bold embedded font.
      • ITALIC = 2

        public static final int ITALIC
        Specifies the Italic embedded font.
      • BOLD_ITALIC = 3

        public static final int BOLD_ITALIC
        Specifies the Bold-Italic embedded font.