MCPcopy Create free account
hub / github.com/LibPDF-js/core / CFFEncodingBase

Class CFFEncodingBase

src/fontbox/cff/encoding.ts:24–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 * Base class for CFF encodings.
23 */
24export class CFFEncodingBase implements CFFEncoding {
25 // code -> name mapping
26 protected readonly codeToName = new Map<number, string>();
27 // name -> code mapping
28 protected readonly nameToCode = new Map<string, number>();
29
30 /**
31 * Add a code/name mapping.
32 */
33 add(code: number, sid: number, name?: string): void {
34 const glyphName = name ?? getStandardString(sid) ?? `.sid${sid}`;
35 this.codeToName.set(code, glyphName);
36
37 if (!this.nameToCode.has(glyphName)) {
38 this.nameToCode.set(glyphName, code);
39 }
40 }
41
42 getName(code: number): string | undefined {
43 return this.codeToName.get(code);
44 }
45
46 getCode(name: string): number | undefined {
47 return this.nameToCode.get(name);
48 }
49}
50
51/**
52 * Standard Encoding (encoding ID 0).

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected