#17 XeTeX 0.996 cannot find fonts by alternate name

v1.0_(example)
closed
Jonathan Kew
5
2008-08-09
2008-08-02
Vasile Gaburici
No

This was tested with fontconfig 2.5.0 (Fedora 9):

$ fc-list "DejaVu Sans":style=ExtraLight
DejaVu Sans,DejaVu Sans Light:style=ExtraLight
$ fc-list "DejaVu Sans Light"
DejaVu Sans,DejaVu Sans Light:style=ExtraLight

Fontconfig reports both the legacy and the preferred family names (see https://bugs.freedesktop.org/show_bug.cgi?id=7673 for details), and you can select by either, but XeTeX seems to form its font name by taking only the first (name, style) in each list:

\font\x="DejaVu Sans ExtraLight" at 64pt
\x Hello XeTeX!
\font\y="DejaVu Sans Light" at 64pt %does not work
\y Hello XeTeX!
\bye

Discussion

  • Jonathan Kew
    Jonathan Kew
    2008-08-05

    Logged In: YES
    user_id=700925
    Originator: NO

    Please check whether the problem still exists with xetex 0.999 (from subversion source, or from TeX Live 2008 pre-release).

     
  • Logged In: YES
    user_id=2153078
    Originator: YES

    I compiled revison 803 from svn, and used it with TeXLive 2007. The bug is still there.

    # xetex --version
    XeTeX 3.1415926-2.2-0.999.4 (Web2C 7.5.6)
    kpathsea version 3.5.6dev
    Copyright 2008 SIL International.
    Kpathsea is copyright 2008 Karl Berry and Olaf Weber.
    There is NO warranty. Redistribution of this software is
    covered by the terms of both the XeTeX copyright and
    the Lesser GNU General Public License.
    For more information about these matters, see the file
    named COPYING and the XeTeX source.
    Primary author of XeTeX: Jonathan Kew.
    Kpathsea written by Karl Berry, Olaf Weber, and others.

    Compiled with ICU version 4.0 [with modifications for XeTeX]
    Compiled with zlib version 1.2.3; using 1.2.3
    Compiled with FreeType2 version 2.3.7; using 2.3.7
    Compiled with fontconfig version 2.5.0; using 2.5.0
    Compiled with libpng version 1.2.15; using 1.2.15
    Compiled with xpdf version 3.01

    # fc-list "DejaVu Sans Light"
    DejaVu Sans,DejaVu Sans Light:style=ExtraLight

    ]# xetex fontname.tex
    This is XeTeXk, Version 3.1415926-2.2-0.999.4 (Web2C 7.5.6)
    %&-line parsing enabled.
    entering extended mode
    (./fontname.texkpathsea: Illegal fontname `DejaVu Sans Light': contains ' '

    ! Font \y="DejaVu Sans Light" at 64.0pt not loadable: Metric (TFM) file or inst
    alled font not found.
    l.3 \font\y="DejaVu Sans Light" at 64pt
    %does not work
    ?

    Btw, you should probably upgrade xpdf since it's been hit by a bunch of CVEs. I'm not sure if the way you use it exposes the user to those vulnerabilities or not.

     
  • Jonathan Kew
    Jonathan Kew
    2008-08-08

    Logged In: YES
    user_id=700925
    Originator: NO

    Currently, this behavior is by design: if a font has the OpenType "preferred family" and "preferred subfamily" names, XeTeX uses these *in place of* the legacy "family" and "style" names. I realize this is different from the current fontconfig behavior, which falls back on the legacy names if it fails to match the preferred name, but I am reluctant to change it because I suspect it may increase the potential for ambiguities.

    Note that XeTeX is doing a somewhat different job to fontconfig, when presented with a font name. XeTeX is supposed to find *the exact font* that was requested (and give an error if it can't be found), whereas fontconfig is supposed to find *the best available match*, so that it will always return something usable rather than give up.

    Simply allowing XeTeX to use either the "preferred" and "legacy" names interchangeably would be an easy change, but leads to problems. Imagine a family with four weights: Light, Regular, Semibold, Bold. A fairly typical organization of this family might be:

    Full Name Legacy Family Legacy Style Preferred Family Preferred Style
    --------------------------------------------------------------------------------------
    MyFont Light MyFont Light Regular MyFont Light
    MyFont Regular MyFont Regular MyFont Regular
    MyFont Semibold MyFont Light Bold MyFont Semibold
    MyFont Bold MyFont Bold MyFont Bold

    If a XeTeX user requests "MyFont-Bold", XeTeX will look for a font in family "MyFont" (which includes all 4 of these), and style name "Bold", which (if the legacy names are used) includes two of them. Avoiding this ambiguity would require a more complex structure for keeping track of the various names when the font information is cached, and I'm not convinced it is worthwhile in this context. I think using the "preferred" names exclusively is preferable.

     
  • Logged In: YES
    user_id=2153078
    Originator: YES

    Yeah, to get the ideal behavior you'd need first to search through a data structure that contains all the preferred names for all fonts, and failing that you'd have to search through another data structure just for the legacy names. I can see why this may no be worthwhile since XeTeX tries to be less legacy-encumbered in general.

    Perhaps you should note in the documentation that only preferred names are supported. There's some chance that non-expert users may be confused by what "preferred" means since the legacy names are still the default in most apps (on Linux and Windows anyway) with the notable exception of professional DTP apps. So this may need some explaining for the casual user.

     
  • Jonathan Kew
    Jonathan Kew
    2008-08-09

    Logged In: YES
    user_id=700925
    Originator: NO

    Closing this as "WontFix" (see discussion), because I am not in favor of changing the current behavior in this area, although I agree that properly documenting it would be good.

     


Anonymous


Cancel   Add attachments