aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley2015-11-13 14:41:41 -0800
committerJohn Wiegley2015-11-13 14:41:41 -0800
commit4d71d2471aaf341791fd728287bf8db62aebb3ba (patch)
tree58f251903d68b3b10c41edb03df9e9b72480c1b9 /src
parent51644c33d2e046b681646e2e07a636ba2fb234dc (diff)
parent92a501022e0154cd9de41240680b7f003a833c96 (diff)
downloademacs-4d71d2471aaf341791fd728287bf8db62aebb3ba.tar.gz
emacs-4d71d2471aaf341791fd728287bf8db62aebb3ba.zip
Merge remote-tracking branch 'origin/master' into emacs-25
Diffstat (limited to 'src')
-rw-r--r--src/ftfont.c106
1 files changed, 50 insertions, 56 deletions
diff --git a/src/ftfont.c b/src/ftfont.c
index 57ded171de4..17e41a9339e 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1776,9 +1776,11 @@ setup_otf_gstring (int size)
1776{ 1776{
1777 if (otf_gstring.size < size) 1777 if (otf_gstring.size < size)
1778 { 1778 {
1779 otf_gstring.glyphs = xnrealloc (otf_gstring.glyphs, 1779 ptrdiff_t new_size = otf_gstring.size;
1780 size, sizeof (OTF_Glyph)); 1780 xfree (otf_gstring.glyphs);
1781 otf_gstring.size = size; 1781 otf_gstring.glyphs = xpalloc (NULL, &new_size, size - otf_gstring.size,
1782 INT_MAX, sizeof *otf_gstring.glyphs);
1783 otf_gstring.size = new_size;
1782 } 1784 }
1783 otf_gstring.used = size; 1785 otf_gstring.used = size;
1784 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * size); 1786 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * size);
@@ -2505,8 +2507,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2505 ptrdiff_t i; 2507 ptrdiff_t i;
2506 struct MFLTFontFT flt_font_ft; 2508 struct MFLTFontFT flt_font_ft;
2507 MFLT *flt = NULL; 2509 MFLT *flt = NULL;
2508 bool with_variation_selector = 0; 2510 bool with_variation_selector = false;
2509 MFLTGlyphFT *glyphs;
2510 2511
2511 if (! m17n_flt_initialized) 2512 if (! m17n_flt_initialized)
2512 { 2513 {
@@ -2527,7 +2528,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2527 break; 2528 break;
2528 c = LGLYPH_CHAR (g); 2529 c = LGLYPH_CHAR (g);
2529 if (CHAR_VARIATION_SELECTOR_P (c)) 2530 if (CHAR_VARIATION_SELECTOR_P (c))
2530 with_variation_selector = 1; 2531 with_variation_selector = true;
2531 } 2532 }
2532 2533
2533 len = i; 2534 len = i;
@@ -2561,39 +2562,6 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2561 } 2562 }
2562 } 2563 }
2563 2564
2564 int len2;
2565 if (INT_MULTIPLY_WRAPV (len, 2, &len2))
2566 memory_full (SIZE_MAX);
2567
2568 if (gstring.allocated == 0)
2569 {
2570 gstring.glyph_size = sizeof (MFLTGlyphFT);
2571 gstring.glyphs = xnmalloc (len2, sizeof (MFLTGlyphFT));
2572 gstring.allocated = len2;
2573 }
2574 else if (gstring.allocated < len2)
2575 {
2576 gstring.glyphs = xnrealloc (gstring.glyphs, len2,
2577 sizeof (MFLTGlyphFT));
2578 gstring.allocated = len2;
2579 }
2580 glyphs = (MFLTGlyphFT *) (gstring.glyphs);
2581 memset (glyphs, 0, len * sizeof (MFLTGlyphFT));
2582 for (i = 0; i < len; i++)
2583 {
2584 Lisp_Object g = LGSTRING_GLYPH (lgstring, i);
2585
2586 glyphs[i].g.c = LGLYPH_CHAR (g);
2587 if (with_variation_selector)
2588 {
2589 glyphs[i].g.code = LGLYPH_CODE (g);
2590 glyphs[i].g.encoded = 1;
2591 }
2592 }
2593
2594 gstring.used = len;
2595 gstring.r2l = 0;
2596
2597 { 2565 {
2598 Lisp_Object family = Ffont_get (LGSTRING_FONT (lgstring), QCfamily); 2566 Lisp_Object family = Ffont_get (LGSTRING_FONT (lgstring), QCfamily);
2599 2567
@@ -2614,24 +2582,50 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2614 flt_font_ft.ft_face = ft_face; 2582 flt_font_ft.ft_face = ft_face;
2615 flt_font_ft.otf = otf; 2583 flt_font_ft.otf = otf;
2616 flt_font_ft.matrix = matrix->xx != 0 ? matrix : 0; 2584 flt_font_ft.matrix = matrix->xx != 0 ? matrix : 0;
2617 if (len > 1 2585
2618 && gstring.glyphs[1].c >= 0x300 && gstring.glyphs[1].c <= 0x36F) 2586 if (1 < len)
2619 /* A little bit ad hoc. Perhaps, shaper must get script and 2587 {
2620 language information, and select a proper flt for them 2588 /* A little bit ad hoc. Perhaps, shaper must get script and
2621 here. */ 2589 language information, and select a proper flt for them
2622 flt = mflt_get (msymbol ("combining")); 2590 here. */
2623 for (i = 0; i < 3; i++) 2591 int c1 = LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 1));
2624 { 2592 if (0x300 <= c1 && c1 <= 0x36F)
2625 int result = mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, flt); 2593 flt = mflt_get (msymbol ("combining"));
2626 if (result != -2) 2594 }
2627 break; 2595
2628 int len2; 2596 MFLTGlyphFT *glyphs = (MFLTGlyphFT *) gstring.glyphs;
2629 if (INT_MULTIPLY_WRAPV (gstring.allocated, 2, &len2)) 2597 ptrdiff_t allocated = gstring.allocated;
2630 memory_full (SIZE_MAX); 2598 ptrdiff_t incr_min = len - allocated;
2631 gstring.glyphs = xnrealloc (gstring.glyphs, 2599
2632 gstring.allocated, 2 * sizeof (MFLTGlyphFT)); 2600 do
2633 gstring.allocated = len2; 2601 {
2602 if (0 < incr_min)
2603 {
2604 xfree (glyphs);
2605 glyphs = xpalloc (NULL, &allocated, incr_min, INT_MAX, sizeof *glyphs);
2606 }
2607 incr_min = 1;
2608
2609 for (i = 0; i < len; i++)
2610 {
2611 Lisp_Object g = LGSTRING_GLYPH (lgstring, i);
2612 memset (&glyphs[i], 0, sizeof glyphs[i]);
2613 glyphs[i].g.c = LGLYPH_CHAR (g);
2614 if (with_variation_selector)
2615 {
2616 glyphs[i].g.code = LGLYPH_CODE (g);
2617 glyphs[i].g.encoded = 1;
2618 }
2619 }
2620
2621 gstring.glyph_size = sizeof *glyphs;
2622 gstring.glyphs = (MFLTGlyph *) glyphs;
2623 gstring.allocated = allocated;
2624 gstring.used = len;
2625 gstring.r2l = 0;
2634 } 2626 }
2627 while (mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, flt) == -2);
2628
2635 if (gstring.used > LGSTRING_GLYPH_LEN (lgstring)) 2629 if (gstring.used > LGSTRING_GLYPH_LEN (lgstring))
2636 return Qnil; 2630 return Qnil;
2637 for (i = 0; i < gstring.used; i++) 2631 for (i = 0; i < gstring.used; i++)