aboutsummaryrefslogtreecommitdiffstats
path: root/src/ftfont.c
diff options
context:
space:
mode:
authorKenichi Handa2008-12-30 23:40:16 +0000
committerKenichi Handa2008-12-30 23:40:16 +0000
commit2b33f1efb50240cab9dc948fa6d705b6eaae67af (patch)
treeea079520e609aac77a33f7c05f4d78c679527c9c /src/ftfont.c
parentc63715cf35aa0078af0be17fbb2d324fca56c4dc (diff)
downloademacs-2b33f1efb50240cab9dc948fa6d705b6eaae67af.tar.gz
emacs-2b33f1efb50240cab9dc948fa6d705b6eaae67af.zip
(ftfont_driver): Set the member get_variation_glyphs to
ftfont_variation_glyphs. (setup_otf_gstring): New function. (ftfont_drive_otf): Use it. (ftfont_shape_by_flt): Handle variation selector. (ftfont_variation_glyphs): New function.
Diffstat (limited to 'src/ftfont.c')
-rw-r--r--src/ftfont.c136
1 files changed, 108 insertions, 28 deletions
diff --git a/src/ftfont.c b/src/ftfont.c
index 4b53467ae42..f58f5150230 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -380,6 +380,8 @@ static int ftfont_anchor_point P_ ((struct font *, unsigned, int,
380 int *, int *)); 380 int *, int *));
381static Lisp_Object ftfont_otf_capability P_ ((struct font *)); 381static Lisp_Object ftfont_otf_capability P_ ((struct font *));
382static Lisp_Object ftfont_shape P_ ((Lisp_Object)); 382static Lisp_Object ftfont_shape P_ ((Lisp_Object));
383static int ftfont_variation_glyphs P_ ((struct font *, int c,
384 unsigned variations[256]));
383 385
384struct font_driver ftfont_driver = 386struct font_driver ftfont_driver =
385 { 387 {
@@ -389,35 +391,41 @@ struct font_driver ftfont_driver =
389 ftfont_list, 391 ftfont_list,
390 ftfont_match, 392 ftfont_match,
391 ftfont_list_family, 393 ftfont_list_family,
392 NULL, 394 NULL, /* free_entity */
393 ftfont_open, 395 ftfont_open,
394 ftfont_close, 396 ftfont_close,
395 /* We can't draw a text without device dependent functions. */ 397 /* We can't draw a text without device dependent functions. */
396 NULL, 398 NULL, /* prepare_face */
397 NULL, 399 NULL, /* done_face */
398 ftfont_has_char, 400 ftfont_has_char,
399 ftfont_encode_char, 401 ftfont_encode_char,
400 ftfont_text_extents, 402 ftfont_text_extents,
401 /* We can't draw a text without device dependent functions. */ 403 /* We can't draw a text without device dependent functions. */
402 NULL, 404 NULL, /* draw */
403 ftfont_get_bitmap, 405 ftfont_get_bitmap,
404 NULL, 406 NULL, /* get_bitmap */
405 NULL, 407 NULL, /* free_bitmap */
406 NULL, 408 NULL, /* get_outline */
407 ftfont_anchor_point, 409 ftfont_anchor_point,
408#ifdef HAVE_LIBOTF 410#ifdef HAVE_LIBOTF
409 ftfont_otf_capability, 411 ftfont_otf_capability,
410#else /* not HAVE_LIBOTF */ 412#else /* not HAVE_LIBOTF */
411 NULL, 413 NULL,
412#endif /* not HAVE_LIBOTF */ 414#endif /* not HAVE_LIBOTF */
413 NULL, 415 NULL, /* otf_drive */
414 NULL, 416 NULL, /* start_for_frame */
415 NULL, 417 NULL, /* end_for_frame */
416#if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF) 418#if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF)
417 ftfont_shape 419 ftfont_shape,
418#else /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */ 420#else /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
419 NULL 421 NULL,
420#endif /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */ 422#endif /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
423 NULL, /* check */
424#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
425 ftfont_variation_glyphs
426#else
427 NULL
428#endif
421 }; 429 };
422 430
423extern Lisp_Object QCname; 431extern Lisp_Object QCname;
@@ -1536,6 +1544,25 @@ adjust_anchor (FT_Face ft_face, OTF_Anchor *anchor,
1536 1544
1537static OTF_GlyphString otf_gstring; 1545static OTF_GlyphString otf_gstring;
1538 1546
1547static void
1548setup_otf_gstring (int size)
1549{
1550 if (otf_gstring.size == 0)
1551 {
1552 otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * size);
1553 otf_gstring.size = size;
1554 }
1555 else if (otf_gstring.size < size)
1556 {
1557 otf_gstring.glyphs = (OTF_Glyph *) realloc (otf_gstring.glyphs,
1558 sizeof (OTF_Glyph) * size);
1559 otf_gstring.size = size;
1560 }
1561 otf_gstring.used = size;
1562 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * size);
1563}
1564
1565
1539static int 1566static int
1540ftfont_drive_otf (font, spec, in, from, to, out, adjustment) 1567ftfont_drive_otf (font, spec, in, from, to, out, adjustment)
1541 MFLTFont *font; 1568 MFLTFont *font;
@@ -1588,19 +1615,7 @@ ftfont_drive_otf (font, spec, in, from, to, out, adjustment)
1588 } 1615 }
1589 } 1616 }
1590 1617
1591 if (otf_gstring.size == 0) 1618 setup_otf_gstring (len);
1592 {
1593 otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * len);
1594 otf_gstring.size = len;
1595 }
1596 else if (otf_gstring.size < len)
1597 {
1598 otf_gstring.glyphs = (OTF_Glyph *) realloc (otf_gstring.glyphs,
1599 sizeof (OTF_Glyph) * len);
1600 otf_gstring.size = len;
1601 }
1602 otf_gstring.used = len;
1603 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * len);
1604 for (i = 0; i < len; i++) 1619 for (i = 0; i < len; i++)
1605 { 1620 {
1606 otf_gstring.glyphs[i].c = in->glyphs[from + i].c; 1621 otf_gstring.glyphs[i].c = in->glyphs[from + i].c;
@@ -1818,6 +1833,7 @@ ftfont_shape_by_flt (lgstring, font, ft_face, otf)
1818 EMACS_UINT i; 1833 EMACS_UINT i;
1819 struct MFLTFontFT flt_font_ft; 1834 struct MFLTFontFT flt_font_ft;
1820 MFLT *flt = NULL; 1835 MFLT *flt = NULL;
1836 int with_variation_selector = 0;
1821 1837
1822 if (! m17n_flt_initialized) 1838 if (! m17n_flt_initialized)
1823 { 1839 {
@@ -1826,9 +1842,45 @@ ftfont_shape_by_flt (lgstring, font, ft_face, otf)
1826 } 1842 }
1827 1843
1828 for (i = 0; i < len; i++) 1844 for (i = 0; i < len; i++)
1829 if (NILP (LGSTRING_GLYPH (lgstring, i))) 1845 {
1830 break; 1846 Lisp_Object g = LGSTRING_GLYPH (lgstring, i);
1847 int c;
1848
1849 if (NILP (g))
1850 break;
1851 c = LGLYPH_CHAR (g);
1852 if (CHAR_VARIATION_SELECTOR_P (c))
1853 with_variation_selector++;
1854 }
1831 len = i; 1855 len = i;
1856 if (with_variation_selector)
1857 {
1858 setup_otf_gstring (len);
1859 for (i = 0; i < len; i++)
1860 {
1861 Lisp_Object g = LGSTRING_GLYPH (lgstring, i);
1862
1863 otf_gstring.glyphs[i].c = LGLYPH_CHAR (g);
1864 otf_gstring.glyphs[i].f.index.from = LGLYPH_FROM (g);
1865 otf_gstring.glyphs[i].f.index.to = LGLYPH_TO (g);
1866 }
1867 OTF_drive_cmap (otf, &otf_gstring);
1868 for (i = 0; i < otf_gstring.used; i++)
1869 {
1870 OTF_Glyph *otfg = otf_gstring.glyphs + i;
1871 Lisp_Object g0 = LGSTRING_GLYPH (lgstring, otfg->f.index.from);
1872 Lisp_Object g1 = LGSTRING_GLYPH (lgstring, otfg->f.index.to);
1873
1874 LGLYPH_SET_CODE (g0, otfg->glyph_id);
1875 LGLYPH_SET_TO (g0, LGLYPH_TO (g1));
1876 LGSTRING_SET_GLYPH (lgstring, i, g0);
1877 }
1878 if (len > otf_gstring.used)
1879 {
1880 len = otf_gstring.used;
1881 LGSTRING_SET_GLYPH (lgstring, len, Qnil);
1882 }
1883 }
1832 1884
1833 if (gstring.allocated == 0) 1885 if (gstring.allocated == 0)
1834 { 1886 {
@@ -1842,8 +1894,19 @@ ftfont_shape_by_flt (lgstring, font, ft_face, otf)
1842 gstring.glyphs = realloc (gstring.glyphs, 1894 gstring.glyphs = realloc (gstring.glyphs,
1843 sizeof (MFLTGlyph) * gstring.allocated); 1895 sizeof (MFLTGlyph) * gstring.allocated);
1844 } 1896 }
1897 memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len);
1845 for (i = 0; i < len; i++) 1898 for (i = 0; i < len; i++)
1846 gstring.glyphs[i].c = LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, i)); 1899 {
1900 Lisp_Object g = LGSTRING_GLYPH (lgstring, i);
1901
1902 gstring.glyphs[i].c = LGLYPH_CHAR (g);
1903 if (with_variation_selector)
1904 {
1905 gstring.glyphs[i].code = LGLYPH_CODE (g);
1906 gstring.glyphs[i].encoded = 1;
1907 }
1908 }
1909
1847 gstring.used = len; 1910 gstring.used = len;
1848 gstring.r2l = 0; 1911 gstring.r2l = 0;
1849 1912
@@ -1940,6 +2003,23 @@ ftfont_shape (lgstring)
1940 return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf); 2003 return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf);
1941} 2004}
1942 2005
2006#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
2007
2008static int
2009ftfont_variation_glyphs (font, c, variations)
2010 struct font *font;
2011 int c;
2012 unsigned variations[256];
2013{
2014 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
2015 OTF *otf = ftfont_get_otf (ftfont_info);
2016
2017 if (! otf)
2018 return 0;
2019 return OTF_get_variation_glyphs (otf, c, variations);
2020}
2021
2022#endif /* HAVE_OTF_GET_VARIATION_GLYPHS */
1943#endif /* HAVE_M17N_FLT */ 2023#endif /* HAVE_M17N_FLT */
1944#endif /* HAVE_LIBOTF */ 2024#endif /* HAVE_LIBOTF */
1945 2025