1 /* font.h -- header file for the font module.
2 Copyright (C) 2003, 2004
3 National Institute of Advanced Industrial Science and Technology (AIST)
4 Registration Number H15PRO112
6 This file is part of the m17n library.
8 The m17n library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public License
10 as published by the Free Software Foundation; either version 2.1 of
11 the License, or (at your option) any later version.
13 The m17n library 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 GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with the m17n library; if not, write to the Free
20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 /** Type of font. Now obsolete. */
30 /** Fonts supproted by a window system natively. On X Window
31 System, it is an X font. */
34 /** Fonts supported by FreeType library. */
44 /* The order of MFONT_FOUNDRY to MFONT_ADSTYLE must be the same as
45 enum MFaceProperty. */
59 /** Information about a font. This structure is used in three ways:
60 FONT-OBJ, FONT-OPENED, and FONT-SPEC.
62 FONT-OBJ: To store information of an existing font. Instances
63 appear only in <font_list> of MDisplay.
65 FONT-OPENED: To store information of an opened font. Instances
66 appear only in <opend_list> of MDisplay.
68 FONT-SPEC: To store specifications of a font. Instances appear
69 only in <spec_list> of MFontset. */
73 /** Numeric value of each font property. Also used as an index to
74 the table @c mfont__property_table to get the actual name of the
77 For FONT-OBJ, FONT-OPENED: The value is greater than zero.
79 For FONT-SPEC: The value is equal to or greater than zero. Zero
80 means that the correponding property is not specified (i.e. wild
83 <property>[MFONT_SIZE] is the size of the font in 1/10 pixels.
85 For FONT-OBJ: If the value is 0, the font is scalable or
88 For FONT-OPENED: The actual size of opened font.
90 <prperty>[MFONT_RESY] is the designed resolution of the font in
91 DPI, or zero. Zero means that the font is scalable.
93 For the time being, we mention only Y-resolution (resy) and
94 assume that resx is always equal to resy. */
95 unsigned short property[MFONT_PROPERTY_MAX];
103 } MFontPropertyTable;
105 extern MFontPropertyTable mfont__property_table[MFONT_REGISTRY + 1];
107 /** Return the symbol of the Nth font property of FONT. */
108 #define FONT_PROPERTY(font, n) \
109 mfont__property_table[(n)].names[(font)->property[(n)]]
111 typedef struct MFontEncoding MFontEncoding;
115 /* Frame on which the font is realized. */
118 /* Font spec used to find the font. */
121 /* Font spec requested by a face. */
124 /* The found font. */
127 /* How well <font> matches with <request>. */
132 /* Font Layout Table for the font. */
135 /* 0: not yet tried to open
137 1: succeessfully opened. */
140 /* Extra information set by <driver>->select or <driver>->open. If
141 non-NULL, it must be a pointer to a managed object. */
144 short ascent, descent;
146 MFontEncoding *encoding;
149 /** Structure to hold a list of fonts of each registry. */
161 /** Return a font satisfying REQUEST and best matching with SPEC.
162 For the moment, LIMITTED_SIZE is ignored. */
163 MRealizedFont *(*select) (MFrame *frame, MFont *spec, MFont *request,
166 /** Open a font specified by RFONT. */
167 int (*open) (MRealizedFont *rfont);
169 /** Set metrics of glyphs in GSTRING from FROM to TO. */
170 void (*find_metric) (MRealizedFont *rfont, MGlyphString *gstring,
173 /** Encode C into the glyph code the font. CODE is a code point of
174 C in rfont->encoder->encoding_charset. If the font has no glyph
175 for C, return MCHAR_INVALID_CODE. */
176 unsigned (*encode_char) (MRealizedFont *rfont, int c, unsigned code);
178 /** Draw glyphs from FROM to TO (exclusive) on window WIN of FRAME
179 at coordinate (X, Y) relative to WIN. */
180 void (*render) (MDrawWindow win, int x, int y,
181 MGlyphString *gstring, MGlyph *from, MGlyph *to,
182 int reverse, MDrawRegion region);
184 MFont *(*parse_name) (char *name, MFont *font);
185 char *(*build_name) (MFont *font);
188 /** Initialize the members of FONT. */
190 #define MFONT_INIT(font) memset ((font), 0, sizeof (MFont))
192 extern MSymbol Mlayouter;
194 extern int mfont__flt_init ();
196 extern void mfont__flt_fini ();
199 #include <ft2build.h>
200 #include FT_FREETYPE_H
204 #endif /* HAVE_OTF */
211 int otf_flag; /* This font is OTF (1), may be OTF (0), is not OTF (-1). */
212 MPlist *charmap_list;
217 #endif /* HAVE_OTF */
218 void *extra_info; /* Xft uses this member. */
221 extern MFontDriver mfont__ft_driver;
223 extern int mfont__ft_init ();
225 extern void mfont__ft_fini ();
227 extern int mfont__ft_drive_otf (MGlyphString *gstring, int from, int to,
228 MRealizedFont *rfont,
229 MSymbol script, MSymbol langsys,
230 MSymbol gsub_features, MSymbol gpos_features);
231 extern int mfont__ft_decode_otf (MGlyph *g);
233 #endif /* HAVE_FREETYPE */
235 extern void mfont__free_realized (MRealizedFont *rfont);
237 extern int mfont__match_p (MFont *font, MFont *spec, int prop);
239 extern int mfont__score (MFont *font, MFont *spec, MFont *request,
242 extern void mfont__set_spec_from_face (MFont *spec, MFace *face);
244 extern MSymbol mfont__set_spec_from_plist (MFont *spec, MPlist *plist);
246 extern void mfont__resize (MFont *spec, MFont *request);
248 extern int mfont__encodable_p (MRealizedFont *rfont, MSymbol layouter_name,
251 extern unsigned mfont__encode_char (MRealizedFont *rfont, int c);
253 extern MRealizedFont *mfont__select (MFrame *frame, MFont *spec,
254 MFont *request, int limitted_size,
257 extern int mfont__open (MRealizedFont *rfont);
259 extern void mfont__get_metric (MGlyphString *gstring, int from, int to);
261 extern void mfont__set_property (MFont *font, enum MFontProperty key,
264 extern int mfont__split_name (char *name, int *property_idx,
265 unsigned short *point, unsigned short *resy);
267 extern void mfont__set_spec (MFont *font,
268 MSymbol attrs[MFONT_PROPERTY_MAX],
269 unsigned short size, unsigned short resy);
271 extern unsigned mfont__flt_encode_char (MSymbol layouter_name, int c);
273 extern int mfont__flt_run (MGlyphString *gstring, int from, int to,
274 MRealizedFace *rface);
276 #endif /* _M17N_FONT_H_ */