diff options
| author | Kenichi Handa | 2007-12-01 02:42:03 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2007-12-01 02:42:03 +0000 |
| commit | 4613015e6a9c314f0de785e5d23178cdd17ced11 (patch) | |
| tree | f3b6874812c039b0d45d9a498e70bec8e72f18fc /src | |
| parent | a9822ae8782a9313d6d287786c05df168b3676c4 (diff) | |
| download | emacs-4613015e6a9c314f0de785e5d23178cdd17ced11.tar.gz emacs-4613015e6a9c314f0de785e5d23178cdd17ced11.zip | |
Include "ftfont.h".
(struct xftfont_info) [HAVE_LIBOTF]: New members maybe_otf and
otf.
(xftfont_open) [HAVE_LIBOTF]: Initialize the above members.
(xftfont_close) [HAVE_LIBOTF]: Close otf.
(xftfont_shape) [HAVE_LIBOTF, HAVE_M17N_FLT]: New function.
(syms_of_xftfont) [HAVE_LIBOTF, HAVE_M17N_FLT]: Set
xftfont_driver.shape to xftfont_shape.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xftfont.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/xftfont.c b/src/xftfont.c index 441a4b91ba6..361c2ace83f 100644 --- a/src/xftfont.c +++ b/src/xftfont.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* xftfont.c -- XFT font driver. | 1 | /* xftfont.c -- XFT font driver. |
| 2 | Copyright (C) 2006 Free Software Foundation, Inc. | 2 | Copyright (C) 2006 Free Software Foundation, Inc. |
| 3 | Copyright (C) 2006 | 3 | Copyright (C) 2006, 2007 |
| 4 | National Institute of Advanced Industrial Science and Technology (AIST) | 4 | National Institute of Advanced Industrial Science and Technology (AIST) |
| 5 | Registration Number H13PRO009 | 5 | Registration Number H13PRO009 |
| 6 | 6 | ||
| @@ -35,6 +35,7 @@ Boston, MA 02110-1301, USA. */ | |||
| 35 | #include "charset.h" | 35 | #include "charset.h" |
| 36 | #include "fontset.h" | 36 | #include "fontset.h" |
| 37 | #include "font.h" | 37 | #include "font.h" |
| 38 | #include "ftfont.h" | ||
| 38 | 39 | ||
| 39 | /* Xft font driver. */ | 40 | /* Xft font driver. */ |
| 40 | 41 | ||
| @@ -49,7 +50,11 @@ struct xftfont_info | |||
| 49 | Display *display; | 50 | Display *display; |
| 50 | int screen; | 51 | int screen; |
| 51 | XftFont *xftfont; | 52 | XftFont *xftfont; |
| 52 | FT_Face ft_face; /* set to XftLockFace (xftfont) */ | 53 | FT_Face ft_face; /* Set to the value of XftLockFace (xftfont). */ |
| 54 | #ifdef HAVE_LIBOTF | ||
| 55 | int maybe_otf; /* Flag to tell if this may be OTF or not. */ | ||
| 56 | OTF *otf; | ||
| 57 | #endif | ||
| 53 | }; | 58 | }; |
| 54 | 59 | ||
| 55 | /* Structure pointed by (struct face *)->extra */ | 60 | /* Structure pointed by (struct face *)->extra */ |
| @@ -265,6 +270,10 @@ xftfont_open (f, entity, pixel_size) | |||
| 265 | xftfont_info->screen = FRAME_X_SCREEN_NUMBER (f); | 270 | xftfont_info->screen = FRAME_X_SCREEN_NUMBER (f); |
| 266 | xftfont_info->xftfont = xftfont; | 271 | xftfont_info->xftfont = xftfont; |
| 267 | xftfont_info->ft_face = XftLockFace (xftfont); | 272 | xftfont_info->ft_face = XftLockFace (xftfont); |
| 273 | #ifdef HAVE_LIBOTF | ||
| 274 | xftfont_info->maybe_otf = xftfont_info->ft_face->face_flags & FT_FACE_FLAG_SFNT; | ||
| 275 | xftfont_info->otf = NULL; | ||
| 276 | #endif | ||
| 268 | 277 | ||
| 269 | font = (struct font *) xftfont_info; | 278 | font = (struct font *) xftfont_info; |
| 270 | font->format = ftfont_font_format (xftfont->pattern); | 279 | font->format = ftfont_font_format (xftfont->pattern); |
| @@ -381,6 +390,10 @@ xftfont_close (f, font) | |||
| 381 | { | 390 | { |
| 382 | struct xftfont_info *xftfont_info = (struct xftfont_info *) font; | 391 | struct xftfont_info *xftfont_info = (struct xftfont_info *) font; |
| 383 | 392 | ||
| 393 | #ifdef HAVE_LIBOTF | ||
| 394 | if (xftfont_info->otf) | ||
| 395 | OTF_close (xftfont_info->otf); | ||
| 396 | #endif | ||
| 384 | XftUnlockFace (xftfont_info->xftfont); | 397 | XftUnlockFace (xftfont_info->xftfont); |
| 385 | XftFontClose (xftfont_info->display, xftfont_info->xftfont); | 398 | XftFontClose (xftfont_info->display, xftfont_info->xftfont); |
| 386 | if (font->font.name) | 399 | if (font->font.name) |
| @@ -580,6 +593,39 @@ xftfont_end_for_frame (f) | |||
| 580 | return 0; | 593 | return 0; |
| 581 | } | 594 | } |
| 582 | 595 | ||
| 596 | #ifdef HAVE_LIBOTF | ||
| 597 | #ifdef HAVE_M17N_FLT | ||
| 598 | static Lisp_Object | ||
| 599 | xftfont_shape (lgstring) | ||
| 600 | Lisp_Object lgstring; | ||
| 601 | { | ||
| 602 | struct font *font; | ||
| 603 | struct xftfont_info *xftfont_info; | ||
| 604 | |||
| 605 | CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font); | ||
| 606 | xftfont_info = (struct xftfont_info *) font; | ||
| 607 | if (! xftfont_info->maybe_otf) | ||
| 608 | return Qnil; | ||
| 609 | if (! xftfont_info->otf) | ||
| 610 | { | ||
| 611 | OTF *otf = OTF_open_ft_face (xftfont_info->ft_face); | ||
| 612 | |||
| 613 | if (! otf || OTF_get_table (otf, "head") < 0) | ||
| 614 | { | ||
| 615 | if (otf) | ||
| 616 | OTF_close (otf); | ||
| 617 | xftfont_info->maybe_otf = 0; | ||
| 618 | return 0; | ||
| 619 | } | ||
| 620 | xftfont_info->otf = otf; | ||
| 621 | } | ||
| 622 | |||
| 623 | return ftfont_shape_by_flt (lgstring, font, xftfont_info->ft_face, | ||
| 624 | xftfont_info->otf); | ||
| 625 | } | ||
| 626 | #endif /* HAVE_M17N_FLT */ | ||
| 627 | #endif /* HAVE_LIBOTF */ | ||
| 628 | |||
| 583 | void | 629 | void |
| 584 | syms_of_xftfont () | 630 | syms_of_xftfont () |
| 585 | { | 631 | { |
| @@ -599,6 +645,11 @@ syms_of_xftfont () | |||
| 599 | xftfont_driver.draw = xftfont_draw; | 645 | xftfont_driver.draw = xftfont_draw; |
| 600 | xftfont_driver.anchor_point = xftfont_anchor_point; | 646 | xftfont_driver.anchor_point = xftfont_anchor_point; |
| 601 | xftfont_driver.end_for_frame = xftfont_end_for_frame; | 647 | xftfont_driver.end_for_frame = xftfont_end_for_frame; |
| 648 | #ifdef HAVE_LIBOTF | ||
| 649 | #ifdef HAVE_M17N_FLT | ||
| 650 | xftfont_driver.shape = xftfont_shape; | ||
| 651 | #endif /* HAVE_M17N_FLT */ | ||
| 652 | #endif /* HAVE_LIBOTF */ | ||
| 602 | 653 | ||
| 603 | register_font_driver (&xftfont_driver, NULL); | 654 | register_font_driver (&xftfont_driver, NULL); |
| 604 | } | 655 | } |