Zbynek R
Zbynek R

Reputation: 63

Individual glyph size manipulation for dynamically generated font

Is there any easy way for individual glyphs size manipulation in font? In other words I would like to dynamically generate font which has different size (or size appearance) for individual glyphs in font based on specified formula.

For example 'A' could look like 150% of its original size and 'B' could have 50% of its original size.

Generated font will be used on webpage. This would allow me to affect characters size even for the same font-size and without additional CSS styling of individual letters. (CSS styling individual letters would be performance/parser overkill for webpage with a lot of text.)

I am not sure whether this glyph size transformation is possible in some simple way or whether there would be needed to write individual glyph contours transformation formula for each affected glyph.

Writing contours transformation formula (based on individual glyph contours) for each glyph would be probably font dependent and not worth in my use case.

Font could be generated/manipulated once (JS/Java/Python library or approach preferred) and then font should be usable on webpage.

Do you have any idea, please? Thank you in advance.

Upvotes: 0

Views: 783

Answers (1)

Ben Whitmore
Ben Whitmore

Reputation: 967

I don't understand why you want to do this, and it sounds ugly, but here you go:

FontForge (a free tool) allows you to scale individual glyphs. You would open the file, select the glyph you want to scale, hit Ctrl-Backslash (or choose Element>Transformations>Transform from the menu). Origin should be "Glyph Origin"; choose "Scale" and set your scale percentage; leave the other two dropdowns to "Do Nothing". And check "Transform Width Too", if you can.

There seems to be a bug which means the "Transform Width Too" option is sometimes disabled. If so, you'll need to manually adjust the Advance width after you've done the transform (Metrics>Set Width>Scale Width By, and enter the same percentage value).

If you're running FontForge on linux, you can even do python scripting, if you want to do this programmatically. Because you say it's a one-off process, it's probably much easier to just do it manually as I've described.

From a designer's perspective, there are occasionally reasons for mixing text of different sizes together, but in these situations some thought needs to be given to making the stroke widths also work together. The large text should be lighter/thinner and the small text more bold. It's the same argument people make about using true small caps rather than just reducing the text size. Check out the FontForge feature Element>Style>Change Weight.

Upvotes: 1

Related Questions