[lltx] Font names database

Khaled Hosny khaledhosny at eglug.org
Fri Jan 15 13:58:19 CET 2010


On Wed, Jan 13, 2010 at 07:42:44PM +0200, Khaled Hosny wrote:
> On Wed, Jan 13, 2010 at 02:11:27PM +0200, Élie Roux wrote:
> > 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?
> 
> That is an interesting idea, I have a more or less similar idea, but I
> need to think more about it though.

I've no a more or less working implementation (it is a bit messy
though).

Now the database looks like:
{
  mappings = {
    families = {
      ["familyname"] = {
        ["regular]   = filename-regular.ttf
        ["bold"]     = filename-bold.ttf
        ...
      }
      ...
    }
    psnames = {
    ["psnameregular"] = filename-regular.ttf
    ["psnamebold"]    = filename-bold.ttf
    ...
    }
  }
}

The psnames table is used as fall-back if font is not found by family
name, and style auto-detection works using XeTeX-like syntax; font/B,
font/I etc. Family names, psnames and the style all case insensitive
(spaces, hyphens etc. are ignored too).

The font information are retrieved through a full fontloader.open()
call, and it is very memory consuming, this definitely needs to be
improved. The font style extraction code is a bit messy, because of a
FontForge "feature" that ignores font subfamily for certain font names
(it is a feature for a font editor as it forces some consistency, but
IMO a bug for a font loader), I'll try to see what can be done to improve
this.

Optical sizes not supported yet.

Check git logs for more details.

Regards,
 Khaled


-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer



More information about the lualatex-dev mailing list