@@ -404,45 +404,50 @@ func (w *pdfWriter) writeFont(ref pdfRef, font *canvas.Font, vertical bool) {
404
404
length ++
405
405
} else {
406
406
if 1 < length {
407
- fmt .Fprintf (& bfRange , "<%04X> <%04X> <%04X>\n " , startGlyphID , startGlyphID + length - 1 , startUnicode )
407
+ fmt .Fprintf (& bfRange , "\n <%04X> <%04X> <%04X>" , startGlyphID , startGlyphID + length - 1 , startUnicode )
408
+ bfRangeCount ++
408
409
} else {
409
- fmt .Fprintf (& bfChar , "<%04X> <%04X>\n " , startGlyphID , startUnicode )
410
+ fmt .Fprintf (& bfChar , "\n <%04X> <%04X>" , startGlyphID , startUnicode )
411
+ bfCharCount ++
410
412
}
411
413
startGlyphID = uint16 (subsetGlyphID + 1 )
412
414
startUnicode = unicode
413
415
length = 1
414
416
}
415
417
}
416
418
if 1 < length {
417
- fmt .Fprintf (& bfRange , "<%04X> <%04X> <%04X>\n " , startGlyphID , startGlyphID + length - 1 , startUnicode )
419
+ fmt .Fprintf (& bfRange , "\n <%04X> <%04X> <%04X>" , startGlyphID , startGlyphID + length - 1 , startUnicode )
420
+ bfRangeCount ++
418
421
} else {
419
- fmt .Fprintf (& bfChar , "<%04X> <%04X>\n " , startGlyphID , startUnicode )
422
+ fmt .Fprintf (& bfChar , "\n <%04X> <%04X>" , startGlyphID , startUnicode )
423
+ bfCharCount ++
420
424
}
421
425
422
- toUnicode := fmt .Sprintf (`/CIDInit /ProcSet findresource begin
426
+ toUnicode := bytes.Buffer {}
427
+ fmt .Fprintf (& toUnicode , `/CIDInit /ProcSet findresource begin
423
428
12 dict begin
424
429
begincmap
425
- /CIDSystemInfo
426
- << /Registry (Adobe)
427
- /Ordering (UCS)
428
- /Supplement 0
429
- >> def
430
+ /CIDSystemInfo <</Registry(Adobe)/Ordering(UCS)/Supplement 0>> def
430
431
/CMapName /Adobe-Identity-UCS def
431
432
/CMapType 2 def
432
433
1 begincodespacerange
433
- <0000> <FFFF>
434
- endcodespacerange
435
- %d beginbfrange
436
- %sendbfrange
437
- %d beginbfchar
438
- %sendbfchar
434
+ <0000> <FFFF> endcodespacerange` )
435
+ if 0 < bfRangeCount {
436
+ fmt .Fprintf (& toUnicode , `
437
+ %d beginbfrange%s endbfrange` , bfRangeCount , bfRange .String ())
438
+ }
439
+ if 0 < bfCharCount {
440
+ fmt .Fprintf (& toUnicode , `
441
+ %d beginbfchar%s endbfchar` , bfCharCount , bfChar .String ())
442
+ }
443
+ fmt .Fprintf (& toUnicode , `
439
444
endcmap
440
445
CMapName currentdict /CMap defineresource pop
441
446
end
442
- end` , bfRangeCount , bfRange . String (), bfCharCount , bfChar . String () )
447
+ end` )
443
448
toUnicodeStream := pdfStream {
444
449
dict : pdfDict {},
445
- stream : [] byte ( toUnicode ),
450
+ stream : toUnicode . Bytes ( ),
446
451
}
447
452
if w .compress {
448
453
toUnicodeStream .dict ["Filter" ] = pdfFilterFlate
0 commit comments