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

Decoding name records of TTF/TTC bundled with Mac #59

Closed
mashabow opened this issue Dec 1, 2016 · 2 comments
Closed

Decoding name records of TTF/TTC bundled with Mac #59

mashabow opened this issue Dec 1, 2016 · 2 comments

Comments

@mashabow
Copy link

mashabow commented Dec 1, 2016

I tried to get name records of a TTF/TTC bundled with Mac, and found that some values are decoded as buffers, instead of as strings. For example:

$ node
> const fontkit = require('fontkit')
undefined
> const font = fontkit.openSync('/Library/Fonts/BigCaslon.ttf')
undefined
> font.postscriptName
<Buffer 42 69 67 43 61 73 6c 6f 6e 2d 4d 65 64 69 75 6d>
> font.fullName
<Buffer 42 69 67 20 43 61 73 6c 6f 6e 20 4d 65 64 69 75 6d>
> font.familyName
<Buffer 42 69 67 20 43 61 73 6c 6f 6e>
> font.subfamilyName
'Medium'
> font.name
{ version: 0,
  count: 43,
  stringOffset: 522,
  records:
   { fontFeatures: { '0-1': [Object], English: [Object] },
     copyright: { English: <Buffer 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 31 39 39 34 20 43 61 72 74 65 72 20 26 20 43 6f 6e 65 20 54 79 70 65 2c 20 49 6e 63 2e 20 41 6c 6c 20 72 69 ... > },
     fontFamily: { English: <Buffer 42 69 67 20 43 61 73 6c 6f 6e> },
     fontSubfamily:
      { English: 'Medium',
        Chinese: '中等',
        Danish: 'Medium',
        German: 'Halbfett',
        Finnish: 'Normaali',
        French: 'Moyen',
        Italian: 'Medio',
        Japanese: 'ミディアム',
        Korean: '중간체',
        Dutch: 'Medium',
        'Norwegian (Bokmal)': 'Medium',
        Portuguese: 'Médio',
        Russian: 'Средний',
        Swedish: 'Normal',
        'Spanish (Modern Sort)': 'Media' },
     uniqueSubfamily: { English: <Buffer 42 69 67 20 43 61 73 6c 6f 6e 20 4d 65 64 69 75 6d 3b 20 31 30 2e 30 64 32 65 31 3b 20 32 30 31 34 2d 30 35 2d 33 30> },
     fullName: { English: <Buffer 42 69 67 20 43 61 73 6c 6f 6e 20 4d 65 64 69 75 6d> },
     version: { English: <Buffer 31 30 2e 30 64 32 65 31> },
     postscriptName: { English: <Buffer 42 69 67 43 61 73 6c 6f 6e 2d 4d 65 64 69 75 6d> },
     trademark: { English: <Buffer 22 42 69 67 20 43 61 73 6c 6f 6e 22 20 69 73 20 61 20 54 72 61 64 65 6d 61 72 6b 20 6f 66 20 43 61 72 74 65 72 20 26 20 43 6f 6e 65 20 54 79 70 65 2c ... > } } }
  • node 6.5.0
  • OS X 10.11.6
  • BigCaslon.ttf 10.0d2e1
@devongovett
Copy link
Member

This occurs when the strings are in an encoding that is not natively supported by Node. If you install iconv-lite alongside fontkit, the strings will be decoded properly. The dependency is optional because it is rather large, especially for browser usage.

@mashabow
Copy link
Author

mashabow commented Dec 2, 2016

Now I have installed iconv-lite and it works well. Thank you!

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