[Matroska-devel] font matching algorithm needed

Liisachan Liisachan at faireal.net
Mon Jul 28 02:44:23 CEST 2003

In SSA, you _must_ specify a font-name in the header:

[V4 Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, 
TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, 
Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
Style: style1,Verdana,28,...

OR you _can_ specify a fontname with a \fn tag:

Dialogue: Marked=0,0:00:10.25,0:00:12.83,style1,,0000,0000,0000,,Let's 
change the font {\fnTimes New Roman}temporarily.

The problem is, today's subtitle renders is trying to use the font 
speficied, even if the system does not have it.
I got this feeback about our 15-language soft-ssa sample clip:

"too bad my mplayer fontconfig code doesn't check if the glyphs are 
 so half of the subs (especially russian or polish) miss all characters"

This can happen on Windows too.
I myself found this problem when we were handling Tatar.
So  I'd like the coders to think about this:

1. Like mozilla can handle CSS like "font-family: Verdana" even tho the 
system doesnt have Verdana,
a subtitle renderer may look for ANY available glyphs for that code 
point in the system,
if the specified font is not installed (Verdana, and Times New Roman in 
the above examples)
Anything is really better than nothing

2.  TTF embedding is not only for fancy layout. It is softa "must" to 
sub in a "minor" language which uses
special glyphs (like Divehi)--otherwise, Matroska with subs couldn't be 
For instance, ArialTat.ttf is only 63KB in size. If you can embed this 
small file and "call" it from the SSA in MKV,
any system can replay Tatar subs, which is really cool. This is 
obviously better than picture-sub,
because this way you can handle font more flexibly, like changing 
fontsize font-color etc.

3. The mechanism 1 and 2 are critically important in order to make MKV 
On windows, probably eveyone has "Verdana" and "Times New Roman"
but it d be wonderful if you can play the same Matroska file on many OS's,
including Mac, Linux, FreeBSD etc etc, seamlessly.

 You can't assume "Verdana" is universally available on any systems.
But the subtitle renderer on that OS can--and should--try to find 
available glyphs in that system.
This is possible, because UTF-8 will give you a code point, not a glyph.

4. As a side note, while SSA is somehow windows-centric from its origin,
USF is more sophisticated, where you can specify a generic font like this:

family="Times, 'Times New Roman', serif"

Probably USF is the way to go.

Our sample clip with 15 languages is available here,
and you can test it by yourself:




More information about the Matroska-devel mailing list