I'm trying to figure out a way to get multiple variants of a character in one single font file. Or, to put it another way: can I put multiple font families (or weights) in one OTF/TTF file?
My goal is to reduce the number of requests a site has to make in order to retrieve all the used fonts. I'd only need about 40 to 50 glyphs: the alphabet, the digits and the basic punctuation marks. I'm also willing to just use uppercase, so lowercase could be used for a different family.
This is specifically for web use.
To illustrate, I would like to apply one font familty to this container, and have each line show up in a different typeface:
HELLO, USER 123!
HELLO, USER 123!
HELLO, USER 123!
HELLO, USER 123!
I think it's not possible, but before I give up on this idea I wanted to check with you guys.
I thought about and experimented with the following ideas:
- Give each line one of the basic styles with CSS (normal, bold, italic, bolditalic) and instead of bold, italic or bolditalic glyphs, just use normal glyps of three other fonts. Can't be done because these have to be four separate font files.
- Modify the text so a different character inside the same font is used. Basically, the idea of uppercase and lowercase. This can easily be done in CSS and would work for A to Z, but not for numerals or puncutation. Also, it would be limited to two variants.
- Expand on that idea by somehow transforming everything to accented letters, so I'd have a, A, ä and Ä. I guess this only works for valid characters (a, but not m for instance). Also, this isn't triggerable from CSS, you can't say "text-transform: umlaut"
I've also brainstormed about a way to merge these files into one with other tricks. I.e. use the same binary container but somehow only use part of the data. Kinda like mulit-part MIME, but for binary. But I guess a stable, cross-browser way to do this is impossible.
The best solution I have now is to simply use four different font files, but BASE64-ing them and sticking them inside one CSS file. This actually works very well and caches nicely, the only disadvantage is the BASE64 overhead.
But if there's a solution on OTF/TTF-level, I'd be very interested!