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

Fix incorrect warning when converting to CFF a CFF2 variable font with non-varying glyphs #476

Merged
merged 3 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Tests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sys
import tempfile

__version__ = '0.4.0'
__version__ = '0.5.0'

logger = logging.getLogger('runner')

Expand Down Expand Up @@ -54,7 +54,7 @@ def run_tool(opts):
"""
input_dir = _get_input_dir_path(opts.tool)

args = []
args = [opts.tool]
for opt in opts.options:
if opt.startswith('='):
args.append('--{}'.format(opt[1:]))
Expand All @@ -65,8 +65,6 @@ def run_tool(opts):
else:
args.append('-{}'.format(opt))

args.insert(0, opts.tool)

if opts.files:
if opts.abs_paths:
files = opts.files
Expand All @@ -80,13 +78,18 @@ def run_tool(opts):
save_loc = _get_save_location(opts.save_path)
args.append(save_loc)

stderr = None
if opts.std_error:
stderr = subprocess.STDOUT

logger.debug(
"About to run the command below\n==>{}<==".format(' '.join(args)))
try:
if opts.no_save_path:
return subprocess.check_call(args, timeout=TIMEOUT)
else:
output = subprocess.check_output(args, timeout=TIMEOUT)
output = subprocess.check_output(args, stderr=stderr,
timeout=TIMEOUT)
if opts.redirect:
_write_file(save_loc, output)
return save_loc
Expand Down Expand Up @@ -197,6 +200,12 @@ def get_options(args):
action='store_true',
help="redirect the tool's output to a file"
)
parser.add_argument(
'-e',
'--std-error',
action='store_true',
help="capture stderr instead of stdout"
)
save_parser = parser.add_mutually_exclusive_group()
save_parser.add_argument(
'-s',
Expand Down
Empty file.
Binary file added Tests/tx_data/input/bug356.otf
Binary file not shown.
11 changes: 11 additions & 0 deletions Tests/tx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,14 @@ def test_many_hints_string_bug354():
dcf_txt_path = runner(CMD + ['-a', '-f', cff2_path, '-o', 'dcf'])
expected_path = _get_expected_path('cff2_vf.dcf.txt')
assert differ([expected_path, dcf_txt_path])


def test_non_varying_glyphs_bug356():
"""A glyph which is non-varying in a variable font may be referenced by a
VariationStore data item subtable which has a region count of 0. The VF
support code assumed that this was an error, and issued a false warning.
File 'bug356.otf' is a handcrafted modification of 'cff2_vf.otf'. The
latter cannot be used as-is to validate the fix."""
stderr_path = runner(CMD + ['-r', '-e', '-o', 'cff', '-f', 'bug356.otf'])
expected_path = _get_expected_path('bug356.txt')
assert differ([expected_path, stderr_path, '-l', '1'])
8 changes: 8 additions & 0 deletions afdko/Tools/Programs/public/lib/source/varread/varread.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,14 @@ static float var_applyDeltasForIndexPair(ctlSharedStmCallbacks *sscb, var_itemVa
}

subtable = &dataList->ivdSubtables.array[pair->outerIndex];

/* If specific glyphs do not have any variation, they may be
referenced by an ivdSubtable with a region count of 0. This is
valid.
*/
if (subtable->regionCount == 0)
return netAdjustment;

if (subtable->regionCount > regionListCount) {
sscb->message(sscb, "out of range region count in item variation store subtable");
return netAdjustment;
Expand Down