Fonts
The LAY
methods that work on the fonts are:
LAY.getFontsCount()
Returns the number of fonts detected in the document.
For example the instruction:
var fontsCount = LAY.getFontsCount();
return the integer value 2 in the fontsCount
variable.
The two fonts detected are displayed in the original JSON as follows:
"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.
LAY.getFont(fontIndex)
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:
{
"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.