emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 557c595: Fix problem with certain fonts in ftfont_shape_by_flt


From: Lars Ingebrigtsen
Subject: master 557c595: Fix problem with certain fonts in ftfont_shape_by_flt
Date: Tue, 20 Jul 2021 08:23:06 -0400 (EDT)

branch: master
commit 557c59591cb03729c7ab56719e5ed87a1f06d435
Author: Kenichi Handa <handa@gnu.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix problem with certain fonts in ftfont_shape_by_flt
    
    * src/ftfont.c (ftfont_shape_by_flt): Fix problem with unusual OTF
    tables in fonts (bug#49066).
---
 src/ftfont.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/ftfont.c b/src/ftfont.c
index 0603dd9..12d0d72 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -2798,10 +2798,31 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font 
*font,
 
   if (gstring.used > LGSTRING_GLYPH_LEN (lgstring))
     return Qnil;
+
+  /* mflt_run may fail to set g->g.to (which must be a valid index
+     into lgstring) correctly if the font has an OTF table that is
+     different from what the m17n library expects. */
   for (i = 0; i < gstring.used; i++)
     {
       MFLTGlyphFT *g = (MFLTGlyphFT *) (gstring.glyphs) + i;
+      if (g->g.to >= len)
+       {
+         /* Invalid g->g.to. */
+         g->g.to = len - 1;
+         int from = g->g.from;
+         /* Fix remaining glyphs. */
+         for (++i; i < gstring.used; i++)
+           {
+             g = (MFLTGlyphFT *) (gstring.glyphs) + i;
+             g->g.from = from;
+             g->g.to = len - 1;
+           }
+       }
+    }
 
+  for (i = 0; i < gstring.used; i++)
+    {
+      MFLTGlyphFT *g = (MFLTGlyphFT *) (gstring.glyphs) + i;
       g->g.from = LGLYPH_FROM (LGSTRING_GLYPH (lgstring, g->g.from));
       g->g.to = LGLYPH_TO (LGSTRING_GLYPH (lgstring, g->g.to));
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]