Skip to content

Fonts

The LAY methods that work on the fonts are:

getFontsCount

The getFontsCount method returns the number of fonts detected in the document.

For example the instruction:

var fontsCount = LAY.getFontsCount();

sets a variable called fontsCount that, considering the Extract example output described in the dedicated page, is set to the value of 2.

    "fonts": [
        {
            "name": "Microsoft Sans Serif",
            "bold": false,
            "id": 0,
            "italic": false,
            "id_name": "BCDEEE+MicrosoftSansSerif",
            "ocr": false
        },
        {
            "name": "FranklinGothic Demi",
            "bold": false,
            "id": 1,
            "italic": false,
            "id_name": "BCDFEE+FranklinGothic-Demi",
            "ocr": false
        }
    ],

Info

The fonts of the same family but with different properties (for example Calibri 10 Italics and Calibri 10 bold) are considered as two different fonts in the count.

The syntax is:

LAY.getFontsCount()

getFont

The getFont method returns the font object with the given index, or undefined if the index is invalid.

For example the instruction:

var font = LAY.getFont(1);

returns the following object in the font variable given the Extract example output described in the dedicated page:

{
    "index": 1,
    "name": "FranklinGothic Demi",
    "id_name": "",
    "italic": false,
    "bold": false,
    "ocr": false
}

Where:

Field name Description Field type Default value
index The position of the font in the index of fonts Integer -1
name The name of the font String ""
id_name A more verbose name the uniquely identifies the font and its characteristics String ""
bold Whether the font is in bold or not Boolean false
italic Whether the font is in italic or not Boolean false
ocr Whether the font has been detected by the ocr or not Boolean false

Note

If a font is not detected is labeled in the "name" field as mix.

The syntax is:

LAY.getFonts(fontIndex)

where fontIndex is the font index.