Resize glyphs in Fontlab using Python
rsdk
Posts: 5
I have Gujarati/ Devnagari Unicode fonts and adding some English glyphs/ diacritics, but need to resize the Uppercase letters to gujarati Pa's dimensions. Can anyone help me write a python script for this?
i'm using fontlab8
i'm using fontlab8
Tagged:
0
Comments
-
Why do you need a Python script for this? There are lots of ways you could resize glyphs within FontLab using basic scaling tools, or with Typerig tools.
If you do need something more complex, I recommend asking in the FontLab Forum.1 -
Just to clarify, both of the approaches mentioned by John above have ways to do such resizing on a selected range of glyphs in your font (or all glyphs, or just one glyph). My usual approach would be to:
- measure both glyphs
- calculate the % increase you need
- select the glyphs you want to scale
- and then in FontLab 6+ you would go to Tools > Actions > Basics >Scale and enter that % (be sure to get both horizontal and vertical scaling!)
3 -
I have to resize about 300 glyphs at once for about 20 fonts1
-
Same scaling factor for all, or different for each? Same source font for Latin characters for all of them?
If the same source font for all, this is on the edge for which makes more sense (scripting vs doing by hand). Perhaps more accurately, if one can easily script it oneself, one probably would, but the extra hassles and communication involved in hiring somebody might still not be worth it.
If you only need a kind of arbitrary subset of characters from the source Latin font, you might make a copy of it, use a color coding flag in the Font window to mark the ones you want, and then sort by flag. Either leave them that way or delete the rest.
As long as you know what the extra characters are, and there is only one source Latin font, this seems like about an hour’s work without scripting.
BUT if you have a bunch of different Latin source fonts, yes, I can totally see how this gets complicated. The non-scripting way might involve creating a custom .enc encoding file to help get me the same glyphs from each.1 -
Do you also need to scale kerning data for the Latin subsets? If so, it is best to do this in a separate, temporary source, using UPM adjustment to affect scaling to the whole glyph set, then copy the scaled glyphs and their kerning data into your main source. See more detailed description of this process in the FontLab Forum.
In terms of selecting the glyphs to be copied, and ensuring it is the same for each Latin subset, this script is helpful: it select glyphs by name according to an external text file list.
_____#FLM: Select Glyphs by Text File# Works with comma-separated lists and newline-separated lists
# forum.fontlab.com/fontlab-7/script-to-select-glyphs-from-list/import os
import sys
import FL as legacy
import fontlab as flfont = fl.CurrentFont()# Read the text file with the glyph names from the desktop to a stringglyph_list = open(os.path.expanduser('~')+"/Desktop/select.txt", "r").read()# In case of a comma-separated list, replace the comma by newline character,
# strip any space characters, and split the multi-line string at the newline
# character to get a list of glyph names. In case of a newline-separated
# list, no character replacements will be performed, and the multi-line
# string will be split at the newline characterglyph_data = glyph_list.replace(",", "\n").replace(" ", "").splitlines()# Legacy FL syntax is required to make selections in the font window,
# as described in TypeRig codelegacy.fl.Unselect()
foundGlyphs = []for name in glyph_data:
for glyph in font.glyphs:
if glyph.name == name:
foundGlyphs.append(glyph.name)if len(foundGlyphs):
for glyph in foundGlyphs:
legacy.fl.Select(glyph)1 -
[Moderators: is there anything that can be done to fix the code presentation in TypeDrawers?]1
Categories
- All Categories
- 43 Introductions
- 3.7K Typeface Design
- 803 Font Technology
- 1K Technique and Theory
- 622 Type Business
- 444 Type Design Critiques
- 542 Type Design Software
- 30 Punchcutting
- 136 Lettering and Calligraphy
- 83 Technique and Theory
- 53 Lettering Critiques
- 485 Typography
- 303 History of Typography
- 114 Education
- 68 Resources
- 499 Announcements
- 80 Events
- 105 Job Postings
- 148 Type Releases
- 165 Miscellaneous News
- 270 About TypeDrawers
- 53 TypeDrawers Announcements
- 116 Suggestions and Bug Reports