[PATCH libX11 2/2] Don't try so hard to find a matching font with the given encoding

Alan Coopersmith alan.coopersmith at oracle.com
Fri Dec 13 22:34:09 PST 2013


On 10/ 7/10 10:46 AM, Jon TURNEY wrote:
> See http://sourceware.org/bugzilla/show_bug.cgi?id=10948
>
> Currently, if the locale is UTF-8, no CJK fonts are installed, and someone
> does XCreateFontSet() with a font name of "*", we end up asking the server
> to list the (non-existent) fonts 11 times for each CJK encoding, which can
> take a while.
>
> A * wildcard can match multiple components in a XLFD name in XListFonts(),
> so there's no need to try adding more than one to get a match.
>
> We do try once with a leading '*-' in case the fontname isn't a full
> well-formed XLFD name, maybe even that isn't needed?
>
> (See also http://invisible-island.net/xterm/xterm.faq.html#slow_menus)
>
> Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
> ---
>   modules/om/generic/omGeneric.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/modules/om/generic/omGeneric.c b/modules/om/generic/omGeneric.c
> index c78c0a9..da2a13d 100644
> --- a/modules/om/generic/omGeneric.c
> +++ b/modules/om/generic/omGeneric.c
> @@ -841,7 +841,7 @@ parse_omit_name(
>   	return True;
>
>       /* This may mot be needed anymore as XListFonts() takes care of this */
> -    while (num_fields < 12) {
> +    if (num_fields < 12) {
>   	if ((last - buf) > (XLFD_MAX_LEN - 2))
>   	    return -1;
>   	*last = '*';
>

We have this code completely disabled in the Solaris builds,
so the comment about it not being needed any more may be true:
https://java.net/projects/solaris-x11/sources/x-s12-clone/content/open-src/lib/libX11/6789219.patch

The comments in our bug report from it say:

   xterm, xfd take long time to start when miss fonts

   What this code does is, it progressively calls the get_font_name which calls
   XListFonts with patterns like '*-<codeset>', '*-*-<codeset>',
   '*-*-*-<codeset>' during each loop to find a matching XLFD font. This code
   is not needed because XListFonts should work on the first invocation just
   before the loop code if there's a matching font.

   Commenting out this code speeds up the apps.

In any case, after 3 years with no comments, I've gone ahead and pushed to
git master.

-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list