summaryrefslogtreecommitdiff
path: root/src/ftfont.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>2019-05-14 10:17:16 +0900
committerYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>2019-05-14 10:17:16 +0900
commit9b28a5083edecacfac3c7e16308bd8af3f4773a2 (patch)
treec01c23b892c62d944d89e1f281cbeb7b307d3562 /src/ftfont.c
parent2f7e97ef482ddacd0ed21ccd25ca777beb60ab35 (diff)
downloademacs-9b28a5083edecacfac3c7e16308bd8af3f4773a2.tar.gz
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.
Diffstat (limited to 'src/ftfont.c')
-rw-r--r--src/ftfont.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/ftfont.c b/src/ftfont.c
index d0078a37701..4770c3c40b3 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -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);