From: handa Date: Thu, 20 May 2004 06:05:29 +0000 (+0000) Subject: (mfont__driver_list): Make it MPlist. X-Git-Tag: withdl~206 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=2f2346b8e2070a412162d57cd7c7c0d5448f3620;p=m17n%2Fm17n-lib.git (mfont__driver_list): Make it MPlist. (mfont__init): Adjust initialization of mfont__driver_list. (mfont__fini): Free mfont__driver_list. (mfont__set_spec_from_face): Don't set spec->property[MFONT_TYPE]. (mfont__select): Adjusted for the new mfont__driver_list. --- diff --git a/src/font.c b/src/font.c index 3ddac53..098f8d5 100644 --- a/src/font.c +++ b/src/font.c @@ -106,8 +106,8 @@ variable @c M17NDIR. See the documentation of the variable for details. - If the m17n library is configured to use the Xft librray, in - addition to #mfont_freetype_path, all fonts available via + If the m17n library is configured to use the fontconfig librray, + in addition to #mfont_freetype_path, all fonts available via fontconfig are supported. The family name of a FreeType font corresponds to the family @@ -204,7 +204,7 @@ adstyle ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢serif, sans-serif Åù¤ÎÃê¾ÝŪ¤Ê¥Õ¥©¥ó¥È¥Õ¥¡ ¥ß¥ê¡¼¤Ë´Ø¤¹¤ë¾ðÊó¤ò¼¨¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ - registry ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢iso10646, iso8895-1 ¤Î¥ì¥¸¥¹¥È¥ê¾ðÊó¤ò + registry ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢iso10646, iso8895-1 Åù¤Î¥ì¥¸¥¹¥È¥ê¾ðÊó¤ò ¼¨¤¹¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£ size ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¥Õ¥©¥ó¥È¤Î¥Ç¥¶¥¤¥ó¥µ¥¤¥º¤òɽ¤ï¤¹À°¿ôÃͤǤ¢ @@ -251,9 +251,9 @@ #mfont_freetype_path ¤Ï m17n ¥é¥¤¥Ö¥é¥ê¤ÎÀßÄê¤È´Ä¶­ÊÑ¿ô @c M17NDIR ¤Ë±þ¤¸¤Æ½é´ü²½¤µ¤ì¤ë¡£¾ÜºÙ¤ÏÊÑ¿ô¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£ - ¤â¤· m17n ¥é¥¤¥Ö¥é¥ê¤¬ Xft ¥é¥¤¥Ö¥é¥ê¤ò»È¤¦¤è¤¦¤ËÀßÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢ - #mfont_freetype_path ¤Ë²Ã¤¨¤Æ¡¢ fontconfig ¤Ç»ÈÍѲÄǽ¤Ê¥Õ¥©¥ó¥È¤â¤¹ - ¤Ù¤Æ¥µ¥Ý¡¼¥È¤µ¤ì¤ë¡£ + ¤â¤· m17n ¥é¥¤¥Ö¥é¥ê¤¬ fontconfig ¥é¥¤¥Ö¥é¥ê¤ò»È¤¦¤è¤¦¤ËÀßÄꤵ¤ì¤¿ + ¾ì¹ç¤Ë¤Ï¡¢#mfont_freetype_path ¤Ë²Ã¤¨¤Æ¡¢ fontconfig ¤Ç»ÈÍѲÄǽ¤Ê¥Õ¥© + ¥ó¥È¤â¤¹¤Ù¤Æ¥µ¥Ý¡¼¥È¤µ¤ì¤ë¡£ FreeType ¥Õ¥©¥ó¥È¤Î¥Õ¥¡¥ß¥ê̾¤Ï family ¥×¥í¥Ñ¥Æ¥£¤ËÂбþ¤¹¤ë¡£ FreeType ¥Õ¥©¥ó¥È¤Î¥¹¥¿¥¤¥ë̾¤Ï¡¢²¼¤Îɽ¤Î¤è¤¦¤Ë weight, style, @@ -293,20 +293,20 @@ 3 1 unicode-full @endverbatim - ¤·¤¿¤¬¤Ã¤Æ¡¢Æó¤Ä¤ÎÁȹ礻 (1 0) ¡¢(3 1) ¤ò»ý¤Ä¥Õ¥©¥ó¥È¤Ï¡¢¤½¤ì¤¾¤ì - registry ¥×¥í¥Ñ¥Æ¥£¤¬1-0, apple-roman, 3-1, unicode-bmp ¤Ç¤¢¤ë£´¤Ä + ¤·¤¿¤¬¤Ã¤Æ¡¢Æó¤Ä¤ÎÁȹ礻 (1 0) ¡¢(3 1) ¤ò»ý¤Ä¥Õ¥©¥ó¥È¤Ï¡¢¤½¤ì¤¾¤ì + registry ¥×¥í¥Ñ¥Æ¥£¤¬ 1-0, apple-roman, 3-1, unicode-bmp ¤Ç¤¢¤ë£´¤Ä ¤Î¥Õ¥©¥ó¥È¥ª¥Ö¥¸¥§¥¯¥È¤ËÂбþ¤¹¤ë¡£
  • OpenType ¥Õ¥©¥ó¥È - m17n ¥é¥¤¥Ö¥é¥ê¤Ï¡¢FreeType ¥é¥¤¥Ö¥é¥ê¤È OTF ¥é¥¤¥Ö¥é¥ê¤ò»ÈÍѤ¹¤ë - ¤è¤¦¤ËÀßÄꤹ¤ì¤Ð¡¢¤¹¤Ù¤Æ¤Î OpenType ¥Õ¥©¥ó¥È¤ò¥µ¥Ý¡¼¥È¤¹¤ë¡£¼ÂºÝ¤Ë - ÍøÍѤǤ­¤ë¥Õ¥©¥ó¥È¤Î¥ê¥¹¥È¤ÏFreeType ¥Õ¥©¥ó¥È¤Î¾ì¹ç¤ÈƱÍͤ˺î¤é¤ì - ¤ë¡£OpenType ¥Õ¥©¥ó¥È¤ò FLT (Font Layout Table) ·Ðͳ¤Ç»ÈÍѤ¹¤ë¤è¤¦ - ¥Õ¥©¥ó¥È¥»¥Ã¥È¤Ë»ØÄꤵ¤ì¤Æ¤ª¤ê¡¢FLT ¤Ë OTF ´ØÏ¢¤Î¥³¥Þ¥ó¥É (¤¿¤È¤¨ - ¤Ð otf:deva) ¤¬¤¢¤ì¤Ð¡¢OTF ¥é¥¤¥Ö¥é¥ê¤¬¥Õ¥©¥ó¥È¤Î OpenType ¥ì¥¤¥¢ - ¥¦¥È¥Æ¡¼¥Ö¥ë¤Ë½¾¤Ã¤Æʸ»úÎó¤ò¥°¥ê¥Õ¥³¡¼¥ÉÎó¤ËÊÑ´¹¤·¡¢FreeType ¥é¥¤ - ¥Ö¥é¥ê¤¬³Æ¥°¥ê¥Õ¤Î¥Ó¥Ã¥È¥Þ¥Ã¥×¥¤¥á¡¼¥¸¤òÄ󶡤¹¤ë¡£ + m17n ¥é¥¤¥Ö¥é¥ê¤Ï¡¢FreeType ¥é¥¤¥Ö¥é¥ê¤È OTF ¥é¥¤¥Ö¥é¥ê¤ò»ÈÍѤ¹¤ë¤è + ¤¦¤ËÀßÄꤹ¤ì¤Ð¡¢¤¹¤Ù¤Æ¤Î OpenType ¥Õ¥©¥ó¥È¤ò¥µ¥Ý¡¼¥È¤¹¤ë¡£¼ÂºÝ¤ËÍø + ÍѤǤ­¤ë¥Õ¥©¥ó¥È¤Î¥ê¥¹¥È¤Ï FreeType ¥Õ¥©¥ó¥È¤Î¾ì¹ç¤ÈƱÍͤ˺î¤é¤ì¤ë¡£ + OpenType ¥Õ¥©¥ó¥È¤ò FLT (Font Layout Table) ·Ðͳ¤Ç»ÈÍѤ¹¤ë¤è¤¦¥Õ¥© + ¥ó¥È¥»¥Ã¥È¤Ë»ØÄꤵ¤ì¤Æ¤ª¤ê¡¢FLT ¤Ë OTF ´ØÏ¢¤Î¥³¥Þ¥ó¥É (¤¿¤È¤¨¤Ð + otf:deva) ¤¬¤¢¤ì¤Ð¡¢OTF ¥é¥¤¥Ö¥é¥ê¤¬¥Õ¥©¥ó¥È¤Î OpenType ¥ì¥¤¥¢¥¦¥È + ¥Æ¡¼¥Ö¥ë¤Ë½¾¤Ã¤Æʸ»úÎó¤ò¥°¥ê¥Õ¥³¡¼¥ÉÎó¤ËÊÑ´¹¤·¡¢FreeType ¥é¥¤¥Ö¥é¥ê + ¤¬³Æ¥°¥ê¥Õ¤Î¥Ó¥Ã¥È¥Þ¥Ã¥×¥¤¥á¡¼¥¸¤òÄ󶡤¹¤ë¡£ @@ -335,7 +335,7 @@ #include "font.h" #include "face.h" -MFontDriver *mfont__driver_list[MFONT_TYPE_MAX]; +MPlist *mfont__driver_list; /** Indices to font properties sorted by their priority. */ static int font_score_priority[] = @@ -702,7 +702,7 @@ mfont__init () } } - memset (mfont__driver_list, 0, sizeof mfont__driver_list); + mfont__driver_list = mplist (); /* Here, SHIFT starts from 1, not 0. This is because the lowest bit of a score is a flag for a scalable font (see the documentation @@ -767,6 +767,8 @@ mfont__fini () free (MPLIST_VAL (plist)); M17N_OBJECT_UNREF (mfont_freetype_path); + M17N_OBJECT_UNREF (mfont__driver_list); + if (font_resize_list) { MPLIST_DO (plist, font_resize_list) @@ -858,7 +860,6 @@ mfont__set_spec_from_face (MFont *spec, MFace *face) spec->property[MFONT_REGISTRY] = 1; spec->property[MFONT_SIZE] = (int) (face->property[MFACE_SIZE]); spec->property[MFONT_RESY] = 0; - spec->property[MFONT_TYPE] = 0; } @@ -889,19 +890,18 @@ mfont__select (MFrame *frame, MFont *spec, MFont *request, int limited_size, MSymbol layouter) { MSymbol registry = FONT_PROPERTY (spec, MFONT_REGISTRY); - MPlist *realized_font_list; - MRealizedFont *best_font[MFONT_TYPE_MAX], *best; - int best_index; + MPlist *plist; + MRealizedFont *best; int i; int mdebug_mask = MDEBUG_FONT; if (registry == Mnil) registry = Mt; - MPLIST_DO (realized_font_list, frame->realized_font_list) + MPLIST_DO (plist, frame->realized_font_list) { - best = MPLIST_VAL (realized_font_list); - if (MPLIST_KEY (realized_font_list) == registry + best = MPLIST_VAL (plist); + if (MPLIST_KEY (plist) == registry && ! memcmp (&best->spec, spec, sizeof (MFont)) && ! memcmp (&best->request, request, sizeof (MFont))) { @@ -923,25 +923,21 @@ mfont__select (MFrame *frame, MFont *spec, MFont *request, int limited_size, MDEBUG_PUSH_TIME (); best = NULL; - best_index = -1; - for (i = 0; i < MFONT_TYPE_MAX; i++) - { - MFontDriver *driver = mfont__driver_list[i]; - - best_font[i] = (driver - ? (driver->select) (frame, spec, request, limited_size) - : NULL); - if (best_font[i] - && (best_index < 0 - || best_font[best_index]->score < best_font[i]->score)) - best_index = i; - } - for (i = 0; i < MFONT_TYPE_MAX; i++) + MPLIST_DO (plist, mfont__driver_list) { - if (i == best_index) - best = best_font[i]; - else if (best_font[i]) - free (best_font[i]); + MFontDriver *driver = MPLIST_VAL (plist); + MRealizedFont *this + = (driver->select) (frame, spec, request, limited_size); + + if (this + && (! best + || best->score < this->score)) + { + free (best); + best = this; + if (this->score == 0) + break; + } } if (mdebug__flag & mdebug_mask)