Replacing glyphs with Python in OTF

nycgraphist's picture

Hi everybody, I have a question. I know I can replace glyphs in the same OpenType font.

However, is it possible to replace glyphs in one OpenType font to glyphs from another OpenType font. Is there a python script available for that? Or is there some other way to achieve that? Thank you in advance.

oldnick's picture

There are several options available under Tools > Merge Fonts which may accomplish what you want to do...

nycgraphist's picture

Thanks, but that's not what I was asking about. I guess, I wasn't clear. I'm not talking about replacing glyphs via Fontlab.

I want to be able to replace specific glyphs in already generated OTF from a different OTF that are in the same folder for example. I know that if I apply a script I can change f f l to a ligature ffl in one particular font. But is it possible to control a font with a script from within a different font,.. being able to replace, let's say, a lowercase "g" from one font with another "g" from a different font? I hope this explains. Thanks.

Té Rowan's picture

In CSS, unicode-range will do it, as long as the UA (User Agent) supports it.

twardoch's picture

Nycgraphiste,

without a high-level font editor such as FontLab Studio, it can be quite tricky. Especially with OpenType PS (.otf) fonts which rely on the compression of the CFF table through subroutines.

It's possible, using the FontTools/TTX Python toolkit, but it requires quite a lot of low-level knowledge of the OpenType font format.

One solution might be to try compiling FontForge as a Python module (which unfortunately I haven't been able to do on a Linux server), and/or use the UFO/GLIF format to exchange the glyph data.

It's not trivial. But yes, it can be done.

nycgraphist's picture

Twardoch,

I meant doing it in Fontlab Studio. So how is it possible to do it via FS? Is it rather complicated or not to attach such a script to a font that would work on other fonts, because I'm not an advanced (or intermediate) scripter?

The issue here is that there is a specific OpenType font created for a particular brand. The concept is to use different fonts (in publication materials) alongside the custom font but some of the glyphs (characters in the brand name) will always be replaced with the corresponding glyphs from that custom font. Cheers.

Syndicate content Syndicate content