[Fontconfig] How can I store FC_MATRIX object to cache file?

mpsuzuki at hiroshima-u.ac.jp mpsuzuki at hiroshima-u.ac.jp
Thu Sep 2 11:24:49 PDT 2010


How can I store FC_MATRIX object to cache file?


Now I'm trying to add some properties to fontconfig database,
which are taken from OS/2 and PCLT tables in OpenType: like
sFamilyClass (so-called IBM family classification), Panose etc.
They are useful to guess whether typeface is typographic/scriptic,
serif/sans-serif, proportional/fixed-pitch etc. My original
motivation is an improvement of the font substitution in poppler.
For detail, please find:


Panose in OpenType is a collection of 10 parameters, and
all parameters are expressed by 8bit. 80bit is too large
to pack into double integer, so I have to consider what is
the best way to store such in FcPattern. I think there are
3 options:

1) Name all parameters and store separately, aslike,
adding 10 types to FcObjectTypes: FC_OS2_PANOSE_0,
FC_OS2_PANOSE_1, ...

# The name of each byte is different from OpenType spec
# and its reference, so I don't use OpenType spec name

2) ASCII-fy 10 parameters to NULL-terminated string,
and use as a string type property.

3) Define new data type, a structure including 10 members
and add "FcTypePanose" to FcType.


About 1), it's easy for me to write such patch and for
users to use, but the addition of 10 objects may be too
much, because current variety of the object type is 41.

About 2), it's easy for me to write such patch but tricky
for users to use, because it is requred to decode from
ASCII string to original data.

About 3), it's easiest for users. So I have to consider
about this option.

Checking the source code of fontconfig, FcMatrix data
type looks similar (a structure with fixed length), but
it seems that the data typed FcMatrix cannot be stored
in cache file. I inserted FcMatrix object to FcPattern
and tried to save it in cache file, but it seems that
FcMatrix typed data cannot be saved (fc-cat can read
object type but cannot read value).

The code for FcString, FcCharSet and FcLangSet are
variable length data and have many works. So I want to
know how I can store FcMatrix typed data to cache file.


If option 1) or 2) are acceptable for fontconfig maintainers,
I will do so.

More information about the Fontconfig mailing list