question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Distinction between hintmask bits and an operator in charstring

See original GitHub issue

While subsetting I got an error raised in op_or(), although this font has no or operators, of course.

$ pyftsubset font.otf --text=島 --no-hinting
Traceback (most recent call last):
  File "/Users/mnakamura/.pyenv/versions/subset-2.7.13/bin/pyftsubset", line 11, in <module>
    load_entry_point('fonttools', 'console_scripts', 'pyftsubset')()
  File "/Users/mnakamura/.ghq/github.com/fonttools/fonttools/Lib/fontTools/misc/loggingTools.py", line 372, in wrapper
    return func(*args, **kwds)
  File "/Users/mnakamura/.ghq/github.com/fonttools/fonttools/Lib/fontTools/subset/__init__.py", line 2971, in main
    subsetter.subset(font)
  File "/Users/mnakamura/.ghq/github.com/fonttools/fonttools/Lib/fontTools/subset/__init__.py", line 2785, in subset
    self._prune_post_subset(font)
  File "/Users/mnakamura/.ghq/github.com/fonttools/fonttools/Lib/fontTools/subset/__init__.py", line 2768, in _prune_post_subset
    retain = table.prune_post_subset(self.options)
  File "/Users/mnakamura/.ghq/github.com/fonttools/fonttools/Lib/fontTools/subset/__init__.py", line 2208, in prune_post_subset
    decompiler.execute(c)
  File "/Users/mnakamura/.ghq/github.com/fonttools/fonttools/Lib/fontTools/subset/__init__.py", line 2001, in execute
    psCharStrings.T2WidthExtractor.execute(self, charString)
  File "/Users/mnakamura/.ghq/github.com/fonttools/fonttools/Lib/fontTools/misc/psCharStrings.py", line 303, in execute
    rv = handler(index)
  File "/Users/mnakamura/.ghq/github.com/fonttools/fonttools/Lib/fontTools/misc/psCharStrings.py", line 375, in op_or
    raise NotImplementedError
NotImplementedError

This glyph has fifteen stems, and contains a sequence hintmask 0110111101110010 in its charstring. Since the mask bits 0110111101110010 (= 6f72 in hex) can be decoded as a string “or” in ASCII-compatible encodings, the sequence is stored as [..., 'hintmask', 'or', ...] in charString.program, and eventually it’s impossible to distinguish the bits from an or operator.

Workaround

Use Python 3.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
anthrotypecommented, Jul 20, 2017

I think I’ve fixed the issue in https://github.com/fonttools/fonttools/commit/c0d672ba70ba6907759b086d59f110496d79c606 Could you please check it works now? Also it would be nice if you could provide a minimal font the reproduces the issue so we can add to our regression tests (one glyph would be enough).

0reactions
anthrotypecommented, Jul 25, 2017

@mashabow Thank you! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

The CFF2 CharString Format (OpenType 1.8.3) - Microsoft Learn
Specifies the counter spaces to be controlled, and their relative priority. The mask bits in the bytes, following the operator, reference the ...
Read more >
The Type 2 Charstring Format - GitHub Pages
A Type 2 charstring program is a sequence of unsigned 8-bit bytes that encode numbers and operators. The byte value.
Read more >
fonttools/psCharStrings.py at main - GitHub
A library to manipulate font files from Python. Contribute to fonttools/fonttools development by creating an account on GitHub.
Read more >
Source code for fontTools.misc.psCharStrings - Read the Docs
"""psCharStrings.py -- module implementing various kinds of CharStrings: CFF dictionary ... index value = self.handle_operator(operator) return value, index.
Read more >
July 2015 - Project Zero
This talk discussed the exploitation process of a vulnerability found in the implementation of a BLEND Charstring instruction, discovered in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found