[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10867: 26.3; XIM preedit/status font handling
From: |
Yichao Yu |
Subject: |
bug#10867: 26.3; XIM preedit/status font handling |
Date: |
Sun, 2 Aug 2020 16:07:26 -0400 |
> ## What other programs do
> * xterm seems to use "fixed" to lookup font
> * qt4 https://dreamswork.github.io/qt4/qximinputcontext__x11_8cpp_source.html
> AFAICT uses different fonts?
> * gtk I don't actually see where it set fonts...
> @Xuetian Weng dug deeper into this
>
> ## Fix
> I'm not sure what's the correct one. It seems that setting the fontSet
> is necessary although I'm not sure how/if gtk get away with it.
> According to @Xuetian Weng virtually no one use this setting anymore
> so setting a dummy value to comfort xlib might be good enough? It
> would avoid both issues at the same time.
And since it's basically a useless setting at this point, this fix seems to work
diff --git a/src/xfns.c b/src/xfns.c
index 2ab5080d97..fbbc429fe1 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2511,72 +2511,19 @@ xic_create_xfontset (struct frame *f)
if (! xfs)
{
- char buf[256];
char **missing_list;
int missing_count;
char *def_string;
- const char *xlfd_format = "-*-*-medium-r-normal--%d-*-*-*-*-*";
+ const char *last_resort = "fixed";
- sprintf (buf, xlfd_format, pixel_size);
missing_list = NULL;
- xfs = XCreateFontSet (FRAME_X_DISPLAY (f), buf,
+ xfs = XCreateFontSet (FRAME_X_DISPLAY (f), last_resort,
&missing_list, &missing_count, &def_string);
#ifdef DEBUG_XIC_FONTSET
- print_fontset_result (xfs, buf, missing_list, missing_count);
+ print_fontset_result (xfs, last_resort, missing_list, missing_count);
#endif
if (missing_list)
- XFreeStringList (missing_list);
- if (! xfs)
- {
- /* List of pixel sizes most likely available. Find one that
- is closest to pixel_size. */
- int sizes[] = {0, 8, 10, 11, 12, 14, 17, 18, 20, 24, 26, 34, 0};
- int *smaller, *larger;
-
- for (smaller = sizes; smaller[1]; smaller++)
- if (smaller[1] >= pixel_size)
- break;
- larger = smaller + 1;
- if (*larger == pixel_size)
- larger++;
- while (*smaller || *larger)
- {
- int this_size;
-
- if (! *larger)
- this_size = *smaller--;
- else if (! *smaller)
- this_size = *larger++;
- else if (pixel_size - *smaller < *larger - pixel_size)
- this_size = *smaller--;
- else
- this_size = *larger++;
- sprintf (buf, xlfd_format, this_size);
- missing_list = NULL;
- xfs = XCreateFontSet (FRAME_X_DISPLAY (f), buf,
- &missing_list, &missing_count, &def_string);
-#ifdef DEBUG_XIC_FONTSET
- print_fontset_result (xfs, buf, missing_list, missing_count);
-#endif
- if (missing_list)
- XFreeStringList (missing_list);
- if (xfs)
- break;
- }
- }
- if (! xfs)
- {
- const char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*";
-
- missing_list = NULL;
- xfs = XCreateFontSet (FRAME_X_DISPLAY (f), last_resort,
- &missing_list, &missing_count, &def_string);
-#ifdef DEBUG_XIC_FONTSET
- print_fontset_result (xfs, last_resort, missing_list, missing_count);
-#endif
- if (missing_list)
- XFreeStringList (missing_list);
- }
+ XFreeStringList (missing_list);
}