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.

[varLib / ttLib] pen/GlyphSet API would be very handy for variable fonts

See original GitHub issue

I would love the TTFont().getGlyphSet() API to be extended with variable font support. This is how I imagine this to work:

f = TTFont("myvarfont.ttf")
gs = f.getGlyphSet()
gs.setLocation({'wght': 120, 'wdth': 300})
g = gs['a']
g.draw(somePen)
print(g.width)
print(g.height)

To do this properly, varLib will have to grow a cleaner API to work with coordinates and deltas.

I have attached a very rough and sketchy implementation that uses some hacked up bits from varLib.mutator. I think this shows which parts of varLib need to be redesigned for easier reuse.

ttVarGlyphSet.py.zip

See also #1020

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
behdadcommented, Jul 27, 2017

Sounds about right. I’ll give it a shot.

0reactions
behdadcommented, Aug 12, 2022

To do it on the fly is a great, but I wouldn’t want to burden the glyf module with it. Can the implementation be separate, near the TTGlyphSet code?

Okay I’ll see if that can be done. Good idea. It’s possible if we pass the location to getGlyphSet. I think that’s a fine idea. Then we can reuse your implementation.

Maybe factor out drawing to a pen from a list of coordinates + flags array, so it can be more reusable.

Sure that can be done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction to variable fonts on the web
In this article, we will look at what variable fonts are, the benefits they offer, and how we can use them in our...
Read more >
Variable fonts | Can I use... Support tables for HTML5, CSS3, etc
OpenType font settings that allows a single font file to behave like multiple fonts: it can contain all the allowed variations in width,...
Read more >
1 DesignSpaceDocument Python API - fontTools
An object to read, write and edit interpolation systems for typefaces. Define sources, axes, rules, variable fonts and instances. Get an overview of...
Read more >
[Variable Fonts] Check fonttools.varLib.mutator can generate a ...
This test is needed because the GF Team want to generate font instances from variable fonts. One of our variable test fonts, ...
Read more >
Introducing variable fonts – Fonts Knowledge - Google Fonts
Variable fonts —officially known as OpenType Font Variations—remove the ... is greatly reduced compared to loading multiple individual font files—and that's ...
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