mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
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.
This commit is contained in:
parent
6916e7954a
commit
da00a6f317
1 changed files with 11 additions and 4 deletions
|
|
@ -148,6 +148,7 @@ XftFont *
|
||||||
crxft_font_open_name (Display *dpy, int screen, const char *name)
|
crxft_font_open_name (Display *dpy, int screen, const char *name)
|
||||||
{
|
{
|
||||||
XftFont *pub = NULL;
|
XftFont *pub = NULL;
|
||||||
|
FcPattern *match = NULL;
|
||||||
FcPattern *pattern = FcNameParse ((FcChar8 *) name);
|
FcPattern *pattern = FcNameParse ((FcChar8 *) name);
|
||||||
if (pattern)
|
if (pattern)
|
||||||
{
|
{
|
||||||
|
|
@ -162,12 +163,18 @@ crxft_font_open_name (Display *dpy, int screen, const char *name)
|
||||||
FcPatternAddDouble (pattern, FC_DPI, dpi);
|
FcPatternAddDouble (pattern, FC_DPI, dpi);
|
||||||
}
|
}
|
||||||
FcDefaultSubstitute (pattern);
|
FcDefaultSubstitute (pattern);
|
||||||
|
FcResult result;
|
||||||
|
match = FcFontMatch (NULL, pattern, &result);
|
||||||
|
FcPatternDestroy (pattern);
|
||||||
|
}
|
||||||
|
if (match)
|
||||||
|
{
|
||||||
cairo_font_face_t *font_face
|
cairo_font_face_t *font_face
|
||||||
= cairo_ft_font_face_create_for_pattern (pattern);
|
= cairo_ft_font_face_create_for_pattern (match);
|
||||||
if (font_face)
|
if (font_face)
|
||||||
{
|
{
|
||||||
double pixel_size;
|
double pixel_size;
|
||||||
if ((FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &pixel_size)
|
if ((FcPatternGetDouble (match, FC_PIXEL_SIZE, 0, &pixel_size)
|
||||||
!= FcResultMatch)
|
!= FcResultMatch)
|
||||||
|| pixel_size < 1)
|
|| pixel_size < 1)
|
||||||
pixel_size = 10;
|
pixel_size = 10;
|
||||||
|
|
@ -177,7 +184,7 @@ crxft_font_open_name (Display *dpy, int screen, const char *name)
|
||||||
cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size);
|
cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size);
|
||||||
cairo_matrix_init_identity (&ctm);
|
cairo_matrix_init_identity (&ctm);
|
||||||
cairo_font_options_t *options = cairo_font_options_create ();
|
cairo_font_options_t *options = cairo_font_options_create ();
|
||||||
cairo_ft_font_options_substitute (options, pattern);
|
cairo_ft_font_options_substitute (options, match);
|
||||||
pub->scaled_font = cairo_scaled_font_create (font_face, &font_matrix,
|
pub->scaled_font = cairo_scaled_font_create (font_face, &font_matrix,
|
||||||
&ctm, options);
|
&ctm, options);
|
||||||
cairo_font_face_destroy (font_face);
|
cairo_font_face_destroy (font_face);
|
||||||
|
|
@ -190,7 +197,7 @@ crxft_font_open_name (Display *dpy, int screen, const char *name)
|
||||||
pub->height = lround (extents.height);
|
pub->height = lround (extents.height);
|
||||||
pub->max_advance_width = lround (extents.max_x_advance);
|
pub->max_advance_width = lround (extents.max_x_advance);
|
||||||
}
|
}
|
||||||
FcPatternDestroy (pattern);
|
FcPatternDestroy (match);
|
||||||
}
|
}
|
||||||
if (pub && pub->height <= 0)
|
if (pub && pub->height <= 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue