happypdf / CustomFontEmbedder
Class: CustomFontEmbedder
Defined in: src/core/embedders/CustomFontEmbedder.ts:23
A note of thanks to the developers of https://github.com/foliojs/pdfkit, as this class borrows from: https://github.com/devongovett/pdfkit/blob/e71edab0dd4657b5a767804ba86c94c58d01fbca/lib/image/jpeg.coffee
Extended by
Constructors
Constructor
protected new CustomFontEmbedder(
font,
fontData,
customName?,
fontFeatures?): CustomFontEmbedder;Defined in: src/core/embedders/CustomFontEmbedder.ts:68
Parameters
| Parameter | Type |
|---|---|
font | Font |
fontData | Uint8Array |
customName? | string |
fontFeatures? | TypeFeatures |
Returns
CustomFontEmbedder
Properties
baseFontName
protected baseFontName: string;Defined in: src/core/embedders/CustomFontEmbedder.ts:65
customName
readonly customName: string | undefined;Defined in: src/core/embedders/CustomFontEmbedder.ts:62
font
readonly font: Font;Defined in: src/core/embedders/CustomFontEmbedder.ts:58
fontData
readonly fontData: Uint8Array;Defined in: src/core/embedders/CustomFontEmbedder.ts:60
fontFeatures
readonly fontFeatures: TypeFeatures | undefined;Defined in: src/core/embedders/CustomFontEmbedder.ts:63
fontName
readonly fontName: string;Defined in: src/core/embedders/CustomFontEmbedder.ts:61
glyphCache
protected glyphCache: Cache<Glyph[]>;Defined in: src/core/embedders/CustomFontEmbedder.ts:66
scale
readonly scale: number;Defined in: src/core/embedders/CustomFontEmbedder.ts:59
Methods
computeWidths()
protected computeWidths(): (number | number[])[];Defined in: src/core/embedders/CustomFontEmbedder.ts:259
Returns
(number | number[])[]
embedCIDFontDict()
protected embedCIDFontDict(context): Promise<PDFRef>;Defined in: src/core/embedders/CustomFontEmbedder.ts:185
Parameters
| Parameter | Type |
|---|---|
context | PDFContext |
Returns
Promise<PDFRef>
embedFontDescriptor()
protected embedFontDescriptor(context): Promise<PDFRef>;Defined in: src/core/embedders/CustomFontEmbedder.ts:205
Parameters
| Parameter | Type |
|---|---|
context | PDFContext |
Returns
Promise<PDFRef>
embedFontDict()
protected embedFontDict(context, ref?): Promise<PDFRef>;Defined in: src/core/embedders/CustomFontEmbedder.ts:157
Parameters
| Parameter | Type |
|---|---|
context | PDFContext |
ref? | PDFRef |
Returns
Promise<PDFRef>
embedFontStream()
protected embedFontStream(context): Promise<PDFRef>;Defined in: src/core/embedders/CustomFontEmbedder.ts:237
Parameters
| Parameter | Type |
|---|---|
context | PDFContext |
Returns
Promise<PDFRef>
embedIntoContext()
embedIntoContext(context, ref?): Promise<PDFRef>;Defined in: src/core/embedders/CustomFontEmbedder.ts:151
Parameters
| Parameter | Type |
|---|---|
context | PDFContext |
ref? | PDFRef |
Returns
Promise<PDFRef>
embedUnicodeCmap()
protected embedUnicodeCmap(context): PDFRef;Defined in: src/core/embedders/CustomFontEmbedder.ts:244
Parameters
| Parameter | Type |
|---|---|
context | PDFContext |
Returns
encodeText()
encodeText(text): PDFHexString;Defined in: src/core/embedders/CustomFontEmbedder.ts:89
Encode the JavaScript string into this font. (JavaScript encodes strings in Unicode, but embedded fonts use their own custom encodings)
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
for()
static for(
fontDataOrFontkit,
fontDataOrCustomName?,
customNameOrFeatures?,
fontFeaturesOrVariations?,
fontVariations?): Promise<CustomFontEmbedder>;Defined in: src/core/embedders/CustomFontEmbedder.ts:24
Parameters
| Parameter | Type |
|---|---|
fontDataOrFontkit | unknown |
fontDataOrCustomName? | string | Uint8Array<ArrayBufferLike> |
customNameOrFeatures? | string | TypeFeatures |
fontFeaturesOrVariations? | TypeFeatures | FontVariations |
fontVariations? | FontVariations |
Returns
Promise<CustomFontEmbedder>
glyphCountOfText()
glyphCountOfText(text): number;Defined in: src/core/embedders/CustomFontEmbedder.ts:115
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
number
glyphId()
protected glyphId(glyph?): number;Defined in: src/core/embedders/CustomFontEmbedder.ts:250
Parameters
| Parameter | Type |
|---|---|
glyph? | Glyph |
Returns
number
heightOfFontAtSize()
heightOfFontAtSize(size, options?): number;Defined in: src/core/embedders/CustomFontEmbedder.ts:128
Parameters
| Parameter | Type |
|---|---|
size | number |
options | { descender?: boolean; } |
options.descender? | boolean |
Returns
number
isCFF()
protected isCFF(): boolean;Defined in: src/core/embedders/CustomFontEmbedder.ts:181
Returns
boolean
layout()
protected layout(text): {
glyphs: Glyph[];
positions: GlyphPosition[];
};Defined in: src/core/embedders/CustomFontEmbedder.ts:254
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
{
glyphs: Glyph[];
positions: GlyphPosition[];
}glyphs
glyphs: Glyph[];positions
positions: GlyphPosition[];serializeFont()
protected serializeFont(): Promise<Uint8Array<ArrayBufferLike>>;Defined in: src/core/embedders/CustomFontEmbedder.ts:233
Returns
Promise<Uint8Array<ArrayBufferLike>>
sizeOfFontAtHeight()
sizeOfFontAtHeight(height): number;Defined in: src/core/embedders/CustomFontEmbedder.ts:144
Parameters
| Parameter | Type |
|---|---|
height | number |
Returns
number
widthOfTextAtSize()
widthOfTextAtSize(text, size): number;Defined in: src/core/embedders/CustomFontEmbedder.ts:122
Parameters
| Parameter | Type |
|---|---|
text | string |
size | number |
Returns
number