diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 16 | ||||
| -rw-r--r-- | src/ftfont.c | 48 |
2 files changed, 56 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 825bb816a87..6f13fe12611 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2009-12-12 Kenichi Handa <handa@m17n.org> | ||
| 2 | |||
| 3 | * ftfont.c (struct ftfont_info): New member matrix. | ||
| 4 | (ftfont_open): Setup xftfont_info->matrix. | ||
| 5 | (MFLTFontFT): New member matrix. | ||
| 6 | (FLOOR, CEIL, ROUND): New macros. | ||
| 7 | (ftfont_get_metrics): Handle matrix transformation. | ||
| 8 | (ftfont_shape_by_flt): New arg matrix. Callers changed. | ||
| 9 | |||
| 10 | * xftfont.c (struct xftfont_info): New member matrix. | ||
| 11 | (xftfont_open): Setup xftfont_info->matrix. | ||
| 12 | |||
| 13 | 2009-12-10 Kenichi Handa <handa@m17n.org> | ||
| 14 | |||
| 15 | * xdisp.c (append_space_for_newline): Consider face-remapping. | ||
| 16 | |||
| 1 | 2009-12-09 Andreas Schwab <schwab@linux-m68k.org> | 17 | 2009-12-09 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 18 | ||
| 3 | * xsettings.c: Include "keyboard.h". | 19 | * xsettings.c: Include "keyboard.h". |
diff --git a/src/ftfont.c b/src/ftfont.c index 4ba4712965f..4ebc4be9cf0 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -70,6 +70,7 @@ struct ftfont_info | |||
| 70 | #endif /* HAVE_LIBOTF */ | 70 | #endif /* HAVE_LIBOTF */ |
| 71 | FT_Size ft_size; | 71 | FT_Size ft_size; |
| 72 | int index; | 72 | int index; |
| 73 | FT_Matrix matrix; | ||
| 73 | }; | 74 | }; |
| 74 | 75 | ||
| 75 | enum ftfont_cache_for | 76 | enum ftfont_cache_for |
| @@ -1236,6 +1237,8 @@ ftfont_open (f, entity, pixel_size) | |||
| 1236 | ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; | 1237 | ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; |
| 1237 | ftfont_info->otf = NULL; | 1238 | ftfont_info->otf = NULL; |
| 1238 | #endif /* HAVE_LIBOTF */ | 1239 | #endif /* HAVE_LIBOTF */ |
| 1240 | /* This means that there's no need of transformation. */ | ||
| 1241 | ftfont_info->matrix.xx = 0; | ||
| 1239 | font->pixel_size = size; | 1242 | font->pixel_size = size; |
| 1240 | font->driver = &ftfont_driver; | 1243 | font->driver = &ftfont_driver; |
| 1241 | font->encoding_charset = font->repertory_charset = -1; | 1244 | font->encoding_charset = font->repertory_charset = -1; |
| @@ -1581,6 +1584,7 @@ struct MFLTFontFT | |||
| 1581 | struct font *font; | 1584 | struct font *font; |
| 1582 | FT_Face ft_face; | 1585 | FT_Face ft_face; |
| 1583 | OTF *otf; | 1586 | OTF *otf; |
| 1587 | FT_Matrix *matrix; | ||
| 1584 | }; | 1588 | }; |
| 1585 | 1589 | ||
| 1586 | static int | 1590 | static int |
| @@ -1604,6 +1608,12 @@ ftfont_get_glyph_id (font, gstring, from, to) | |||
| 1604 | return 0; | 1608 | return 0; |
| 1605 | } | 1609 | } |
| 1606 | 1610 | ||
| 1611 | /* Operators for 26.6 fixed fractional pixel format */ | ||
| 1612 | |||
| 1613 | #define FLOOR(x) ((x) & -64) | ||
| 1614 | #define CEIL(x) (((x)+63) & -64) | ||
| 1615 | #define ROUND(x) (((x)+32) & -64) | ||
| 1616 | |||
| 1607 | static int | 1617 | static int |
| 1608 | ftfont_get_metrics (font, gstring, from, to) | 1618 | ftfont_get_metrics (font, gstring, from, to) |
| 1609 | MFLTFont *font; | 1619 | MFLTFont *font; |
| @@ -1620,16 +1630,35 @@ ftfont_get_metrics (font, gstring, from, to) | |||
| 1620 | if (g->code != FONT_INVALID_CODE) | 1630 | if (g->code != FONT_INVALID_CODE) |
| 1621 | { | 1631 | { |
| 1622 | FT_Glyph_Metrics *m; | 1632 | FT_Glyph_Metrics *m; |
| 1633 | int lbearing, rbearing, ascent, descent, xadv; | ||
| 1623 | 1634 | ||
| 1624 | if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0) | 1635 | if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0) |
| 1625 | abort (); | 1636 | abort (); |
| 1626 | m = &ft_face->glyph->metrics; | 1637 | m = &ft_face->glyph->metrics; |
| 1627 | 1638 | if (flt_font_ft->matrix) | |
| 1628 | g->lbearing = m->horiBearingX; | 1639 | { |
| 1629 | g->rbearing = m->horiBearingX + m->width; | 1640 | FT_Vector v[4]; |
| 1630 | g->ascent = m->horiBearingY; | 1641 | int i; |
| 1631 | g->descent = m->height - m->horiBearingY; | 1642 | |
| 1632 | g->xadv = m->horiAdvance; | 1643 | v[0].x = v[1].x = m->horiBearingX; |
| 1644 | v[2].x = v[3].x = m->horiBearingX + m->width; | ||
| 1645 | v[0].y = v[2].y = m->horiBearingY; | ||
| 1646 | v[1].y = v[3].y = m->horiBearingY - m->height; | ||
| 1647 | for (i = 0; i < 4; i++) | ||
| 1648 | FT_Vector_Transform (v + i, flt_font_ft->matrix); | ||
| 1649 | g->lbearing = v[0].x < v[1].x ? FLOOR (v[0].x) : FLOOR (v[1].x); | ||
| 1650 | g->rbearing = v[2].x > v[3].x ? CEIL (v[2].x) : CEIL (v[3].x); | ||
| 1651 | g->ascent = v[0].y > v[2].y ? CEIL (v[0].y) : CEIL (v[2].y); | ||
| 1652 | g->descent = v[1].y < v[3].y ? - FLOOR (v[1].y) : - FLOOR (v[3].y); | ||
| 1653 | } | ||
| 1654 | else | ||
| 1655 | { | ||
| 1656 | g->lbearing = FLOOR (m->horiBearingX); | ||
| 1657 | g->rbearing = CEIL (m->horiBearingX + m->width); | ||
| 1658 | g->ascent = CEIL (m->horiBearingY); | ||
| 1659 | g->descent = - FLOOR (m->horiBearingY - m->height); | ||
| 1660 | } | ||
| 1661 | g->xadv = ROUND (ft_face->glyph->advance.x); | ||
| 1633 | } | 1662 | } |
| 1634 | else | 1663 | else |
| 1635 | { | 1664 | { |
| @@ -1989,11 +2018,12 @@ static int m17n_flt_initialized; | |||
| 1989 | extern Lisp_Object QCfamily; | 2018 | extern Lisp_Object QCfamily; |
| 1990 | 2019 | ||
| 1991 | static Lisp_Object | 2020 | static Lisp_Object |
| 1992 | ftfont_shape_by_flt (lgstring, font, ft_face, otf) | 2021 | ftfont_shape_by_flt (lgstring, font, ft_face, otf, matrix) |
| 1993 | Lisp_Object lgstring; | 2022 | Lisp_Object lgstring; |
| 1994 | struct font *font; | 2023 | struct font *font; |
| 1995 | FT_Face ft_face; | 2024 | FT_Face ft_face; |
| 1996 | OTF *otf; | 2025 | OTF *otf; |
| 2026 | FT_Matrix *matrix; | ||
| 1997 | { | 2027 | { |
| 1998 | EMACS_UINT len = LGSTRING_GLYPH_LEN (lgstring); | 2028 | EMACS_UINT len = LGSTRING_GLYPH_LEN (lgstring); |
| 1999 | EMACS_UINT i; | 2029 | EMACS_UINT i; |
| @@ -2095,6 +2125,7 @@ ftfont_shape_by_flt (lgstring, font, ft_face, otf) | |||
| 2095 | flt_font_ft.font = font; | 2125 | flt_font_ft.font = font; |
| 2096 | flt_font_ft.ft_face = ft_face; | 2126 | flt_font_ft.ft_face = ft_face; |
| 2097 | flt_font_ft.otf = otf; | 2127 | flt_font_ft.otf = otf; |
| 2128 | flt_font_ft.matrix = matrix->xx != 0 ? matrix : 0; | ||
| 2098 | if (len > 1 | 2129 | if (len > 1 |
| 2099 | && gstring.glyphs[1].c >= 0x300 && gstring.glyphs[1].c <= 0x36F) | 2130 | && gstring.glyphs[1].c >= 0x300 && gstring.glyphs[1].c <= 0x36F) |
| 2100 | /* A little bit ad hoc. Perhaps, shaper must get script and | 2131 | /* A little bit ad hoc. Perhaps, shaper must get script and |
| @@ -2166,7 +2197,8 @@ ftfont_shape (lgstring) | |||
| 2166 | otf = ftfont_get_otf (ftfont_info); | 2197 | otf = ftfont_get_otf (ftfont_info); |
| 2167 | if (! otf) | 2198 | if (! otf) |
| 2168 | return make_number (0); | 2199 | return make_number (0); |
| 2169 | return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf); | 2200 | return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf, |
| 2201 | &ftfont_info->matrix); | ||
| 2170 | } | 2202 | } |
| 2171 | 2203 | ||
| 2172 | #endif /* HAVE_M17N_FLT */ | 2204 | #endif /* HAVE_M17N_FLT */ |