@pdfa-lab/fontkit / CFFGlyph
Class: CFFGlyph ​
Defined in: src/glyph/cff-glyph.ts:9
Represents an OpenType PostScript glyph, in the Compact Font Format.
Extends ​
Constructors ​
Constructor ​
new CFFGlyph(
id,codePoints,font):CFFGlyph
Defined in: src/glyph/cff-glyph.ts:16
Parameters ​
| Parameter | Type |
|---|---|
id | number |
codePoints | readonly number[] |
font | OpenTypePostScriptFont |
Returns ​
CFFGlyph
Overrides ​
Properties ​
| Property | Modifier | Type | Default value | Overrides | Inherited from | Defined in |
|---|---|---|---|---|---|---|
_metrics? | protected | GlyphLayoutMetrics | undefined | - | Glyph._metrics | src/glyph/glyph.ts:109 |
codePoints | readonly | readonly number[] | undefined | - | Glyph.codePoints | src/glyph/glyph.ts:104 |
font | protected | OpenTypePostScriptFont | undefined | Glyph.font | - | src/glyph/cff-glyph.ts:13 |
id | readonly | number | undefined | - | Glyph.id | src/glyph/glyph.ts:103 |
isLigature | readonly | boolean | undefined | - | Glyph.isLigature | src/glyph/glyph.ts:107 |
isMark | readonly | boolean | undefined | - | Glyph.isMark | src/glyph/glyph.ts:106 |
usedGsubrs | public | Record<number, boolean> | {} | - | - | src/glyph/cff-glyph.ts:10 |
usedSubrs | public | Record<number, boolean> | {} | - | - | src/glyph/cff-glyph.ts:11 |
Accessors ​
advanceHeight ​
Get Signature ​
get advanceHeight():
number
Defined in: src/glyph/glyph.ts:294
The glyph's advance height.
Returns ​
number
Inherited from ​
advanceWidth ​
Get Signature ​
get advanceWidth():
number
Defined in: src/glyph/glyph.ts:283
The glyph's advance width.
Returns ​
number
Inherited from ​
bbox ​
Get Signature ​
get bbox():
Readonly<BoundingBox>
Defined in: src/glyph/glyph.ts:250
The glyph’s bounding box, i.e. the rectangle that encloses the glyph outline as tightly as possible.
Returns ​
Readonly<BoundingBox>
Inherited from ​
cbox ​
Get Signature ​
get cbox():
Readonly<BoundingBox>
Defined in: src/glyph/glyph.ts:238
The glyph’s control box. This is often the same as the bounding box, but is faster to compute. Because of the way bezier curves are defined, some of the control points can be outside of the bounding box. Where bbox takes this into account, cbox does not. Thus, cbox is less accurate, but faster to compute. See here for a more detailed description.
Returns ​
Readonly<BoundingBox>
Inherited from ​
name ​
Get Signature ​
get name():
string|null
Defined in: src/glyph/glyph.ts:352
The glyph's name.
Returns ​
string | null
Inherited from ​
path ​
Get Signature ​
get path():
Readonly<Path>
Defined in: src/glyph/glyph.ts:262
A vector Path object representing the glyph outline.
Returns ​
Readonly<Path>
Inherited from ​
Methods ​
getBBox() ​
protectedgetBBox():Readonly<BoundingBox>
Defined in: src/glyph/glyph.ts:150
Returns ​
Readonly<BoundingBox>
Inherited from ​
getCBox() ​
protectedgetCBox(_?):Readonly<BoundingBox>
Defined in: src/glyph/glyph.ts:146
Parameters ​
| Parameter | Type |
|---|---|
_? | boolean |
Returns ​
Readonly<BoundingBox>
Inherited from ​
getName() ​
protectedgetName():string|null
Defined in: src/glyph/cff-glyph.ts:24
Returns ​
string | null
Overrides ​
getScaledPath() ​
getScaledPath(
size):Path
Defined in: src/glyph/glyph.ts:275
Returns a path scaled to the given font size.
Parameters ​
| Parameter | Type |
|---|---|
size | number |
Returns ​
Inherited from ​
render() ​
render(
ctx,size):void
Defined in: src/glyph/glyph.ts:377
Renders the glyph to the given graphics context, at the specified font size.
The rendering context ctx should actually be an instance of pdfkit. However, for regular glyphs, you can also pass an HTML5 CanvasRenderingContext2D or one of the implementations for Node.js, like canvas, although you have to cast this, when using TypeScript.
Unfortunately, this will crash, for colour glyphs, see https://github.com/gflohr/pdfa-lab/issues/105.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
ctx | FontkitCanvas | the FontkitCanvas |
size | number | the font size in points |
Returns ​
void