Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIsplay glyfs #6

Closed
MinimaJack opened this issue Aug 1, 2014 · 12 comments
Closed

DIsplay glyfs #6

MinimaJack opened this issue Aug 1, 2014 · 12 comments

Comments

@MinimaJack
Copy link
Contributor

image
at the end have error with glyfs
"PЮocter&GambleW" - don't display correctly
only first 128 symbols embeded correctly from subsets...

@rkusa
Copy link
Owner

rkusa commented Aug 1, 2014

Thanks for reports! I am investigating both

@MinimaJack
Copy link
Contributor Author

only 160 symbols(160 =.128-32)
need some test code?

@rkusa
Copy link
Owner

rkusa commented Aug 1, 2014

Test code would be welcome, thanks!

@MinimaJack
Copy link
Contributor Author

var Document = require('pdfjs');
var fs = require('fs');

var doc;

fs.readFile('open-sans.regular.ttf', function(err, b) {
  if (err) throw err
  doc = new Document(new Document.Font(b));
  doc.text("абвгдеёжзийклмнопрстуфхцчшщъыьэюя АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ", {size: 12});
fs.writeFile(__dirname + '/test.pdf', doc.toString(), 'ascii')
})

when copy string from pdf file to another editor - all symbols visible.
ps code must be saved in utf-8

@rkusa
Copy link
Owner

rkusa commented Aug 1, 2014

This is a tricky one... It seems, that embedded font subsets cannot contain glyphs with a code > 127. That is, I've to split such a subset into two. This fix will required some time. A workaround would be, to add a font multiple times, e.g.

doc = new Document(new Document.Font(b));

doc.text("абвгдеёжзийклмнопрстуфхцчшщъыьэюя АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ", {size: 12})
doc.text("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ", {
  size: 12,
  font: new Document.Font(b)
})

@MinimaJack
Copy link
Contributor Author

generate in itext file with above chars...

/CIDInit /ProcSet findresource begin
12 dict begin
begincmap
/CIDSystemInfo
<< /Registry (TTX+0)
/Ordering (T42UV)
/Supplement 0
>> def
/CMapName /TTX+0 def
/CMapType 2 def
1 begincodespacerange
<0000><FFFF>
endcodespacerange
100 beginbfrange
<0003><0003><0020>
<0024><0024><0041>
<0025><0025><0042>
<0026><0026><0043> 
......................

Encoding/Identity-H

1 0 obj
<</DescendantFonts[8 0 R]/BaseFont/UTNGIR+OpenSans/Type/Font/Encoding/Identity-H/Subtype/Type0/ToUnicode 9 0 R>>
endobj 

result file:
https://yadi.sk/i/p3azUATEYr5WH

@rkusa
Copy link
Owner

rkusa commented Aug 2, 2014

They are using CID fonts. Seems to be another possible solution. Thanks for
the hint

rkusa added a commit that referenced this issue Aug 3, 2014
@rkusa
Copy link
Owner

rkusa commented Aug 3, 2014

Seems to work just fine! But I'll do some additional testing before releasing a new version to NPM.

@MinimaJack
Copy link
Contributor Author

Thanks! Displayed fine. But copy-past to another application broken...

@rkusa
Copy link
Owner

rkusa commented Aug 4, 2014

I knew I forgot something 😉 But this is easy to fix

rkusa added a commit that referenced this issue Aug 4, 2014
Refs #6
@MinimaJack
Copy link
Contributor Author

Thanks all work fine!

@rkusa
Copy link
Owner

rkusa commented Aug 4, 2014

Unfortunately, it broke the text align option justify. But I am on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants