* 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)
| 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. |
no test coverage detected