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

Method encodeText

src/document/forms/form-font.ts:173–186  ·  view source on GitHub ↗

* Encode text to character codes for this font. * * For CID fonts: returns 2-byte Unicode code points (Identity-H/V encoding). * For simple fonts: uses the font's encoding (WinAnsi, custom, etc.).

(text: string)

Source from the content-addressed store, hash-verified

171 * For simple fonts: uses the font's encoding (WinAnsi, custom, etc.).
172 */
173 encodeText(text: string): number[] {
174 if (this.simpleFont) {
175 return this.simpleFont.encodeText(text);
176 }
177
178 // Simple ASCII encoding for Standard 14 fonts
179 const codes: number[] = [];
180
181 for (const char of text) {
182 codes.push(char.charCodeAt(0));
183 }
184
185 return codes;
186 }
187
188 /**
189 * Encode text as bytes for use in a PdfString.

Callers 2

encodeTextToBytesMethod · 0.95
form-font.test.tsFile · 0.45

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected