[lltx] Font names database

Élie Roux elie.roux at telecom-bretagne.eu
Wed Jan 13 13:11:27 CET 2010


2010/1/12 Khaled Hosny <khaledhosny at eglug.org>:
>
> I'm working on a font names database generation script, it is capable of
> producing output similar to ConTeXt's 'simple' font names.

Hello,

I'm glad you're taking care of it, it will be a huge improvement in
LuaTeX's fontspec!

> The main problem now is which font names should we index, currently we
> simply take the 'fullname' as returned by fontloader, but things is isn't
> that simple! There is a hell of different font names stored in the font;
> fontname, fullname, familyname, and identical enteries in TTF names
> table, which in turn have different copies for mac and windows! And
> kindly enough, font designers have taken the liberty to have different
> names in each set. Take LM roman regular as an example:
>
> fullname: LMRoman10-Regular
> fontname: LMRoman10-Regular
> familyname: LMRoman10
> names.compatfull: LM Roman 10 Regular
> names.family: LM Roman 10
> names.preffamilyname: Latin Modern Roman
> names.prefmodifiers: 10 Regular
> fontstyle_name: Regular

I think we should make a first pass generating a table like

fonts.list = {
  {
    fullname = "LMRoman10-Regular",
    variant = "regular" -- we should normalize the value here
    size = 10             -- here too
    familyname = "Latin Modern Roman" -- the thing that will be
searched first, for compatibility with fc and thus XeTeX
    family = "LM Roman 10"
    path = "/path/to/the/file"
}

and then making a second pass that generates the table that will be
written in the file:

fonts = {
  familyname = "Latin Modern Roman",
  alias = "LM Roman 10"
    {
      size = 10,  -- can be 0 for any
        {
          variant = "regular",
          fullname = "LMRoman10-Regular"
          path = "/path/to/the/file"
        }
        {
          variant = "slanted",
          fullname = "LMRoman10-Slanted"
          path = "/path/to/the/file"
        }
     }
     {
       size = 12,
       {
          ...
       }
     ....
}

With this, a single font would fit in a family with this font only,
and we can do a very quick search on a requested name (only on the
fields familyname and alias, and then go in the subtree to be more
precise, etc.). Wdyt?

> Now which one should I pick? Any idea how Fontconfig and similar tools
> handle this? (since what they return is likely to be expected by users)

I tried fc-match when I planned to make a luafontspec, and frankly,
there must be something I didn't understand because it has always
seemed something at best strange, at worst totally crappy... for
example:

fc-match Latin
--> DejaVuSans.ttf

fc-match Latin\ Modern
--> DejaVuSans.ttf

fc-match Latin\ Modern\ Roman
--> lmroman17-regular.otf

But anyway, fontconfig could be used in the script, with fc-cat: it
outputs a set of entries like

"VenturisSansADFNo2Cd-Bold.otf" 0 "VenturisSans ADF No2
Cd:familylang=en:style=Bold:stylelang=en:fullname=VenturisSansADFNo2Cd-Bold,VenturisSans
ADF No2 Cd Bold:fullnamelang=en,en:slant=0:weight=200:width=75:foundry=unknown:index=0:outline=True:scalable=True:charset=
 |>^1!|>^1!P0oWQ |>]!]|>^1!|>^1!!!!%# !!71$!#>r7F3y?4!!K?&   !!!)$
 9;*f! !!#0GM>RAd#y#fx!!!!5  !!!W5  !!#3H !!!!&      !!#6I!!K?&
!!+u{!!!!F
:lang=aa|ast|ay|bi|br|ch|co|da|de|en|es|et|eu|fi|fj|fo|fr|fur|fy|gd|gl|gv|ho|ia|id|ie|io|is|it|lb|mg|nb|nds|nl|nn|no|nr|nso|oc|om|pt|rm|sma|smj|so|sq|ss|st|sv|sw|tl|tn|ts|uz|vo|vot|wa|xh|yap|zu|an|fil|ht|jv|kj|kwm|li|ms|ng|pap-an|pap-aw|rn|rw|sc|sg|sn|su|za:fo

As you can see it doesn't give the full file name with the directory
path, but with the option -v it gives it each time it changes
directory. I think this is clearly the best way to get all the system
fonts listed. Also you could easily detect if the fonts in TEXMF have
already been listed or not, and list them after accordingly. Wdyt?

If you can't use fontconfig on your system I can do this part.
fontconfig exists under cygwin if it helps, though it would need a
change from cygwin paths to Windows paths. (cygwin is always a mess
for programmers...)

Thank you,
-- 
Elie



More information about the lualatex-dev mailing list