1 /* fontset.c -- fontset 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
24 @addtogroup m17nFontset
25 @brief A fontset is an object that maps a character to fonts.
27 A @e fontset is an object of the type @c MFontset. When drawing an
28 M-text, a fontset provides rules to select a font for each
29 character in the M-text according to the following information.
31 - The script character property of a character.
32 - The language text property of a character.
33 - The charset text property of a character.
35 The documentation of mdraw_text () describes how that information is
39 @addtogroup m17nFontset
40 @brief ¥Õ¥©¥ó¥È¥»¥Ã¥È¤Ï°ìÄê¤Î¥¹¥¿¥¤¥ë¤ò¶¦Í¤¹¤ë¥Õ¥©¥ó¥È¤Î½¸¹ç¤Ç¤¢¤ë
42 @e ¥Õ¥©¥ó¥È¥»¥Ã¥È ¤Ï @c MFontset ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ê¡¢Â¿¸À¸ìʸ
43 ½ñ¤Îɽ¼¨¤ÎºÝ¡¢¸«¤«¤±¤Î»÷¤¿¥Õ¥©¥ó¥È¤ò½¸¤á¤Æ°ì´Ó¤·¤Æ¼è¤ê°·¤¦¤¿¤á¤Ë»È
44 ¤ï¤ì¤ë¡£¥Õ¥©¥ó¥È¥»¥Ã¥È¤Ï¤Þ¤¿¡¢¸À¸ì¡¢Ê¸»ú¥»¥Ã¥È¡¢Ê¸»ú¤¬Í¿¤¨¤é¤ì¤¿¤È
45 ¤¤ËŬÀڤʥե©¥ó¥È¤òÁªÂò¤¹¤ë¤¿¤á¤Î¾ðÊó¤âÊÝ»ý¤·¤Æ¤¤¤ë¡£ */
49 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
50 /*** @addtogroup m17nInternal
59 #include "m17n-misc.h"
63 #include "character.h"
65 #include "internal-gui.h"
73 /* Name of the fontset. */
76 /* Initialized to 0, and incremented by one each time the fontset is
80 /* Database from which to load the contents of the fontset. Once
81 loaded, this member is set to NULL. */
84 /* SCRIPT vs PER-LANGUAGE (which is a plist LANGUAGE vs FONT-GROUP) */
87 /* CHARSET vs FONT-GROUP */
93 /* Plist of Mt vs font specs. */
94 MPlist *font_spec_list;
97 static MFontset *default_fontset;
99 static MPlist *fontset_list;
101 struct MRealizedFontset
103 /* Fontset from which the realized fontset is realized. */
106 /* Initialized to <fontset>->tick. */
109 /* Font spec extracted from a face. */
112 /* The frame on which the realized fontset is realized. */
124 load_font_group (MPlist *plist, MPlist *elt, MPlist *spec_list)
128 /* ELT ::= ( FONT-SPEC-LIST [ LAYOUTER ] ) ... */
130 MFont font, *spec = NULL;
131 MSymbol layouter_name;
133 if (! MPLIST_PLIST_P (elt))
134 MWARNING (MERROR_FONTSET);
135 elt2 = MPLIST_PLIST (elt);
136 if (! MPLIST_PLIST_P (elt2))
137 MWARNING (MERROR_FONTSET);
138 mfont__set_spec_from_plist (&font, MPLIST_PLIST (elt2));
139 MPLIST_DO (p, spec_list)
141 if (! memcmp (MPLIST_VAL (p), &font, sizeof (MFont)))
143 spec = MPLIST_VAL (p);
149 MSTRUCT_MALLOC (spec, MERROR_FONTSET);
151 mplist_add (spec_list, Mt, spec);
153 elt2 = MPLIST_NEXT (elt2);
155 if (MPLIST_SYMBOL_P (elt2))
156 layouter_name = MPLIST_SYMBOL (elt2);
157 if (layouter_name == Mnil)
159 plist = mplist_add (plist, layouter_name, spec);
162 /* ANSI-C requires some statement after a label. */
168 /* Load FONTSET->per_script from the data in FONTSET->mdb. */
171 load_fontset_contents (MFontset *fontset)
173 MPlist *per_script, *per_charset, *fallback, *spec_list, *font_group;
174 MSymbol script, lang;
175 MPlist *fontset_def, *plist;
177 fontset->per_script = per_script = mplist ();
178 fontset->per_charset = per_charset = mplist ();
179 fontset->fallback = fallback = mplist ();
180 fontset->font_spec_list = spec_list = mplist ();
181 if (! (fontset_def = (MPlist *) mdatabase_load (fontset->mdb)))
184 MPLIST_DO (plist, fontset_def)
186 /* PLIST ::= ( SCRIPT ( LANGUAGE FONT-SPEC-ELT ... ) ... )
187 | (CHARSET FONT-SPEC-ELT ...)
191 if (! MPLIST_PLIST_P (plist))
192 MWARNING (MERROR_FONTSET);
193 elt = MPLIST_PLIST (plist);
194 if (! MPLIST_SYMBOL_P (elt))
195 MWARNING (MERROR_FONTSET);
196 script = MPLIST_SYMBOL (elt);
197 elt = MPLIST_NEXT (elt);
198 if (! MPLIST_PLIST_P (elt))
199 MWARNING (MERROR_FONTSET);
201 fallback = load_font_group (fallback, elt, spec_list);
202 else if (MPLIST_PLIST_P (MPLIST_PLIST (elt)))
204 font_group = mplist_find_by_key (fontset->per_charset, script);
207 font_group = mplist ();
208 per_charset = mplist_add (per_charset, script, font_group);
210 load_font_group (font_group, elt, spec_list);
214 MPlist *per_lang = mplist_find_by_key (fontset->per_script, script);
218 per_lang = mplist ();
219 per_script = mplist_add (per_script, script, per_lang);
224 /* ELT ::= ( LANGUAGE FONT-DEF ...) ... */
227 if (! MPLIST_PLIST_P (elt))
228 MWARNING (MERROR_FONTSET);
229 elt2 = MPLIST_PLIST (elt);
230 if (! MPLIST_SYMBOL_P (elt2))
231 MWARNING (MERROR_FONTSET);
232 lang = MPLIST_SYMBOL (elt2);
235 font_group = mplist_find_by_key (per_lang, lang);
238 font_group = mplist ();
239 mplist_add (per_lang, lang, font_group);
241 elt2 = MPLIST_NEXT (elt2);
242 load_font_group (font_group, elt2, spec_list);
248 /* ANSI-C requires some statement after a label. */
252 M17N_OBJECT_UNREF (fontset_def);
257 free_fontset (void *object)
259 MFontset *fontset = (MFontset *) object;
260 MPlist *plist, *pl, *p;
262 if (fontset->per_script)
264 MPLIST_DO (plist, fontset->per_script)
266 MPLIST_DO (pl, MPLIST_PLIST (plist))
268 p = MPLIST_PLIST (pl);
269 M17N_OBJECT_UNREF (p);
271 pl = MPLIST_PLIST (plist);
272 M17N_OBJECT_UNREF (pl);
274 M17N_OBJECT_UNREF (fontset->per_script);
276 if (fontset->per_charset)
278 MPLIST_DO (plist, fontset->per_charset)
280 pl = MPLIST_PLIST (plist);
281 M17N_OBJECT_UNREF (pl);
283 M17N_OBJECT_UNREF (fontset->per_charset);
285 if (fontset->fallback)
286 M17N_OBJECT_UNREF (fontset->fallback);
287 plist = mplist_find_by_key (fontset_list, fontset->name);
291 if (fontset->font_spec_list)
293 if (((M17NObject *) (fontset->font_spec_list))->ref_count == 1)
294 MPLIST_DO (plist, fontset->font_spec_list)
295 free (MPLIST_VAL (plist));
296 M17N_OBJECT_UNREF (fontset->font_spec_list);
302 realize_font_group (MFrame *frame, MFont *request, MPlist *font_group,
305 MPlist *plist = MPLIST_VAL (font_group), *pl, *p;
307 mplist_set (font_group, Mnil, NULL);
308 MPLIST_DO (pl, plist)
310 MRealizedFont *rfont = mfont__select (frame, MPLIST_VAL (pl), request,
315 rfont->layouter = MPLIST_KEY (pl);
316 if (rfont->layouter == Mt)
317 rfont->layouter = Mnil;
318 MPLIST_DO (p, font_group)
319 if (((MRealizedFont *) (MPLIST_VAL (p)))->score > rfont->score)
321 mplist_push (p, Mt, rfont);
327 check_fontset_element (MFrame *frame, MPlist *element, MGlyph *g, int size)
329 MRealizedFont *rfont = (MRealizedFont *) MPLIST_VAL (element);
332 /* We have already failed to select this font. */
336 rfont = mfont__select (frame, &rfont->spec, &rfont->request, size);
337 free (MPLIST_VAL (element));
338 MPLIST_VAL (element) = rfont;
340 /* No font matches this spec. */
344 g->code = mfont__encode_char (rfont, g->c);
345 return (g->code != MCHAR_INVALID_CODE);
353 mfont__fontset_init ()
355 Mfontset = msymbol ("fontset");
356 Mfontset->managing_key = 1;
357 fontset_list = mplist ();
358 default_fontset = mfontset ("default");
359 if (! default_fontset->mdb)
364 mfont_put_prop (&font, Mregistry, msymbol ("iso8859-1"));
365 mfontset_modify_entry (default_fontset, Mnil, Mnil, Mnil,
367 mfont_put_prop (&font, Mregistry, msymbol ("iso10646-1"));
368 mfontset_modify_entry (default_fontset, Mnil, Mnil, Mnil,
376 mfont__fontset_fini ()
378 while (! MPLIST_TAIL_P (fontset_list))
379 free_fontset ((MFontset *) MPLIST_VAL (fontset_list));
380 M17N_OBJECT_UNREF (fontset_list);
386 mfont__realize_fontset (MFrame *frame, MFontset *fontset, MFace *face)
388 MRealizedFontset *realized;
390 MPlist *per_script, *per_lang, *per_charset, *font_group;
391 MPlist *plist, *pl, *p;
394 load_fontset_contents (fontset);
396 mfont__set_spec_from_face (&request, face);
397 if (request.property[MFONT_SIZE] <= 0)
400 request.property[MFONT_SIZE] = 120;
402 MPLIST_DO (p, frame->realized_fontset_list)
404 realized = (MRealizedFontset *) MPLIST_VAL (p);
405 if (fontset->name == MPLIST_KEY (p)
406 && ! memcmp (&request, &realized->spec, sizeof (request)))
410 MSTRUCT_MALLOC (realized, MERROR_FONTSET);
411 realized->fontset = fontset;
412 realized->tick = fontset->tick;
413 realized->spec = request;
414 realized->frame = frame;
415 realized->per_script = per_script = mplist ();
416 MPLIST_DO (plist, fontset->per_script)
418 per_lang = mplist ();
419 per_script = mplist_add (per_script, MPLIST_KEY (plist), per_lang);
420 MPLIST_DO (pl, MPLIST_PLIST (plist))
422 font_group = mplist ();
423 mplist_add (font_group, Mplist, MPLIST_VAL (pl));
424 per_lang = mplist_add (per_lang, MPLIST_KEY (pl), font_group);
428 realized->per_charset = per_charset = mplist ();
429 MPLIST_DO (plist, fontset->per_charset)
431 font_group = mplist ();
432 mplist_add (font_group, Mplist, MPLIST_VAL (plist));
433 per_charset = mplist_add (per_charset, MPLIST_KEY (plist), font_group);
436 realized->fallback = mplist ();
437 mplist_add (realized->fallback, Mplist, fontset->fallback);
439 mplist_add (frame->realized_fontset_list, fontset->name, realized);
445 mfont__free_realized_fontset (MRealizedFontset *realized)
447 MPlist *plist, *pl, *p;
448 MRealizedFont *rfont;
450 if (realized->per_script)
452 MPLIST_DO (plist, realized->per_script)
454 MPLIST_DO (pl, MPLIST_PLIST (plist))
456 MPLIST_DO (p, MPLIST_PLIST (pl))
457 if ((rfont = MPLIST_VAL (p)) && ! rfont->frame)
459 p = MPLIST_PLIST (pl);
460 M17N_OBJECT_UNREF (p);
462 pl = MPLIST_PLIST (plist);
463 M17N_OBJECT_UNREF (pl);
465 M17N_OBJECT_UNREF (realized->per_script);
467 if (realized->per_charset)
469 MPLIST_DO (plist, realized->per_charset)
471 MPLIST_DO (pl, MPLIST_PLIST (plist))
472 if ((rfont = MPLIST_VAL (pl)) && ! rfont->frame)
474 pl = MPLIST_PLIST (plist);
475 M17N_OBJECT_UNREF (pl);
477 M17N_OBJECT_UNREF (realized->per_charset);
479 if (realized->fallback)
481 MPLIST_DO (plist, realized->fallback)
482 if ((rfont = MPLIST_VAL (plist)) && ! rfont->frame)
484 M17N_OBJECT_UNREF (realized->fallback);
492 mfont__lookup_fontset (MRealizedFontset *realized, MGlyph *g, int *num,
493 MSymbol script, MSymbol language, MSymbol charset,
496 MFrame *frame = realized->frame;
497 MCharset *preferred_charset = (charset == Mnil ? NULL : MCHARSET (charset));
498 MPlist *per_charset, *per_script, *per_lang, *font_group;
499 MPlist *font_groups[256], *plist;
500 int n_font_group = 0;
501 MRealizedFont *first = NULL, *rfont;
505 if (preferred_charset
506 && (per_charset = mplist_get (realized->per_charset, charset)) != NULL)
507 font_groups[n_font_group++] = per_charset;
509 && ((per_script = mplist_find_by_key (realized->per_script, script))
512 /* The first loop is for matching language (if any), and the second
513 loop is for non-matching languages. */
514 if (language == Mnil)
516 for (i = 0; i < 2; i++)
518 MPLIST_DO (per_lang, MPLIST_PLIST (per_script))
519 if ((MPLIST_KEY (per_lang) == language) != i)
520 font_groups[n_font_group++] = MPLIST_PLIST (per_lang);
523 font_groups[n_font_group++] = realized->fallback;
525 if (n_font_group == 1)
527 /* As we only have a fallback font group, try all the other
529 MPLIST_DO (per_script, realized->per_script)
530 MPLIST_DO (per_lang, MPLIST_PLIST (per_script))
531 font_groups[n_font_group++] = MPLIST_PLIST (per_lang);
532 MPLIST_DO (per_charset, realized->per_charset)
533 font_groups[n_font_group++] = MPLIST_PLIST (per_charset);
536 for (i = 0; i < n_font_group; i++)
540 if (MPLIST_PLIST_P (font_groups[i]))
541 realize_font_group (frame, &realized->spec, font_groups[i], size);
543 MPLIST_DO (plist, font_groups[i])
545 rfont = (MRealizedFont *) MPLIST_VAL (plist);
546 g->code = mfont__encode_char (rfont, g->c);
547 if (g->code != MCHAR_INVALID_CODE)
550 if (MPLIST_TAIL_P (plist))
552 for (j = 1; j < *num; j++)
554 g[j].code = mfont__encode_char (rfont, g[j].c);
555 if (g[j].code == MCHAR_INVALID_CODE)
559 first = rfont, first_len = j;
561 /* We found a font that can display all requested
565 MPLIST_DO (plist, MPLIST_NEXT (plist))
567 rfont = (MRealizedFont *) MPLIST_VAL (plist);
568 for (j = 0; j < *num; j++)
570 g[j].code = mfont__encode_char (rfont, g[j].c);
571 if (g[j].code == MCHAR_INVALID_CODE)
577 if (! MPLIST_TAIL_P (plist))
581 if (i == n_font_group)
585 rfont = first, *num = first_len;
586 for (i = 0; i < *num; i++)
587 g[i].code = mfont__encode_char (rfont, g[i].c);
590 && mfont__open (rfont) < 0)
592 MPLIST_VAL (font_group) = NULL;
599 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
604 /*** @addtogroup m17nFontset */
609 @brief Return a fontset.
611 The mfontset () function returns a pointer to a fontset object of
612 name $NAME. If $NAME is @c NULL, it returns a pointer to the
615 If no fontset has the name $NAME, a new one is created. At that
616 time, if there exists a data \<@c fontset, $NAME\> in the m17n
617 database, the fontset contents are initialized according to the
618 data. If no such data exists, the fontset contents are left
621 The macro M17N_INIT () creates the default fontset. An
622 application program can modify it before the first call of mframe
626 This function returns a pointer to the found or newly created
630 mfontset (char *name)
636 return default_fontset;
637 sym = msymbol (name);
638 fontset = mplist_get (fontset_list, sym);
641 M17N_OBJECT (fontset, free_fontset, MERROR_FONTSET);
643 fontset->mdb = mdatabase_find (Mfontset, sym, Mnil, Mnil);
646 fontset->per_script = mplist ();
647 fontset->per_charset = mplist ();
648 fontset->fallback = mplist ();
650 mplist_put (fontset_list, sym, fontset);
651 M17N_OBJECT_REF (fontset);
658 @brief Return the name of a fontset
660 The mfontset_name () function returns the name of $FONTSET. */
662 mfontset_name (MFontset *fontset)
664 return fontset->name;
670 @brief Make a copy a fontset
672 The mfontset_copy () function makes a copy of $FONTSET, gives it a
673 name $NAME, and returns a pointer to the created copy. $NAME must
674 not be a name of existing fontset. Otherwise, this function
675 returns NULL without making a copy. */
678 mfontset_copy (MFontset *fontset, char *name)
680 MSymbol sym = msymbol (name);
681 MFontset *copy = mplist_get (fontset_list, sym);
686 M17N_OBJECT (copy, free_fontset, MERROR_FONTSET);
689 if (fontset->per_script)
691 copy->per_script = mplist ();
692 MPLIST_DO (plist, fontset->per_script)
694 MPlist *new = mplist ();
696 MPLIST_DO (pl, MPLIST_PLIST (plist))
697 mplist_add (new, MPLIST_KEY (pl), mplist_copy (MPLIST_PLIST (pl)));
698 mplist_add (copy->per_script, MPLIST_KEY (plist), new);
701 if (fontset->per_charset)
703 copy->per_charset = mplist ();
704 MPLIST_DO (plist, fontset->per_charset)
705 mplist_add (copy->per_charset, MPLIST_KEY (plist),
706 mplist_copy (MPLIST_PLIST (plist)));
708 if (fontset->fallback)
709 copy->fallback = mplist_copy (fontset->fallback);
711 copy->font_spec_list = fontset->font_spec_list;
712 M17N_OBJECT_REF (copy->font_spec_list);
714 mplist_put (fontset_list, sym, copy);
715 M17N_OBJECT_REF (copy);
722 @brief Modify the contents of a fontset.
724 The mfontset_modify_entry () function associates, in $FONTSET, a
725 copy of $FONT with the $SCRIPT / $LANGUAGE pair or with $CHARSET.
727 Each font in a fontset is associated with a particular
728 script/language pair, with a particular charset, or with the
729 symbol @c Mnil. The fonts that are associated with the same item
732 If $SCRIPT is not @c Mnil, it must be a symbol identifying a
733 script. In this case, $LANGUAGE is either a symbol identifying a
734 language or @c Mnil, and $FONT is associated with the $SCRIPT /
737 If $CHARSET is not @c Mnil, it must be a symbol representing a
738 charset object. In this case, $FONT is associated with that
741 If both $SCRIPT and $CHARSET are not @c Mnil, two copies of $FONT
742 are created. Then one is associated with the script/language pair
743 and the other with the charset.
745 If both $SCRIPT and $CHARSET are @c Mnil, $FONT is associated
746 with @c Mnil. This kind of fonts are called <i>fallback
749 The argument $HOW specifies the priority of $FONT. If $HOW is
750 positive, $FONT has the highest priority in the group of fonts
751 that are associated with the same item. If $HOW is negative,
752 $FONT has the lowest priority. If $HOW is zero, $FONT becomes the
753 only available font for the associated item; all the other fonts
754 are removed from the group.
756 If $LAYOUTER_NAME is not @c Mnil, it must be a symbol
757 representing a @ref flt. In that case, if $FONT is selected for
758 drawing an M-text, that font layout table is used to generate a
759 glyph code sequence from a character sequence.
762 If the operation was successful, mfontset_modify_entry () returns 0.
763 Otherwise it returns -1 and assigns an error code to the external
764 variable @c merror_code. */
767 @brief ¸À¸ì¤È¥¹¥¯¥ê¥×¥È¤ÎÁȤ߹ç¤ï¤»¤Ë¥Õ¥©¥ó¥È¤ò´ØÏ¢ÉÕ¤±¤ë
769 ´Ø¿ô mfontset_set_language_script () ¤Ï¡¢$LANGUAGE ¤È $SCRIPT ¤ÎÁÈ
770 ¤ß¹ç¤ï¤»¤ËÂФ·¤Æ¥Õ¥©¥ó¥È $FONT ¤ò»È¤¦¤è¤¦¡¢¥Õ¥©¥ó¥È¥»¥Ã¥È $FONTSET
771 ¤òÀßÄꤹ¤ë¡£$LANGUAGE ¤È $SCRIPT ¤Ï¡¢¤½¤ì¤¾¤ì¸À¸ì¤È¥¹¥¯¥ê¥×¥È¤ò»Ø
772 Äꤹ¤ë¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
774 ¸À¸ì¤È¥¹¥¯¥ê¥×¥È¤ÎÁȤ߹ç¤ï¤»°ì¤Ä¤ËÂФ·¤ÆÊ£¿ô¤Î¥Õ¥©¥ó¥È¤òÀßÄꤹ¤ë¤³
775 ¤È¤â¤Ç¤¤ë¡£$PREPEND_P ¤¬ 0 °Ê³°¤Ê¤é¤Ð¡¢$FONT ¤Ï¤½¤ÎÁȤ߹ç¤ï¤»¤ËÂÐ
776 ¤·¤ÆºÇÍ¥Àè¤ÇÍѤ¤¤é¤ì¤ë¤â¤Î¤È¤Ê¤ë¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢Í¥ÀèÅÙºÇÄã¤Î¥Õ¥©
777 ¥ó¥È¤È¤·¤ÆÅÐÏ¿¤µ¤ì¤ë¡£
780 ½èÍý¤¬À®¸ù¤·¤¿¤È¤¡¢mfontset_set_language_script () ¤Ï 0 ¤òÊÖ¤¹¡£
781 ¼ºÇÔ¤·¤¿¤È¤¤Ï -1 ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô @c merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤ò
789 mfontset_modify_entry (MFontset *fontset,
790 MSymbol script, MSymbol language, MSymbol charset,
791 MFont *spec, MSymbol layouter_name,
794 MPlist *per_lang, *plist[3], *pl;
799 load_fontset_contents (fontset);
801 MPLIST_DO (pl, fontset->font_spec_list)
803 if (! memcmp (MPLIST_VAL (pl), spec, sizeof (MFont)))
805 font = MPLIST_VAL (pl);
813 mplist_add (fontset->font_spec_list, Mt, font);
819 if (language == Mnil)
821 per_lang = mplist_get (fontset->per_script, script);
823 mplist_add (fontset->per_script, script, per_lang = mplist ());
824 plist[i] = mplist_get (per_lang, language);
826 mplist_add (per_lang, language, plist[i] = mplist ());
831 plist[i] = mplist_get (fontset->per_charset, charset);
833 mplist_add (fontset->per_charset, charset, plist[i] = mplist ());
836 if (script == Mnil && charset == Mnil)
838 plist[i++] = fontset->fallback;
841 if (layouter_name == Mnil)
843 for (i--; i >= 0; i--)
846 mplist_push (plist[i], layouter_name, font);
848 mplist_add (plist[i], layouter_name, font);
851 mplist_set (plist[i], Mnil, NULL);
852 mplist_add (plist[i], layouter_name, font);
861 /*** @addtogroup m17nDebug */
866 @brief Dump a fontset
868 The mdebug_dump_fontset () function prints $FONTSET in a human readable
869 way to the stderr. $INDENT specifies how many columns to indent
870 the lines but the first one.
873 This function returns $FONTSET. */
876 mdebug_dump_fontset (MFontset *fontset, int indent)
878 char *prefix = (char *) alloca (indent + 1);
879 MPlist *plist, *pl, *p;
881 memset (prefix, 32, indent);
884 fprintf (stderr, "(fontset %s", fontset->name->name);
885 if (fontset->per_script)
886 MPLIST_DO (plist, fontset->per_script)
888 fprintf (stderr, "\n %s(%s", prefix, MPLIST_KEY (plist)->name);
889 MPLIST_DO (pl, MPLIST_PLIST (plist))
891 fprintf (stderr, "\n %s(%s", prefix, MPLIST_KEY (pl)->name);
892 MPLIST_DO (p, MPLIST_PLIST (pl))
894 fprintf (stderr, "\n %s(%s ", prefix,
895 MPLIST_KEY (p)->name);
896 mdebug_dump_font (MPLIST_VAL (p));
897 fprintf (stderr, ")");
899 fprintf (stderr, ")");
901 fprintf (stderr, ")");
903 if (fontset->per_charset)
904 MPLIST_DO (pl, fontset->per_charset)
906 fprintf (stderr, "\n %s(%s", prefix, MPLIST_KEY (pl)->name);
907 MPLIST_DO (p, MPLIST_PLIST (pl))
909 fprintf (stderr, "\n %s(%s ", prefix, MPLIST_KEY (p)->name);
910 mdebug_dump_font (MPLIST_VAL (p));
911 fprintf (stderr, ")");
913 fprintf (stderr, ")");
916 if (fontset->fallback)
917 MPLIST_DO (p, fontset->fallback)
919 fprintf (stderr, "\n %s(%s ", prefix, MPLIST_KEY (p)->name);
920 mdebug_dump_font (MPLIST_VAL (p));
921 fprintf (stderr, ")");
924 fprintf (stderr, ")");