Commit 9b28a508 authored by YAMAMOTO Mitsuharu's avatar YAMAMOTO Mitsuharu

Avoid artifacts in ftx and ftcr font backend drivers

* src/ftcrfont.c (ftcrfont_open):
* src/ftfont.c (ftfont_open2): Make font->height equal to sum of font->ascent
and font->descent.  Respect :minspace property.
(ftfont_open2): Remove redundant assignment.
(syms_of_ftfont) <QCminspace>: New DEFSYM.
parent 2f7e97ef
Pipeline #1654 passed with stage
in 52 minutes and 32 seconds
......@@ -160,8 +160,18 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
cairo_font_extents_t extents;
cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents);
font->ascent = lround (extents.ascent);
font->descent = lround (extents.descent);
font->height = lround (extents.height);
Lisp_Object val = assq_no_quit (QCminspace,
AREF (entity, FONT_EXTRA_INDEX));
if (!(CONSP (val) && NILP (XCDR (val))))
{
font->descent = lround (extents.descent);
font->height = font->ascent + font->descent;
}
else
{
font->height = lround (extents.height);
font->descent = font->height - font->ascent;
}
cairo_glyph_t stack_glyph;
int n = 0;
......
......@@ -1108,7 +1108,6 @@ ftfont_open2 (struct frame *f,
return Qnil;
filename = XCAR (val);
idx = XCDR (val);
val = XCDR (cache);
cache_data = xmint_pointer (XCDR (cache));
ft_face = cache_data->ft_face;
if (cache_data->face_refcount > 0)
......@@ -1172,20 +1171,38 @@ ftfont_open2 (struct frame *f,
font->driver = &ftfont_driver;
font->encoding_charset = font->repertory_charset = -1;
val = assq_no_quit (QCminspace, AREF (entity, FONT_EXTRA_INDEX));
bool no_leading_p = !(CONSP (val) && NILP (XCDR (val)));
upEM = ft_face->units_per_EM;
scalable = (FIXNUMP (AREF (entity, FONT_AVGWIDTH_INDEX))
&& XFIXNUM (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0);
if (scalable)
{
font->ascent = ft_face->ascender * size / upEM + 0.5;
font->descent = - ft_face->descender * size / upEM + 0.5;
font->height = ft_face->height * size / upEM + 0.5;
if (no_leading_p)
{
font->descent = - ft_face->descender * size / upEM + 0.5;
font->height = font->ascent + font->descent;
}
else
{
font->height = ft_face->height * size / upEM + 0.5;
font->descent = font->height - font->ascent;
}
}
else
{
font->ascent = ft_face->size->metrics.ascender >> 6;
font->descent = - ft_face->size->metrics.descender >> 6;
font->height = ft_face->size->metrics.height >> 6;
if (no_leading_p)
{
font->descent = - ft_face->size->metrics.descender >> 6;
font->height = font->ascent + font->descent;
}
else
{
font->height = ft_face->size->metrics.height >> 6;
font->descent = font->height - font->ascent;
}
}
if (FIXNUMP (AREF (entity, FONT_SPACING_INDEX)))
spacing = XFIXNUM (AREF (entity, FONT_SPACING_INDEX));
......@@ -2769,6 +2786,9 @@ syms_of_ftfont (void)
DEFSYM (Qsans, "sans");
DEFSYM (Qsans__serif, "sans serif");
/* The boolean-valued font property key specifying the use of leading. */
DEFSYM (QCminspace, ":minspace");
staticpro (&freetype_font_cache);
freetype_font_cache = list1 (Qt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment