: How can I make a font monospaced? Suppose that I have a font in a modestly popular format (.ttf, .otf, etc.), and I have the legal rights to modify it. As it stands, it is a normal font
Suppose that I have a font in a modestly popular format (.ttf, .otf, etc.), and I have the legal rights to modify it. As it stands, it is a normal font with different charaters (glyphs?) varying in widths and spacings. How would I go about turning said font into a monospaced font (e.g. all characters are same dimensions, etc.)?
If possible, are there any automated tools that can do some of the guesswork for you? (The results don't have to be perfect.) The font may be large (many characters), and editing it could be tedious.
Any suggestions on the problem are much appreciated! :)
Disclaimer: Sorry if this is considered a simple howto, but Google has very little information on the subject, and for a programmer that doesn't deal with graphics or fonts much, it sure isn't simple. Also, sorry if my terminology is off... :P
More posts by @Carla748
4 Comments
Sorted by latest first Latest Oldest Best
In word processor, I: (1) created a table; (2) split into columns - one column for each letter; (3) centered the letters; and (4) rendered all borders, internal and external invisible.
I came across this very problem trying to edit source code making heavy use of Unicode symbols. In that context, most of the source code is displayed in one monospace font, and a few symbols that are not covered by that font end up ruining alignment.
Though it's true that "monospacifying" a full font will yield horrible results (kerning, stroke widths, and general balance will all be entirely messed up), importing just a few symbols from a variable-width font into a monospace one yields decent results. The animation below shows using Consolas + Symbola as a fallback, versus using Consolas + a monospacified version of Symbola:
This is useless for advanced typography, but it's a nice compromise if you want to use symbols in your source code without ruining indentation. There are a number of caveats though:
Wide characters will bleed a bit onto neighbouring spaces (though they can be slightly shrunk to mitigate the issue)
Kerning will be bad (not too much of a problem, as it's only a fallback)
I've launched a GitHub project to handle this kind of font transformations automatically. It includes pre-generated fonts, and code using fontforge's Python bindings.
See also this emacs.se question.
thomasrutter offers more of a technical answer; I'll show you some principles of typography to discourage you from doing what you want to do unless you really need to.
Zoom in on an 'i' and an 'm' in Consolas or Courier and then Corbel or Verdana. Notice how different the letters have to be in order to make monospace work. To properly convert a font to monospace takes a lot of knowledge and work. The general idea of stretching fonts at all is frowned upon by any designer worth their salt, that's why even going from normal to a condensed variant takes a redraw of all of the glyphs.
So, look at Consolas vs. Corbel here and see how, when it's zoomed in, you can look at 1) spacing between letters, 2) consistency of stroke thickness, and 3) how each letter fits into its box. Look at the monospaced face (first) compared to the variable spaced
face (second), then see the third and fourth to see what happens when you try to stretch and space to make it equal. For the fourth, I made the Ms squish to 75% to get in the box, but now they're much skinnier than the Is. that will be noticeable when it's used.
So, in short: don't mess with typefaces; they're a lot more formidable than you'd expect!
If you don't already have any font editing software, the good news is that Fontforge is free and open source. The bad news is that it has a relatively high learning curve and a somewhat unusual user interface.
Basically, for a font to be considered monospace, every glyph has to be the same width, right down to the exact same number of units. This includes even glyphs that should normally be zero width, or a certain width (such as em spaces, em dashes, etc).
See the FAQ entry "How do I mark a font as monospaced?"
To actually edit the width of all glyphs at once in a batch, you can just go to "Metrics" -> "Set Width" on the menu, but I wouldn't expect it to work for all characters. You'll probably have to manually edit all the wide characters such as 'W', 'M', '@', etc so they don't end up overlapping. And combining diacriticals (accents intended to be "combined" with letters at render-time) may have all their positions messed up (which is hard to test if you're American/English and you almost never use them).
A person who knows how to create and edit fonts would be able to do this task but it still wouldn't be straightforward.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.