1 /* ftfont.h -- Interface definition for Freetype font backend.
2 Copyright (C) 2007, 2008, 2009, 2010, 2011
3 National Institute of Advanced Industrial Science and Technology (AIST)
4 Registration Number H13PRO009
5
6 This file is part of GNU Emacs.
7
8 GNU Emacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or (at
11 your option) any later version.
12
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
20
21
22 #ifndef EMACS_FTFONT_H
23 #define EMACS_FTFONT_H
24
25 #include <ft2build.h>
26 #include FT_FREETYPE_H
27 #include FT_SIZES_H
28 #include FT_TRUETYPE_TABLES_H
29 #ifdef FT_BDF_H
30 # include FT_BDF_H
31 #endif
32
33 #ifdef USE_BE_CAIRO
34 #include <cairo.h>
35 #endif
36
37 #ifdef HAVE_HARFBUZZ
38 #include <hb.h>
39 #include <hb-ft.h>
40 #endif /* HAVE_HARFBUZZ */
41
42 #ifdef HAVE_LIBOTF
43 # include <otf.h>
44 #ifdef HAVE_M17N_FLT
45 # include <m17n-flt.h>
46 #endif /* HAVE_M17N_FLT */
47 #endif /* HAVE_LIBOTF */
48
49 extern void ftfont_fix_match (FcPattern *, FcPattern *);
50 extern void ftfont_add_rendering_parameters (FcPattern *, Lisp_Object);
51 extern FcPattern *ftfont_entity_pattern (Lisp_Object, int);
52
53 /* This struct is shared by the XFT, Freetype, and Cairo font
54 backends. Members up to and including 'matrix' are common, the
55 rest depend on which backend is in use. */
56 struct font_info
57 {
58 struct font font;
59 #ifdef HAVE_LIBOTF
60 bool maybe_otf; /* Flag to tell if this may be OTF or not. */
61 OTF *otf;
62 #endif /* HAVE_LIBOTF */
63 FT_Size ft_size;
64 int index;
65 FT_Matrix matrix;
66 #ifdef HAVE_HARFBUZZ
67 hb_font_t *hb_font;
68 #endif /* HAVE_HARFBUZZ */
69
70 #if defined (USE_CAIRO) || defined (USE_BE_CAIRO)
71 cairo_scaled_font_t *cr_scaled_font;
72 /* Scale factor from the bitmap strike metrics in 1/64 pixels, used
73 as the hb_position_t value in HarfBuzz, to those in (scaled)
74 pixels. The value is 0 for scalable fonts. */
75 double bitmap_position_unit;
76 /* Font metrics cache. */
77 struct font_metrics **metrics;
78 short metrics_nrows;
79 #else
80 /* These are used by the XFT backend. */
81 Display *display;
82 XftFont *xftfont;
83 unsigned x_display_id;
84 #endif
85 };
86
87 #if defined USE_CAIRO && defined HAVE_X_WINDOWS
88
89 extern void ftcrfont_get_default_font_options (struct x_display_info *,
90 cairo_font_options_t *);
91
92 #endif /* USE_CAIRO && HAVE_X_WINDOWS */
93
94 #endif /* EMACS_FTFONT_H */