Skip to content

Commit

Permalink
Generate ToUnicodeMap bfrange in multiple ranges (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
orzFly committed Feb 24, 2024
1 parent 485b7e6 commit f4dd1a8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/font/embedded.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,15 @@ class EmbeddedFont extends PDFFont {
entries.push(`<${encoded.join(' ')}>`);
}

const chunkSize = 256;
const chunks = Math.ceil(entries.length / chunkSize);
const ranges = [];
for (let i = 0; i < chunks; i++) {
const start = i * chunkSize;
const end = Math.min((i + 1) * chunkSize, entries.length);
ranges.push(`<${toHex(start)}> <${toHex(end - 1)}> [${entries.slice(start, end).join(' ')}]`);
}

cmap.end(`\
/CIDInit /ProcSet findresource begin
12 dict begin
Expand All @@ -267,7 +276,7 @@ begincmap
<0000><ffff>
endcodespacerange
1 beginbfrange
<0000> <${toHex(entries.length - 1)}> [${entries.join(' ')}]
${ranges.join('\n')}
endbfrange
endcmap
CMapName currentdict /CMap defineresource pop
Expand Down

0 comments on commit f4dd1a8

Please sign in to comment.