diff options
| author | YAMAMOTO Mitsuharu | 2020-12-06 14:21:35 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2020-12-06 14:21:35 +0900 |
| commit | da00a6f31770b6f3eced6b87c49d89ec33c1e1ab (patch) | |
| tree | 8a456e27254b94f8d4e1bc09f7268dd93e517a74 /lwlib | |
| parent | 6916e7954ab5de5e2dc7b25f165a63396d0e70a0 (diff) | |
| download | emacs-da00a6f31770b6f3eced6b87c49d89ec33c1e1ab.tar.gz emacs-da00a6f31770b6f3eced6b87c49d89ec33c1e1ab.zip | |
Fix Xaw widget text disappearing when built with cairo (bug#43418)
* lwlib/lwlib-utils.c (crxft_font_open_name): Use FcFontMatch to
get a pattern to pass to cairo_ft_font_face_create_for_pattern.
Diffstat (limited to 'lwlib')
| -rw-r--r-- | lwlib/lwlib-utils.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lwlib/lwlib-utils.c b/lwlib/lwlib-utils.c index f15cb603a80..2b3aa55c3e6 100644 --- a/lwlib/lwlib-utils.c +++ b/lwlib/lwlib-utils.c | |||
| @@ -148,6 +148,7 @@ XftFont * | |||
| 148 | crxft_font_open_name (Display *dpy, int screen, const char *name) | 148 | crxft_font_open_name (Display *dpy, int screen, const char *name) |
| 149 | { | 149 | { |
| 150 | XftFont *pub = NULL; | 150 | XftFont *pub = NULL; |
| 151 | FcPattern *match = NULL; | ||
| 151 | FcPattern *pattern = FcNameParse ((FcChar8 *) name); | 152 | FcPattern *pattern = FcNameParse ((FcChar8 *) name); |
| 152 | if (pattern) | 153 | if (pattern) |
| 153 | { | 154 | { |
| @@ -162,12 +163,18 @@ crxft_font_open_name (Display *dpy, int screen, const char *name) | |||
| 162 | FcPatternAddDouble (pattern, FC_DPI, dpi); | 163 | FcPatternAddDouble (pattern, FC_DPI, dpi); |
| 163 | } | 164 | } |
| 164 | FcDefaultSubstitute (pattern); | 165 | FcDefaultSubstitute (pattern); |
| 166 | FcResult result; | ||
| 167 | match = FcFontMatch (NULL, pattern, &result); | ||
| 168 | FcPatternDestroy (pattern); | ||
| 169 | } | ||
| 170 | if (match) | ||
| 171 | { | ||
| 165 | cairo_font_face_t *font_face | 172 | cairo_font_face_t *font_face |
| 166 | = cairo_ft_font_face_create_for_pattern (pattern); | 173 | = cairo_ft_font_face_create_for_pattern (match); |
| 167 | if (font_face) | 174 | if (font_face) |
| 168 | { | 175 | { |
| 169 | double pixel_size; | 176 | double pixel_size; |
| 170 | if ((FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &pixel_size) | 177 | if ((FcPatternGetDouble (match, FC_PIXEL_SIZE, 0, &pixel_size) |
| 171 | != FcResultMatch) | 178 | != FcResultMatch) |
| 172 | || pixel_size < 1) | 179 | || pixel_size < 1) |
| 173 | pixel_size = 10; | 180 | pixel_size = 10; |
| @@ -177,7 +184,7 @@ crxft_font_open_name (Display *dpy, int screen, const char *name) | |||
| 177 | cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size); | 184 | cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size); |
| 178 | cairo_matrix_init_identity (&ctm); | 185 | cairo_matrix_init_identity (&ctm); |
| 179 | cairo_font_options_t *options = cairo_font_options_create (); | 186 | cairo_font_options_t *options = cairo_font_options_create (); |
| 180 | cairo_ft_font_options_substitute (options, pattern); | 187 | cairo_ft_font_options_substitute (options, match); |
| 181 | pub->scaled_font = cairo_scaled_font_create (font_face, &font_matrix, | 188 | pub->scaled_font = cairo_scaled_font_create (font_face, &font_matrix, |
| 182 | &ctm, options); | 189 | &ctm, options); |
| 183 | cairo_font_face_destroy (font_face); | 190 | cairo_font_face_destroy (font_face); |
| @@ -190,7 +197,7 @@ crxft_font_open_name (Display *dpy, int screen, const char *name) | |||
| 190 | pub->height = lround (extents.height); | 197 | pub->height = lround (extents.height); |
| 191 | pub->max_advance_width = lround (extents.max_x_advance); | 198 | pub->max_advance_width = lround (extents.max_x_advance); |
| 192 | } | 199 | } |
| 193 | FcPatternDestroy (pattern); | 200 | FcPatternDestroy (match); |
| 194 | } | 201 | } |
| 195 | if (pub && pub->height <= 0) | 202 | if (pub && pub->height <= 0) |
| 196 | { | 203 | { |