aboutsummaryrefslogtreecommitdiffstats
path: root/src/font.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/font.c b/src/font.c
index 49a09bced28..1f22fee88ee 100644
--- a/src/font.c
+++ b/src/font.c
@@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#include <config.h> 23#include <config.h>
24#include <float.h> 24#include <float.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <setjmp.h>
27 26
28#include <c-ctype.h> 27#include <c-ctype.h>
29 28
@@ -4296,12 +4295,15 @@ to get the correct visual image of character sequences set in the
4296header of the glyph-string. 4295header of the glyph-string.
4297 4296
4298If the shaping was successful, the value is GSTRING itself or a newly 4297If the shaping was successful, the value is GSTRING itself or a newly
4299created glyph-string. Otherwise, the value is nil. */) 4298created glyph-string. Otherwise, the value is nil.
4299
4300See the documentation of `composition-get-gstring' for the format of
4301GSTRING. */)
4300 (Lisp_Object gstring) 4302 (Lisp_Object gstring)
4301{ 4303{
4302 struct font *font; 4304 struct font *font;
4303 Lisp_Object font_object, n, glyph; 4305 Lisp_Object font_object, n, glyph;
4304 ptrdiff_t i, j, from, to; 4306 ptrdiff_t i, from, to;
4305 4307
4306 if (! composition_gstring_p (gstring)) 4308 if (! composition_gstring_p (gstring))
4307 signal_error ("Invalid glyph-string: ", gstring); 4309 signal_error ("Invalid glyph-string: ", gstring);
@@ -4327,44 +4329,42 @@ created glyph-string. Otherwise, the value is nil. */)
4327 if (XINT (n) < LGSTRING_GLYPH_LEN (gstring)) 4329 if (XINT (n) < LGSTRING_GLYPH_LEN (gstring))
4328 LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil); 4330 LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil);
4329 4331
4332 /* Check FROM_IDX and TO_IDX of each GLYPH in GSTRING to assure that
4333 GLYPHS covers all characters (except for the last few ones) in
4334 GSTRING. More formally, provided that NCHARS is the number of
4335 characters in GSTRING and GLYPHS[i] is the ith glyph, FROM_IDX
4336 and TO_IDX of each glyph must satisfy these conditions:
4337
4338 GLYPHS[0].FROM_IDX == 0
4339 GLYPHS[i].FROM_IDX <= GLYPHS[i].TO_IDX
4340 if (GLYPHS[i].FROM_IDX == GLYPHS[i-1].FROM_IDX)
4341 ;; GLYPHS[i] and GLYPHS[i-1] belongs to the same grapheme cluster
4342 GLYPHS[i].TO_IDX == GLYPHS[i-1].TO_IDX
4343 else
4344 ;; Be sure to cover all characters.
4345 GLYPHS[i].FROM_IDX == GLYPHS[i-1].TO_IDX + 1 */
4330 glyph = LGSTRING_GLYPH (gstring, 0); 4346 glyph = LGSTRING_GLYPH (gstring, 0);
4331 from = LGLYPH_FROM (glyph); 4347 from = LGLYPH_FROM (glyph);
4332 to = LGLYPH_TO (glyph); 4348 to = LGLYPH_TO (glyph);
4333 for (i = 1, j = 0; i < LGSTRING_GLYPH_LEN (gstring); i++) 4349 if (from != 0 || to < from)
4350 goto shaper_error;
4351 for (i = 1; i < LGSTRING_GLYPH_LEN (gstring); i++)
4334 { 4352 {
4335 Lisp_Object this = LGSTRING_GLYPH (gstring, i); 4353 glyph = LGSTRING_GLYPH (gstring, i);
4336 4354 if (NILP (glyph))
4337 if (NILP (this))
4338 break; 4355 break;
4339 if (NILP (LGLYPH_ADJUSTMENT (this))) 4356 if (! (LGLYPH_FROM (glyph) <= LGLYPH_TO (glyph)
4340 { 4357 && (LGLYPH_FROM (glyph) == from
4341 if (j < i - 1) 4358 ? LGLYPH_TO (glyph) == to
4342 for (; j < i; j++) 4359 : LGLYPH_FROM (glyph) == to + 1)))
4343 { 4360 goto shaper_error;
4344 glyph = LGSTRING_GLYPH (gstring, j); 4361 from = LGLYPH_FROM (glyph);
4345 LGLYPH_SET_FROM (glyph, from); 4362 to = LGLYPH_TO (glyph);
4346 LGLYPH_SET_TO (glyph, to);
4347 }
4348 from = LGLYPH_FROM (this);
4349 to = LGLYPH_TO (this);
4350 j = i;
4351 }
4352 else
4353 {
4354 if (from > LGLYPH_FROM (this))
4355 from = LGLYPH_FROM (this);
4356 if (to < LGLYPH_TO (this))
4357 to = LGLYPH_TO (this);
4358 }
4359 } 4363 }
4360 if (j < i - 1)
4361 for (; j < i; j++)
4362 {
4363 glyph = LGSTRING_GLYPH (gstring, j);
4364 LGLYPH_SET_FROM (glyph, from);
4365 LGLYPH_SET_TO (glyph, to);
4366 }
4367 return composition_gstring_put_cache (gstring, XINT (n)); 4364 return composition_gstring_put_cache (gstring, XINT (n));
4365
4366 shaper_error:
4367 return Qnil;
4368} 4368}
4369 4369
4370DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs, 4370DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs,