Bug 18340

Summary: Include TTF_NAME table fields in fontconfig's cache
Product: fontconfig Reporter: Nicolas Spalinger <nicolas.spalinger>
Component: libraryAssignee: fontconfig-bugs
Status: RESOLVED MOVED QA Contact: Behdad Esfahbod <freedesktop>
Severity: normal    
Priority: medium CC: akira, freedesktop, mpsuzuki
Version: 2.6   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: A preliminary patch to cache more name entries in TTF

Description Nicolas Spalinger 2008-11-01 12:08:54 UTC
Please include in the fontconfig cache the information contained in the following fields of the NAME table to allow better exposure of the existing font metadata contained in both open and restricted fonts. 

These are standard fields already taken into account in Freetype:

in include/freetype/ttnameid.h

#define TT_NAME_ID_COPYRIGHT            0
#define TT_NAME_ID_FONT_FAMILY          1
#define TT_NAME_ID_FONT_SUBFAMILY       2
#define TT_NAME_ID_UNIQUE_ID            3
#define TT_NAME_ID_FULL_NAME            4
#define TT_NAME_ID_VERSION_STRING       5
#define TT_NAME_ID_PS_NAME              6
#define TT_NAME_ID_TRADEMARK            7
#define TT_NAME_ID_MANUFACTURER         8
#define TT_NAME_ID_DESIGNER             9
#define TT_NAME_ID_DESCRIPTION          10
#define TT_NAME_ID_VENDOR_URL           11
#define TT_NAME_ID_DESIGNER_URL         12
#define TT_NAME_ID_LICENSE              13
#define TT_NAME_ID_LICENSE_URL          14


Then the cache can be queried for this information: utilities like fc-list or fc-match can report on the licensing/author/foundry for each font in the cache by default or via a parameter. Dedicated commands like fc-license could also be created.
Comment 1 Behdad Esfahbod 2009-06-01 18:44:06 UTC
Nicolas, if you want to hack on this, I'm interested in reviewing a patch.  Here's the fields I think can be added:

#define TT_NAME_ID_COPYRIGHT            0 
#define TT_NAME_ID_VERSION_STRING       5 
#define TT_NAME_ID_TRADEMARK            7 
#define TT_NAME_ID_MANUFACTURER         8 
#define TT_NAME_ID_DESIGNER             9 
#define TT_NAME_ID_DESCRIPTION          10 
#define TT_NAME_ID_VENDOR_URL           11 
#define TT_NAME_ID_DESIGNER_URL         12 
#define TT_NAME_ID_LICENSE              13 
#define TT_NAME_ID_LICENSE_URL          14 
#define TT_NAME_ID_SAMPLE_TEXT          19 

For each, a language field is also desired.  For example, FC_COPYRIGHT and FC_COPYRIGHTLANG.

To add these, you need to modify fontconfig.h, fcname.c, and finally fcfreetype.c to collect them.  That should be all.
Comment 2 suzuki toshiya 2010-09-16 04:19:53 UTC
Although I'm not sure if Nicolas is still interested in,
I will try to write a patch for this feature.
Comment 3 Nicolas Spalinger 2010-09-16 04:36:04 UTC
Hi Susuki-san. 

I'm still interested but haven't found the time to move forward on this. This is also beyond my current programming abilities. Your help much appreciated. This will be incredibly useful. Thanks.
Comment 4 suzuki toshiya 2010-09-16 10:12:11 UTC
Created attachment 38746 [details] [review]
A preliminary patch to cache more name entries in TTF

Here is a preliminary patch to store more name entries into cache file.
Yet I've not written the tools like fc-license etc. BTW, some fonts have
long texts for license (e.g. Vera by Bitstream, including 2.3K byte text)
and increases the size of cache file. Some people may propose to
compress them.
Comment 5 suzuki toshiya 2010-09-23 10:43:57 UTC
Dear Nicolas,
Please find recent discussion in 29497:
https://bugs.freedesktop.org/show_bug.cgi?id=29497

Behdad thinks it is not good idea to use fontconfig
cache as a storage of arbitrary data copied from
font files - the cached data should be related with
a query method to lookup a font by using the data
as an attribute.

Thus, the long texts like license, sample text do not
fit to the criteria. For such data, fontconfig would be
used just as a storage, they don't help the font lookup.
Please describe what kind of features of fc-license
you expected, in detail. It can be a counter evidence
to show the advantage to cache license text.

I think it is NOT so unreasonable request to have a
storage of some selected metadata copied from the
font files, but it seems that fontconfig maintainer(s)
think fontconfig is not for such purpose.
Comment 6 Behdad Esfahbod 2010-09-23 10:54:23 UTC
Putting the long text fields in the cache enlarges the cache files considerably and unnecessarily.

We can add fontconfig API for looking up various name-table fields from an FT_Face, but don't have to put them in the cache.
Comment 7 Nicolas Spalinger 2010-10-04 09:39:33 UTC
(In reply to comment #6)
> Putting the long text fields in the cache enlarges the cache files considerably
> and unnecessarily.

OK, I understand that a lot a text is too much for the cache but I really think that we need at the very least TT_NAME_ID_COPYRIGHT, TT_NAME_ID_VENDOR_URL, TT_NAME_ID_DESIGNER_URL and TT_NAME_ID_LICENSE_URL which are short.

The general use case would be to allow for better classification of the fonts available to the system: who are the author(s) and the supporting foundry, under what terms the fonts can be used, etc by exposing the dedicated short text field and the URLs. 

> We can add fontconfig API for looking up various name-table fields from an
> FT_Face, but don't have to put them in the cache.

I agree that for the bigger name-table fields this makes sense. 

Thanks for the efforts towards this.
Comment 8 GitLab Migration User 2018-08-20 21:44:41 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/24.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.