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

Chinese .ttf fonts failing with one of two errors #279

Open
dhowe opened this issue Apr 18, 2017 · 6 comments · May be fixed by #648
Open

Chinese .ttf fonts failing with one of two errors #279

dhowe opened this issue Apr 18, 2017 · 6 comments · May be fixed by #648
Assignees
Labels

Comments

@dhowe
Copy link

dhowe commented Apr 18, 2017

Uncaught Error: Only format 4 and 12 cmap tables are supported.
or
Uncaught TypeError: Cannot read property 'glyphIndexMap' of null

I suppose the first is an expected error.

Code here:

<html>
<head>
  <meta charset="UTF-8">
  <script src="lib/opentype.js"></script>
  <script>
  window.onload = function() {
    opentype.load('fonts/font.ttf', function(err, font) {
      if (err) {
        alert('Font could not be loaded: ' + err);
      } else {
        var ctx = document.getElementById('canvas').getContext('2d');
        var path = font.getPath('Hello, World!', 0, 100, 22);
        path.draw(ctx);
      }
    });
  }
  </script>
</head>
<body>
<canvas id="canvas" style="width: 600px"></canvas>
</body>
</html>

fonts.zip

@Jolg42 Jolg42 added the bug label Apr 18, 2017
@fdb
Copy link
Contributor

fdb commented Apr 25, 2017

Both errors have to do with unsupported cmap tables.

  • The DFBK1B.TTF font file has a supported cmap sub-table, but with an unsupported format 0.
  • The heiti.ttf font file only has a Unicode sub-table (PlatformID 0 EncodingId 3), which we do not support.

I'm not sure about supporting format 0 as used by DFBK1B.TTF, since it can only encode 255 characters and seems not to be used very often.

The Unicode platform is something we should support, as more fonts are using this, including some built-in fonts on OS X.

@dhowe
Copy link
Author

dhowe commented Apr 26, 2017

Indeed, unicode support would be great. We had significant difficulty getting any (of what we thought were) standard Chinese fonts on OS X to work with opentype

@fdb
Copy link
Contributor

fdb commented Apr 26, 2017

With the introduction of CID-keyed fonts, a lot more of them should now work, although some still miss the correct cmap parsing.

@weiyunpeng
Copy link

I have also encountered this situation. Is it resolved now?
1.TTF.zip

@antony-hk
Copy link
Contributor

I have also encountered this situation. Is it resolved now?
1.TTF.zip

This is a font without any Unicode cmap tables (platform ID 3 encoding ID 3). Seems the library will not support it at this moment, but I would like to try to make it work for this library.

@Connum Connum self-assigned this Nov 25, 2023
@Connum
Copy link
Contributor

Connum commented Nov 27, 2023

heiti.ttf and DFBK1B.TTF already work with the current master, 1.TTF will work as soon as #648 will be implemented

@Connum Connum linked a pull request Nov 27, 2023 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants