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.

[ttLib] scale-upem fails in many ways

See original GitHub issue

Trying to use ttLib.scaleUpem and not getting anything so far

Running on Source Serif VF from https://github.com/adobe-fonts/source-serif/blob/release/VAR/SourceSerif4Variable-Roman.ttf

fonttools ttLib.scaleUpem SourceSerif4Variable-Roman.ttf 4096 --output-file=scaledRoman.ttf

too much 'hmtx' table data
Writing scaledRoman.ttf
Traceback (most recent call last):
  File "/venv/test/bin/fonttools", line 8, in <module>
    sys.exit(main())
  File "/venv/test/lib/python3.10/site-packages/fontTools/__main__.py", line 30, in main
    runpy.run_module(mod, run_name='__main__')
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 227, in run_module
    return _run_code(code, {}, init_globals, run_name, mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/scaleUpem.py", line 336, in <module>
    sys.exit(main())
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/scaleUpem.py", line 330, in main
    font.save(output_file)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/ttFont.py", line 185, in save
    writer_reordersTables = self._save(tmp)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/ttFont.py", line 225, in _save
    self._writeTable(tag, writer, done, tableCache)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/ttFont.py", line 658, in _writeTable
    tabledata = self.getTableData(tag)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/ttFont.py", line 680, in getTableData
    return self.tables[tag].compile(self)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otBase.py", line 135, in compile
    self.table.compile(writer, font)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otBase.py", line 1006, in compile
    conv.write(writer, font, table, value)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otConverters.py", line 660, in write
    value.compile(subWriter, font)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otBase.py", line 970, in compile
    conv.writeArray(writer, font, table, value)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otConverters.py", line 201, in writeArray
    self.write(writer, font, tableDict, value, i)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otConverters.py", line 660, in write
    value.compile(subWriter, font)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otBase.py", line 970, in compile
    conv.writeArray(writer, font, table, value)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otConverters.py", line 201, in writeArray
    self.write(writer, font, tableDict, value, i)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otConverters.py", line 1715, in write
    writeSmallArray(values[n1:regionCount])
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otBase.py", line 674, in writeInt8Array
    self.writeArray('b', values)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/tables/otBase.py", line 666, in writeArray
    a = array.array(typecode, values)
OverflowError: ('signed char is less than minimum', 0, 'Item[]', 0, 'VarData[]', 'VarStore')

The OTF has the same except for the too much hmtx line.

Running on a totally different static OTF

Traceback (most recent call last):
  File "/venv/test/bin/fonttools", line 8, in <module>
    sys.exit(main())
  File "/venv/test/lib/python3.10/site-packages/fontTools/__main__.py", line 30, in main
    runpy.run_module(mod, run_name='__main__')
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 227, in run_module
    return _run_code(code, {}, init_globals, run_name, mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/scaleUpem.py", line 336, in <module>
    sys.exit(main())
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/scaleUpem.py", line 327, in main
    scale_upem(font, new_upem)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/scaleUpem.py", line 291, in scale_upem
    visitor.visit(font)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/ttVisitor.py", line 16, in visit
    super().visit(obj, *args, **kwargs)
  File "/venv/test/lib/python3.10/site-packages/fontTools/misc/visitor.py", line 133, in visit
    ret = visitorFunc(self, obj, *args, **kwargs)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/ttVisitor.py", line 30, in visit
    visitor.visit(font[tag], *args, **kwargs)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/ttVisitor.py", line 16, in visit
    super().visit(obj, *args, **kwargs)
  File "/venv/test/lib/python3.10/site-packages/fontTools/misc/visitor.py", line 137, in visit
    self.visitObject(obj, *args, **kwargs)
  File "/venv/test/lib/python3.10/site-packages/fontTools/misc/visitor.py", line 91, in visitObject
    ret = visitorFunc(self, obj, key, value, *args, **kwargs)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/scaleUpem.py", line 179, in visit
    _cff_scale(visitor, args)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/scaleUpem.py", line 152, in _cff_scale
    args[i] = visitor.scale(arg)
  File "/venv/test/lib/python3.10/site-packages/fontTools/ttLib/scaleUpem.py", line 24, in scale
    return otRound(v * self.scaleFactor)
TypeError: can't multiply sequence by non-int of type 'float'

It seems to work on some fonts, but not most of what I’m trying.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
behdadcommented, Oct 4, 2022

Closing this. Please open new issue for the remaining failures with reproducer fonts.

0reactions
anthrotypecommented, Oct 4, 2022

Thanks Behdad

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Unable to locate build via Github Actions API" after switching ...
After receiving an email about the pending deprecation of the bash uploader, I decided to start migrating my repos to use the v2...
Read more >
fonttools · PyPI
fontTools is a library for manipulating fonts, written in Python. The project includes the TTX tool, that can convert TrueType and OpenType fonts...
Read more >
Virtual - pkgsrc.se | The NetBSD package collection
Base color glyphs of same name in different masters must have identical paint graph structure (incl. number of layers, palette indices, number of...
Read more >
https://ftp.sjtu.edu.cn/opensuse/factory/iso/Chang...
ttLib.ttVisitor. Added fontTools.ttLib.scaleUpem module that uses the latter to change a font's units-per-em and scale all the related fields accordingly ...
Read more >
Python fonttools: Check if font supports multi codepoint emoji
I'm trying to check if a font has a glyph for a multi codepoint emoji like " ‍♂️", " ...
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