Skip to content

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 ​

ts
protected new CustomFontEmbedder(
   font, 
   fontData, 
   customName?, 
   fontFeatures?): CustomFontEmbedder;

Defined in: src/core/embedders/CustomFontEmbedder.ts:68

Parameters ​

ParameterType
fontFont
fontDataUint8Array
customName?string
fontFeatures?TypeFeatures

Returns ​

CustomFontEmbedder

Properties ​

baseFontName ​

ts
protected baseFontName: string;

Defined in: src/core/embedders/CustomFontEmbedder.ts:65


customName ​

ts
readonly customName: string | undefined;

Defined in: src/core/embedders/CustomFontEmbedder.ts:62


font ​

ts
readonly font: Font;

Defined in: src/core/embedders/CustomFontEmbedder.ts:58


fontData ​

ts
readonly fontData: Uint8Array;

Defined in: src/core/embedders/CustomFontEmbedder.ts:60


fontFeatures ​

ts
readonly fontFeatures: TypeFeatures | undefined;

Defined in: src/core/embedders/CustomFontEmbedder.ts:63


fontName ​

ts
readonly fontName: string;

Defined in: src/core/embedders/CustomFontEmbedder.ts:61


glyphCache ​

ts
protected glyphCache: Cache<Glyph[]>;

Defined in: src/core/embedders/CustomFontEmbedder.ts:66


scale ​

ts
readonly scale: number;

Defined in: src/core/embedders/CustomFontEmbedder.ts:59

Methods ​

computeWidths() ​

ts
protected computeWidths(): (number | number[])[];

Defined in: src/core/embedders/CustomFontEmbedder.ts:259

Returns ​

(number | number[])[]


embedCIDFontDict() ​

ts
protected embedCIDFontDict(context): Promise<PDFRef>;

Defined in: src/core/embedders/CustomFontEmbedder.ts:185

Parameters ​

ParameterType
contextPDFContext

Returns ​

Promise&lt;PDFRef&gt;


embedFontDescriptor() ​

ts
protected embedFontDescriptor(context): Promise<PDFRef>;

Defined in: src/core/embedders/CustomFontEmbedder.ts:205

Parameters ​

ParameterType
contextPDFContext

Returns ​

Promise&lt;PDFRef&gt;


embedFontDict() ​

ts
protected embedFontDict(context, ref?): Promise<PDFRef>;

Defined in: src/core/embedders/CustomFontEmbedder.ts:157

Parameters ​

ParameterType
contextPDFContext
ref?PDFRef

Returns ​

Promise&lt;PDFRef&gt;


embedFontStream() ​

ts
protected embedFontStream(context): Promise<PDFRef>;

Defined in: src/core/embedders/CustomFontEmbedder.ts:237

Parameters ​

ParameterType
contextPDFContext

Returns ​

Promise&lt;PDFRef&gt;


embedIntoContext() ​

ts
embedIntoContext(context, ref?): Promise<PDFRef>;

Defined in: src/core/embedders/CustomFontEmbedder.ts:151

Parameters ​

ParameterType
contextPDFContext
ref?PDFRef

Returns ​

Promise&lt;PDFRef&gt;


embedUnicodeCmap() ​

ts
protected embedUnicodeCmap(context): PDFRef;

Defined in: src/core/embedders/CustomFontEmbedder.ts:244

Parameters ​

ParameterType
contextPDFContext

Returns ​

PDFRef


encodeText() ​

ts
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 ​

ParameterType
textstring

Returns ​

PDFHexString


for() ​

ts
static for(
   fontDataOrFontkit, 
   fontDataOrCustomName?, 
   customNameOrFeatures?, 
   fontFeaturesOrVariations?, 
fontVariations?): Promise<CustomFontEmbedder>;

Defined in: src/core/embedders/CustomFontEmbedder.ts:24

Parameters ​

ParameterType
fontDataOrFontkitunknown
fontDataOrCustomName?string | Uint8Array&lt;ArrayBufferLike&gt;
customNameOrFeatures?string | TypeFeatures
fontFeaturesOrVariations?TypeFeatures | FontVariations
fontVariations?FontVariations

Returns ​

Promise&lt;CustomFontEmbedder&gt;


glyphCountOfText() ​

ts
glyphCountOfText(text): number;

Defined in: src/core/embedders/CustomFontEmbedder.ts:115

Parameters ​

ParameterType
textstring

Returns ​

number


glyphId() ​

ts
protected glyphId(glyph?): number;

Defined in: src/core/embedders/CustomFontEmbedder.ts:250

Parameters ​

ParameterType
glyph?Glyph

Returns ​

number


heightOfFontAtSize() ​

ts
heightOfFontAtSize(size, options?): number;

Defined in: src/core/embedders/CustomFontEmbedder.ts:128

Parameters ​

ParameterType
sizenumber
options{ descender?: boolean; }
options.descender?boolean

Returns ​

number


isCFF() ​

ts
protected isCFF(): boolean;

Defined in: src/core/embedders/CustomFontEmbedder.ts:181

Returns ​

boolean


layout() ​

ts
protected layout(text): {
  glyphs: Glyph[];
  positions: GlyphPosition[];
};

Defined in: src/core/embedders/CustomFontEmbedder.ts:254

Parameters ​

ParameterType
textstring

Returns ​

ts
{
  glyphs: Glyph[];
  positions: GlyphPosition[];
}
glyphs ​
ts
glyphs: Glyph[];
positions ​
ts
positions: GlyphPosition[];

serializeFont() ​

ts
protected serializeFont(): Promise<Uint8Array<ArrayBufferLike>>;

Defined in: src/core/embedders/CustomFontEmbedder.ts:233

Returns ​

Promise&lt;Uint8Array&lt;ArrayBufferLike&gt;&gt;


sizeOfFontAtHeight() ​

ts
sizeOfFontAtHeight(height): number;

Defined in: src/core/embedders/CustomFontEmbedder.ts:144

Parameters ​

ParameterType
heightnumber

Returns ​

number


widthOfTextAtSize() ​

ts
widthOfTextAtSize(text, size): number;

Defined in: src/core/embedders/CustomFontEmbedder.ts:122

Parameters ​

ParameterType
textstring
sizenumber

Returns ​

number

MIT Licensed. A fork of pdf-lib.