Shoot, unfortunately, I tried again (both here and in a separate Incognito window, to avoid cache issues), and got the same result.
Posts made by arrowtype_2
-
RE: I can’t login via Twitter
-
RE: How can I loop through all glyphs of a TTF or OTF font?
@frederik said in How can I loop through all glyphs of a TTF or OTF font?:
pageSize = "A4"
Amazing, thanks so much for the tips, @frederik!
For anyone coming across this, there was a good discussion of this and of FontTools pens on Twitter:
https://twitter.com/typemytype/status/1352985048639799297
Also, I have cleaned up the several scripts in the GitHub repo. using Frederick’s & Just’s advice from both here & the Twitter thread. Have a look and remix as needed!
https://github.com/arrowtype/drawbot--loop-through-font-glyphs
-
RE: How can I loop through all glyphs of a TTF or OTF font?
@arrowtype_2 said in How can I loop through all glyphs of a TTF or OTF font?:
Okay, so I got a little further!
This now includes a script that will output all glyphs of a font to SVG:
https://github.com/arrowtype/drawbot--loop-through-font-glyphs
The main caveat right now is that I just copied from the docs to center & size glyphs to the full W/H of the canvas. So, relative sizing is lost. If I had to use this for real, I would figure out how to scale things in one way that could work for all glyphs ... probably, I would find the min/max Y values and widths (values that are pre-recorded in fonts, actually), and use these instead of min/max values per glyph.
-
RE: How can I loop through all glyphs of a TTF or OTF font?
Okay, so I’ve figured out the start of this. The core of it is this:
from fontTools.ttLib import TTFont fontPath = "source/RecursiveMonoCslSt-Med.ttf" newPage(1000,1000) txt = FormattedString() with TTFont(fontPath) as f: for key, value in f["cmap"].getBestCmap().items(): print(chr(key), end=" ") txt.append(chr(key) + " ") textBox(txt, (0, 0, 1000,1000))
Run from a script outside of the DrawBot app, the fuller script looks like this so far:
from fontTools.ttLib import TTFont from drawBot import * autoOpen = True fontPath = "source/RecursiveMonoCslSt-Med.ttf" W,H= 1000,1000 fontSize = W/40 newPage(W,H) txt = FormattedString() txt.font(fontPath) txt.fontSize(fontSize) txt.lineHeight(fontSize * 1.5) with TTFont(fontPath) as f: for key, value in f["cmap"].getBestCmap().items(): print(chr(key), end=" ") txt.append(chr(key) + " ") textBox(txt, (0, 0, W, H)) saveTo="test.pdf" saveImage(saveTo) if autoOpen: import os # os.system(f"open --background -a Preview {path}") os.system(f"open -a Preview {saveTo}")
But this still prints out a very basic/ugly thing, for now.
-
How can I loop through all glyphs of a TTF or OTF font?
A while ago, I made a simple script for RoboFont + DrawBot which would step through all glyphs of an open font in order to export these to SVG files (useful for an icon font, in that case).
However, it would be more convenient to run such a script outside of RoboFont, on a TTF/OTF font binary. Use cases for this general looping-through a font technique would probably include:
- exporting an icon font to SVGs & PNGs
- proofing every glyph in a font by printing it to a PDF
Is this possible in DrawBot alone? Or should I import FontTools, e.g. to loop through the CMAP table? I’ll look into this a little further, and update if I find a way.
Thanks for any tips!
-
I can’t login via Twitter
If I try to log in via Twitter, I get the following error:
I am fairly certain that my previous login was through Twitter, as I have also tried doing a standard "Forgot Password" flow, but didn’t get a reset email.
So, I made a new account to share this meta bug here.