[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#421025: XCreateFontSet fails with fixed 13 as first font pattern in UTF-8 environment



On Fri, 2007-08-10 at 11:48 +0200, Brice Goglin wrote:
> Ben Hutchings wrote:
> > If list->charset_list != NULL and list->charset_count == 0, the Xmalloc
> > call in copy_string_list might return NULL (I don't know whether it
> > supports a size of 0), causing copy_string_list and XCreateFontSet() to
> > return NULL.  This seems unlikely to be triggered only by the exact font
> > pattern lists I identified though.
> >   
> 
> By the way, did you try with libx11-6 2:1.1.3-1 currently in experimental?

I have tried this now, and the assertion still fails.

I traced through the call with gdb and symbols from the libx11-dbg
package.  Most of the interesting code is in omGeneric.c; XCreateFontSet
indirectly calls create_oc in this file.  This gets some configuration
from files in /usr/share/X11/locale.  The "locale.dir" file specifies
that most UTF-8 locales should get font set configuration from
"en_US.UTF-8/XLC_LOCALE".  That specifies that it should look for fonts
covering the following character sets:

0. ISO8859-1
1. ISO8859-1 (again)
2. JISX0208.1983-0
3. KSC5601.1987-0
4. GB2312.1980-0
5. JISX0201.1976-0
6. ISO10646-1

parse_fontname somehow comes up with the following font names for these,
respectively:

0. -misc-fixed-bold-r-normal--13-100-100-100-c-70-iso8859-1
1. -misc-fixed-bold-r-normal--13-100-100-100-c-70-iso8859-1
2. -jis-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0
3. (nothing)
4. (nothing)
5. -misc-fixed-medium-r-normal--13-94-100-100-c-0-jisx0201.1976-0
6. -misc-fixed-bold-r-normal--13-120-75-75-c-70-iso10646-1

Then load_font_info calls XListFontsWithInfo for each of these names.
This fails for
"-jis-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0", and the
error propagates up to the caller of XCreateFontSet.  It would also fail
for "-misc-fixed-medium-r-normal--13-94-100-100-c-0-jisx0201.1976-0".

parse_fontname is calling parse_omit_name, which combines the font
name(s) originally passed to XCreateFontSet with a given character set
and then calls get_font_name, which calls XListFonts.  And XListFonts
for "-*-fixed-*-*-*-*-13-*-*-*-*-*-JISX0208.1983-0" returns
"-jis-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0".

XListFonts does little other than making a request to the server.  So I
guess this is really a server bug.

Here's a new test program:

#include <assert.h>
#include <stdio.h>

#include <X11/Xlib.h>

int main(int argc, char ** argv)
{
    Display * display;
    char **name_list, **name_list_2;
    int count, count_2, i;
    XFontStruct *info;

    assert(argc >= 2);
    display = XOpenDisplay(0);
    assert(display);
    name_list = XListFonts(display, argv[1], 10, &count);
    assert(name_list);

    for (i = 0; i != count; ++i)
    {
	name_list_2 = XListFontsWithInfo(display, name_list[i], 1, &count_2,
					 &info);
	if (name_list_2)
	{
	    printf("%s exists\n", name_list[i]);
	    XFreeFontInfo(name_list_2, info, count_2);
	}
	else
	{
	    printf("%s doesn't exist!\n", name_list[i]);
	}
    }

    XFreeFontNames(name_list);

    return 0;
}

Run this with the argument
"-*-fixed-*-*-*-*-*-*-*-*-*-*-JISX0208.1983-0" and you should see the
bug (or not).

Ben.

-- 
Ben Hutchings
friends: People who know you well, but like you anyway.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: