X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffont.h;h=54c75d1827bcf5205e256b0b3f0ca2f8b27727a9;hb=d1e2822c1e429dc953137dc8bfaa7e1cb7b95015;hp=b96e11cf2e514c3f6e9f6280d10735b72eb3e5cb;hpb=81b778b62f74aff7afc1a09312862c4a3a8e4a99;p=m17n%2Fm17n-lib.git diff --git a/src/font.h b/src/font.h index b96e11c..54c75d1 100644 --- a/src/font.h +++ b/src/font.h @@ -23,7 +23,7 @@ #ifndef _M17N_FONT_H_ #define _M17N_FONT_H_ -/** Type of font stored in MFont->property[MFONT_TYPE]. */ +/** Type of font. Now obsolete. */ enum MFontType { @@ -52,7 +52,6 @@ enum MFontProperty MFONT_REGISTRY, MFONT_SIZE, MFONT_RESY, - MFONT_TYPE, /* anchor */ MFONT_PROPERTY_MAX }; @@ -145,6 +144,12 @@ struct MRealizedFont short ascent, descent; MFontEncoding *encoding; + + /* Type of the font: Mx, Mfreetype, or Mxft. */ + MSymbol type; + + /* Pointer to the font structure. */ + void *fontp; }; /** Structure to hold a list of fonts of each registry. */ @@ -159,39 +164,41 @@ typedef struct struct MFontDriver { - /** Return a font best matching with SPEC. */ + /** Return a font satisfying REQUEST and best matching with SPEC. + For the moment, LIMITTED_SIZE is ignored. */ MRealizedFont *(*select) (MFrame *frame, MFont *spec, MFont *request, int limitted_size); /** Open a font specified by RFONT. */ int (*open) (MRealizedFont *rfont); - /** Close a font specified by RFONT. */ - void (*close) (MRealizedFont *rfont); - /** Set metrics of glyphs in GSTRING from FROM to TO. */ void (*find_metric) (MRealizedFont *rfont, MGlyphString *gstring, int from, int to); - /** Encode C into the glyph code the font. CODE is a code point of - C in rfont->encoder->encoding_charset. If the font has no glyph - for C, return MCHAR_INVALID_CODE. */ - unsigned (*encode_char) (MRealizedFont *rfont, int c, unsigned code); + /** Encode CODE into a glyph code the font. CODE is a code point of + a character in rfont->encoder->encoding_charset. If the font + has no glyph for CODE, return MCHAR_INVALID_CODE. */ + unsigned (*encode_char) (MRealizedFont *rfont, unsigned code); /** Draw glyphs from FROM to TO (exclusive) on window WIN of FRAME at coordinate (X, Y) relative to WIN. */ void (*render) (MDrawWindow win, int x, int y, MGlyphString *gstring, MGlyph *from, MGlyph *to, int reverse, MDrawRegion region); + + /** Push to PLIST fonts matching with FONT. LANGUAGE, if not Mnil, + limits fonts to ones that support LANGUAGE. MAXNUM if greater + than 0 limits the number of listed fonts. Return how many fonts + a listed. */ + int (*list) (MFrame *frame, MPlist *plist, MFont *font, MSymbol language, + int maxnum); }; /** Initialize the members of FONT. */ #define MFONT_INIT(font) memset ((font), 0, sizeof (MFont)) - -extern MFontDriver *mfont__driver_list[MFONT_TYPE_MAX]; - extern MSymbol Mlayouter; extern int mfont__flt_init (); @@ -199,16 +206,58 @@ extern int mfont__flt_init (); extern void mfont__flt_fini (); #ifdef HAVE_FREETYPE +#include +#include FT_FREETYPE_H + +#ifdef HAVE_FONTCONFIG +#include +#endif + +#ifdef HAVE_OTF +#include +#endif /* HAVE_OTF */ + +typedef struct +{ + M17NObject control; + MFont font; + char *filename; + int otf_flag; /* This font is OTF (1), may be OTF (0), is not OTF (-1). */ + MPlist *charmap_list; + int charmap_index; + FT_Face ft_face; + char *languages; +#ifdef HAVE_OTF + OTF *otf; +#endif /* HAVE_OTF */ +#ifdef HAVE_FONTCONFIG + FcLangSet *langset; +#else + void *langset; +#endif + void *extra_info; /* Xft uses this member. */ +} MFTInfo; + +extern MFontDriver mfont__ft_driver; + extern int mfont__ft_init (); extern void mfont__ft_fini (); +extern int mfont__ft_parse_name (char *name, MFont *font); + +extern char *mfont__ft_unparse_name (MFont *font); + +#ifdef HAVE_OTF + extern int mfont__ft_drive_otf (MGlyphString *gstring, int from, int to, - MRealizedFont *rfont, MSymbol script, MSymbol langsys, MSymbol gsub_features, MSymbol gpos_features); + extern int mfont__ft_decode_otf (MGlyph *g); +#endif /* HAVE_OTF */ + #endif /* HAVE_FREETYPE */ extern void mfont__free_realized (MRealizedFont *rfont); @@ -224,9 +273,6 @@ extern MSymbol mfont__set_spec_from_plist (MFont *spec, MPlist *plist); extern void mfont__resize (MFont *spec, MFont *request); -extern int mfont__encodable_p (MRealizedFont *rfont, MSymbol layouter_name, - int c); - extern unsigned mfont__encode_char (MRealizedFont *rfont, int c); extern MRealizedFont *mfont__select (MFrame *frame, MFont *spec, @@ -235,8 +281,6 @@ extern MRealizedFont *mfont__select (MFrame *frame, MFont *spec, extern int mfont__open (MRealizedFont *rfont); -extern void mfont__close (MRealizedFont *rfont); - extern void mfont__get_metric (MGlyphString *gstring, int from, int to); extern void mfont__set_property (MFont *font, enum MFontProperty key, @@ -249,6 +293,11 @@ extern void mfont__set_spec (MFont *font, MSymbol attrs[MFONT_PROPERTY_MAX], unsigned short size, unsigned short resy); +extern int mfont__parse_name_into_font (char *name, MSymbol format, + MFont *font); + +extern MPlist *mfont__encoding_list (void); + extern unsigned mfont__flt_encode_char (MSymbol layouter_name, int c); extern int mfont__flt_run (MGlyphString *gstring, int from, int to,