[dev] Potential bug in st fallback font code

From: Eric Pruitt <eric.pruitt_AT_gmail.com>
Date: Fri, 20 Feb 2015 19:53:04 -0800

First off, I'm not sure what's proper etiquette around here for posting
a public email that is somewhat directed toward a specific person, so
mea culpa if CC'ing that person is the wrong approach.

While implementing Unicode support for dwm with Xft, I discovered an
issue with my code and realized the same issue appears to be present in
st. When selecting a fallback font for a character that the user has no
fonts installed for, the font cache is immediately exhausted with
duplicate entries of the default font. To test this in st, I made a
small change to print the name of the font st is falling back to for a
given character:

    diff --git a/st.c b/st.c
    index b9d30a7..a44adb1 100644
    --- a/st.c
    +++ b/st.c
    _AT_@ -3427,6 +3427,9 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {

                            fontpattern = FcFontSetMatch(0, fcsets,
                                            FcTrue, fcpattern, &fcres);
    + FcPattern *match = XftFontMatch (xw.dpy, xw.scr, fontpattern, &fcres);
    + char *font = (char *)FcNameUnparse (match);
    + fprintf(stderr, "This font: %s\n", font);

                            /*
                             * Overwrite or create the new cache entry.

After that, I typed the string "ខមែរ" in the terminal and observed the
output from st. The output showed the following lines (truncated):

    CC -o st
    erresc: unknown private set/reset mode 1005
    This font: VL Gothic [...]
    This font: DejaVu Sans Mono [...]
    This font: DejaVu Sans Mono [...]
    This font: DejaVu Sans Mono [...]
    This font: DejaVu Sans Mono [...]
    This font: DejaVu Sans Mono [...]
    This font: DejaVu Sans Mono [...]
    This font: DejaVu Sans Mono [...]
    This font: DejaVu Sans Mono [...]

The Xft / Fc* font calls end up returning the default font even though
the codepoint does not exist in it. This is the first time I've done
anything with Xft, so I'm not sure if there's something that can be done
with the Fc* calls to keep this from happening.

Eric
Received on Sat Feb 21 2015 - 04:53:04 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 21 2015 - 05:00:08 CET