cmap.unicode doesn't work for symbol fonts

Open
#7 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
ruby
Domain
tooling

Research direction

Start in lib/ttfunk/table/cmap/subtable.rb at the unicode? method and inspect how encoding_id is filtered. Reproduce with the Webdings.ttf example from the issue; done means cmap.unicode returns the symbol font's Unicode mapping instead of an empty list.

Written by the indexing model from the issue text.

Description

When getting the Unicode character map from the cmap table list, TTFunk only allows a value of 1 for "encoding_id" (which seems to equate to language code although I'm not sure).

According to Apple's spec for the cmap table the language code in Format 4 can be 0 for language independent fonts. This seems to be the case for Microsoft's symbol fonts (Webdings and Wingdings*).

So I think the unicode? method of subtable should allow encoding_id of 1 or 0. Currently symbol fonts' unicode character mapping can't be used. This is preventing me from outputting symbols to PDFs generated by Prawn, even though there's a Unicode mapping to the glyphs.

require 'ttfunk'
cmap = TTFunk::File.open("Webdings.ttf").cmap

cmap.tables[1].platform_id # => 3
cmap.tables[1].encoding_id # => 0
cmap.tables[1].format $ => 4
cmap.unicode # => []
Dominant language
Ruby
Stars
144
Forks
100
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from prawnpdf/ttfunk

All issues in prawnpdf/ttfunk

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.