Skip to content

@pdfa-lab/fontkit / TTFGlyph

Class: TTFGlyph ​

Defined in: src/glyph/true-type-glyph.ts:535

Alias for TrueTypeGlyph to be compatible with upstream fontkit.

Extends ​

Constructors ​

Constructor ​

new TTFGlyph(id, codePoints, font): TTFGlyph

Defined in: src/glyph/true-type-glyph.ts:121

Parameters ​

ParameterType
idnumber
codePointsreadonly number[]
fontTrueTypeSubsetFont

Returns ​

TTFGlyph

Inherited from ​

TrueTypeGlyph.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_metrics?protectedGlyphLayoutMetricsTrueTypeGlyph._metricssrc/glyph/glyph.ts:109
codePointsreadonlyreadonly number[]TrueTypeGlyph.codePointssrc/glyph/glyph.ts:104
components?publicComponent[]TrueTypeGlyph.componentssrc/glyph/true-type-glyph.ts:115
fontprotectedTrueTypeSubsetFontTrueTypeGlyph.fontsrc/glyph/true-type-glyph.ts:117
idreadonlynumberTrueTypeGlyph.idsrc/glyph/glyph.ts:103
instructions?publicnumber[]TrueTypeGlyph.instructionssrc/glyph/true-type-glyph.ts:113
isLigaturereadonlybooleanTrueTypeGlyph.isLigaturesrc/glyph/glyph.ts:107
isMarkreadonlybooleanTrueTypeGlyph.isMarksrc/glyph/glyph.ts:106
numberOfContourspublicnumberTrueTypeGlyph.numberOfContourssrc/glyph/true-type-glyph.ts:107
phantomPoints?publicPoint[]TrueTypeGlyph.phantomPointssrc/glyph/true-type-glyph.ts:114
points?publicPoint[]TrueTypeGlyph.pointssrc/glyph/true-type-glyph.ts:112
xMaxpublicnumberTrueTypeGlyph.xMaxsrc/glyph/true-type-glyph.ts:110
xMinpublicnumberTrueTypeGlyph.xMinsrc/glyph/true-type-glyph.ts:108
yMaxpublicnumberTrueTypeGlyph.yMaxsrc/glyph/true-type-glyph.ts:111
yMinpublicnumberTrueTypeGlyph.yMinsrc/glyph/true-type-glyph.ts:109

Accessors ​

advanceHeight ​

Get Signature ​

get advanceHeight(): number

Defined in: src/glyph/glyph.ts:294

The glyph's advance height.

Returns ​

number

Inherited from ​

TrueTypeGlyph.advanceHeight


advanceWidth ​

Get Signature ​

get advanceWidth(): number

Defined in: src/glyph/glyph.ts:283

The glyph's advance width.

Returns ​

number

Inherited from ​

TrueTypeGlyph.advanceWidth


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 ​

TrueTypeGlyph.bbox


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 ​

TrueTypeGlyph.cbox


name ​

Get Signature ​

get name(): string | null

Defined in: src/glyph/glyph.ts:352

The glyph's name.

Returns ​

string | null

Inherited from ​

TrueTypeGlyph.name


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 ​

TrueTypeGlyph.path

Methods ​

getBBox() ​

protected getBBox(): Readonly<BoundingBox>

Defined in: src/glyph/glyph.ts:150

Returns ​

Readonly<BoundingBox>

Inherited from ​

TrueTypeGlyph.getBBox


getCBox() ​

protected getCBox(internal): Readonly<BoundingBox>

Defined in: src/glyph/true-type-glyph.ts:133

Parameters ​

ParameterType
internalboolean

Returns ​

Readonly<BoundingBox>

Inherited from ​

TrueTypeGlyph.getCBox


getName() ​

protected getName(): string | null

Defined in: src/glyph/glyph.ts:302

Returns ​

string | null

Inherited from ​

TrueTypeGlyph.getName


getScaledPath() ​

getScaledPath(size): Path

Defined in: src/glyph/glyph.ts:275

Returns a path scaled to the given font size.

Parameters ​

ParameterType
sizenumber

Returns ​

Path

Inherited from ​

TrueTypeGlyph.getScaledPath


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 ​

ParameterTypeDescription
ctxFontkitCanvasthe FontkitCanvas
sizenumberthe font size in points

Returns ​

void

Inherited from ​

TrueTypeGlyph.render