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 MSymbol layouter = MPLIST_KEY (pl);
311 MFont this_request = *request;
312 MRealizedFont *rfont;
314 mfont__resize (MPLIST_VAL (pl), &this_request);
315 rfont = mfont__select (frame, MPLIST_VAL (pl), &this_request,
316 size, layouter == Mt ? Mnil : layouter);
320 MPLIST_DO (p, font_group)
321 if (((MRealizedFont *) (MPLIST_VAL (p)))->score > rfont->score)
323 mplist_push (p, Mt, rfont);
333 mfont__fontset_init ()
335 Mfontset = msymbol ("fontset");
336 Mfontset->managing_key = 1;
337 fontset_list = mplist ();
338 default_fontset = mfontset ("default");
339 if (! default_fontset->mdb)
344 mfont_put_prop (&font, Mregistry, msymbol ("iso8859-1"));
345 mfontset_modify_entry (default_fontset, Mnil, Mnil, Mnil,
347 mfont_put_prop (&font, Mregistry, msymbol ("iso10646-1"));
348 mfontset_modify_entry (default_fontset, Mnil, Mnil, Mnil,
356 mfont__fontset_fini ()
358 while (! MPLIST_TAIL_P (fontset_list))
359 free_fontset ((MFontset *) MPLIST_VAL (fontset_list));
360 M17N_OBJECT_UNREF (fontset_list);
366 mfont__realize_fontset (MFrame *frame, MFontset *fontset, MFace *face)
368 MRealizedFontset *realized;
370 MPlist *per_script, *per_lang, *per_charset, *font_group;
371 MPlist *plist, *pl, *p;
374 load_fontset_contents (fontset);
376 mfont__set_spec_from_face (&request, face);
377 if (request.property[MFONT_SIZE] <= 0)
380 request.property[MFONT_SIZE] = 120;
382 MPLIST_DO (p, frame->realized_fontset_list)
384 realized = (MRealizedFontset *) MPLIST_VAL (p);
385 if (fontset->name == MPLIST_KEY (p)
386 && ! memcmp (&request, &realized->spec, sizeof (request)))
390 MSTRUCT_MALLOC (realized, MERROR_FONTSET);
391 realized->fontset = fontset;
392 realized->tick = fontset->tick;
393 realized->spec = request;
394 realized->frame = frame;
395 realized->per_script = per_script = mplist ();
396 MPLIST_DO (plist, fontset->per_script)
398 per_lang = mplist ();
399 per_script = mplist_add (per_script, MPLIST_KEY (plist), per_lang);
400 MPLIST_DO (pl, MPLIST_PLIST (plist))
402 font_group = mplist ();
403 mplist_add (font_group, Mplist, MPLIST_VAL (pl));
404 per_lang = mplist_add (per_lang, MPLIST_KEY (pl), font_group);
408 realized->per_charset = per_charset = mplist ();
409 MPLIST_DO (plist, fontset->per_charset)
411 font_group = mplist ();
412 mplist_add (font_group, Mplist, MPLIST_VAL (plist));
413 per_charset = mplist_add (per_charset, MPLIST_KEY (plist), font_group);
416 realized->fallback = mplist ();
417 mplist_add (realized->fallback, Mplist, fontset->fallback);
419 mplist_add (frame->realized_fontset_list, fontset->name, realized);
425 mfont__free_realized_fontset (MRealizedFontset *realized)
427 MPlist *plist, *pl, *p;
428 MRealizedFont *rfont;
430 if (realized->per_script)
432 MPLIST_DO (plist, realized->per_script)
434 MPLIST_DO (pl, MPLIST_PLIST (plist))
436 MPLIST_DO (p, MPLIST_PLIST (pl))
437 if ((rfont = MPLIST_VAL (p)) && ! rfont->frame)
439 p = MPLIST_PLIST (pl);
440 M17N_OBJECT_UNREF (p);
442 pl = MPLIST_PLIST (plist);
443 M17N_OBJECT_UNREF (pl);
445 M17N_OBJECT_UNREF (realized->per_script);
447 if (realized->per_charset)
449 MPLIST_DO (plist, realized->per_charset)
451 MPLIST_DO (pl, MPLIST_PLIST (plist))
452 if ((rfont = MPLIST_VAL (pl)) && ! rfont->frame)
454 pl = MPLIST_PLIST (plist);
455 M17N_OBJECT_UNREF (pl);
457 M17N_OBJECT_UNREF (realized->per_charset);
459 if (realized->fallback)
461 MPLIST_DO (plist, realized->fallback)
462 if ((rfont = MPLIST_VAL (plist)) && ! rfont->frame)
464 M17N_OBJECT_UNREF (realized->fallback);
472 mfont__lookup_fontset (MRealizedFontset *realized, MGlyph *g, int *num,
473 MSymbol script, MSymbol language, MSymbol charset,
476 MFrame *frame = realized->frame;
477 MCharset *preferred_charset = (charset == Mnil ? NULL : MCHARSET (charset));
478 MPlist *per_charset, *per_script, *per_lang, *font_group;
479 MPlist *font_groups[256], *plist;
480 int n_font_group = 0;
481 MRealizedFont *first = NULL, *rfont;
485 if (preferred_charset
486 && (per_charset = mplist_get (realized->per_charset, charset)) != NULL)
487 font_groups[n_font_group++] = per_charset;
489 && ((per_script = mplist_find_by_key (realized->per_script, script))
492 /* The first loop is for matching language (if any), and the second
493 loop is for non-matching languages. */
494 if (language == Mnil)
496 for (i = 0; i < 2; i++)
498 MPLIST_DO (per_lang, MPLIST_PLIST (per_script))
499 if ((MPLIST_KEY (per_lang) == language) != i)
500 font_groups[n_font_group++] = MPLIST_PLIST (per_lang);
503 font_groups[n_font_group++] = realized->fallback;
505 if (n_font_group == 1)
507 /* As we only have a fallback font group, try all the other
509 MPLIST_DO (per_script, realized->per_script)
510 MPLIST_DO (per_lang, MPLIST_PLIST (per_script))
511 font_groups[n_font_group++] = MPLIST_PLIST (per_lang);
512 MPLIST_DO (per_charset, realized->per_charset)
513 font_groups[n_font_group++] = MPLIST_PLIST (per_charset);
516 for (i = 0; i < n_font_group; i++)
520 if (MPLIST_PLIST_P (font_groups[i]))
521 realize_font_group (frame, &realized->spec, font_groups[i], size);
523 MPLIST_DO (plist, font_groups[i])
525 rfont = (MRealizedFont *) MPLIST_VAL (plist);
526 g->code = mfont__encode_char (rfont, g->c);
527 if (g->code != MCHAR_INVALID_CODE)
530 if (MPLIST_TAIL_P (plist))
532 for (j = 1; j < *num; j++)
534 g[j].code = mfont__encode_char (rfont, g[j].c);
535 if (g[j].code == MCHAR_INVALID_CODE)
539 first = rfont, first_len = j;
541 /* We found a font that can display all requested
545 MPLIST_DO (plist, MPLIST_NEXT (plist))
547 rfont = (MRealizedFont *) MPLIST_VAL (plist);
548 for (j = 0; j < *num; j++)
550 g[j].code = mfont__encode_char (rfont, g[j].c);
551 if (g[j].code == MCHAR_INVALID_CODE)
557 if (! MPLIST_TAIL_P (plist))
561 if (i == n_font_group)
565 rfont = first, *num = first_len;
566 for (i = 0; i < *num; i++)
567 g[i].code = mfont__encode_char (rfont, g[i].c);
570 && mfont__open (rfont) < 0)
572 MPLIST_VAL (font_group) = NULL;
579 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
584 /*** @addtogroup m17nFontset */
589 @brief Return a fontset.
591 The mfontset () function returns a pointer to a fontset object of
592 name $NAME. If $NAME is @c NULL, it returns a pointer to the
595 If no fontset has the name $NAME, a new one is created. At that
596 time, if there exists a data \<@c fontset, $NAME\> in the m17n
597 database, the fontset contents are initialized according to the
598 data. If no such data exists, the fontset contents are left
601 The macro M17N_INIT () creates the default fontset. An
602 application program can modify it before the first call of mframe
606 This function returns a pointer to the found or newly created
610 mfontset (char *name)
616 return default_fontset;
617 sym = msymbol (name);
618 fontset = mplist_get (fontset_list, sym);
621 M17N_OBJECT (fontset, free_fontset, MERROR_FONTSET);
623 fontset->mdb = mdatabase_find (Mfontset, sym, Mnil, Mnil);
626 fontset->per_script = mplist ();
627 fontset->per_charset = mplist ();
628 fontset->fallback = mplist ();
630 mplist_put (fontset_list, sym, fontset);
631 M17N_OBJECT_REF (fontset);
638 @brief Return the name of a fontset
640 The mfontset_name () function returns the name of $FONTSET. */
642 mfontset_name (MFontset *fontset)
644 return fontset->name;
650 @brief Make a copy a fontset
652 The mfontset_copy () function makes a copy of $FONTSET, gives it a
653 name $NAME, and returns a pointer to the created copy. $NAME must
654 not be a name of existing fontset. Otherwise, this function
655 returns NULL without making a copy. */
658 mfontset_copy (MFontset *fontset, char *name)
660 MSymbol sym = msymbol (name);
661 MFontset *copy = mplist_get (fontset_list, sym);
666 M17N_OBJECT (copy, free_fontset, MERROR_FONTSET);
669 if (fontset->per_script)
671 copy->per_script = mplist ();
672 MPLIST_DO (plist, fontset->per_script)
674 MPlist *new = mplist ();
676 MPLIST_DO (pl, MPLIST_PLIST (plist))
677 mplist_add (new, MPLIST_KEY (pl), mplist_copy (MPLIST_PLIST (pl)));
678 mplist_add (copy->per_script, MPLIST_KEY (plist), new);
681 if (fontset->per_charset)
683 copy->per_charset = mplist ();
684 MPLIST_DO (plist, fontset->per_charset)
685 mplist_add (copy->per_charset, MPLIST_KEY (plist),
686 mplist_copy (MPLIST_PLIST (plist)));
688 if (fontset->fallback)
689 copy->fallback = mplist_copy (fontset->fallback);
691 copy->font_spec_list = fontset->font_spec_list;
692 M17N_OBJECT_REF (copy->font_spec_list);
694 mplist_put (fontset_list, sym, copy);
695 M17N_OBJECT_REF (copy);
702 @brief Modify the contents of a fontset.
704 The mfontset_modify_entry () function associates, in $FONTSET, a
705 copy of $FONT with the $SCRIPT / $LANGUAGE pair or with $CHARSET.
707 Each font in a fontset is associated with a particular
708 script/language pair, with a particular charset, or with the
709 symbol @c Mnil. The fonts that are associated with the same item
712 If $SCRIPT is not @c Mnil, it must be a symbol identifying a
713 script. In this case, $LANGUAGE is either a symbol identifying a
714 language or @c Mnil, and $FONT is associated with the $SCRIPT /
717 If $CHARSET is not @c Mnil, it must be a symbol representing a
718 charset object. In this case, $FONT is associated with that
721 If both $SCRIPT and $CHARSET are not @c Mnil, two copies of $FONT
722 are created. Then one is associated with the script/language pair
723 and the other with the charset.
725 If both $SCRIPT and $CHARSET are @c Mnil, $FONT is associated
726 with @c Mnil. This kind of fonts are called <i>fallback
729 The argument $HOW specifies the priority of $FONT. If $HOW is
730 positive, $FONT has the highest priority in the group of fonts
731 that are associated with the same item. If $HOW is negative,
732 $FONT has the lowest priority. If $HOW is zero, $FONT becomes the
733 only available font for the associated item; all the other fonts
734 are removed from the group.
736 If $LAYOUTER_NAME is not @c Mnil, it must be a symbol
737 representing a @ref flt. In that case, if $FONT is selected for
738 drawing an M-text, that font layout table is used to generate a
739 glyph code sequence from a character sequence.
742 If the operation was successful, mfontset_modify_entry () returns 0.
743 Otherwise it returns -1 and assigns an error code to the external
744 variable @c merror_code. */
747 @brief ¸À¸ì¤È¥¹¥¯¥ê¥×¥È¤ÎÁȤ߹ç¤ï¤»¤Ë¥Õ¥©¥ó¥È¤ò´ØÏ¢ÉÕ¤±¤ë
749 ´Ø¿ô mfontset_set_language_script () ¤Ï¡¢$LANGUAGE ¤È $SCRIPT ¤ÎÁÈ
750 ¤ß¹ç¤ï¤»¤ËÂФ·¤Æ¥Õ¥©¥ó¥È $FONT ¤ò»È¤¦¤è¤¦¡¢¥Õ¥©¥ó¥È¥»¥Ã¥È $FONTSET
751 ¤òÀßÄꤹ¤ë¡£$LANGUAGE ¤È $SCRIPT ¤Ï¡¢¤½¤ì¤¾¤ì¸À¸ì¤È¥¹¥¯¥ê¥×¥È¤ò»Ø
752 Äꤹ¤ë¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£
754 ¸À¸ì¤È¥¹¥¯¥ê¥×¥È¤ÎÁȤ߹ç¤ï¤»°ì¤Ä¤ËÂФ·¤ÆÊ£¿ô¤Î¥Õ¥©¥ó¥È¤òÀßÄꤹ¤ë¤³
755 ¤È¤â¤Ç¤¤ë¡£$PREPEND_P ¤¬ 0 °Ê³°¤Ê¤é¤Ð¡¢$FONT ¤Ï¤½¤ÎÁȤ߹ç¤ï¤»¤ËÂÐ
756 ¤·¤ÆºÇÍ¥Àè¤ÇÍѤ¤¤é¤ì¤ë¤â¤Î¤È¤Ê¤ë¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢Í¥ÀèÅÙºÇÄã¤Î¥Õ¥©
757 ¥ó¥È¤È¤·¤ÆÅÐÏ¿¤µ¤ì¤ë¡£
760 ½èÍý¤¬À®¸ù¤·¤¿¤È¤¡¢mfontset_set_language_script () ¤Ï 0 ¤òÊÖ¤¹¡£
761 ¼ºÇÔ¤·¤¿¤È¤¤Ï -1 ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô @c merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤ò
769 mfontset_modify_entry (MFontset *fontset,
770 MSymbol script, MSymbol language, MSymbol charset,
771 MFont *spec, MSymbol layouter_name,
774 MPlist *per_lang, *plist[3], *pl;
779 load_fontset_contents (fontset);
781 MPLIST_DO (pl, fontset->font_spec_list)
783 if (! memcmp (MPLIST_VAL (pl), spec, sizeof (MFont)))
785 font = MPLIST_VAL (pl);
793 mplist_add (fontset->font_spec_list, Mt, font);
799 if (language == Mnil)
801 per_lang = mplist_get (fontset->per_script, script);
803 mplist_add (fontset->per_script, script, per_lang = mplist ());
804 plist[i] = mplist_get (per_lang, language);
806 mplist_add (per_lang, language, plist[i] = mplist ());
811 plist[i] = mplist_get (fontset->per_charset, charset);
813 mplist_add (fontset->per_charset, charset, plist[i] = mplist ());
816 if (script == Mnil && charset == Mnil)
818 plist[i++] = fontset->fallback;
821 if (layouter_name == Mnil)
823 for (i--; i >= 0; i--)
826 mplist_push (plist[i], layouter_name, font);
828 mplist_add (plist[i], layouter_name, font);
831 mplist_set (plist[i], Mnil, NULL);
832 mplist_add (plist[i], layouter_name, font);
841 /*** @addtogroup m17nDebug */
846 @brief Dump a fontset
848 The mdebug_dump_fontset () function prints $FONTSET in a human readable
849 way to the stderr. $INDENT specifies how many columns to indent
850 the lines but the first one.
853 This function returns $FONTSET. */
856 mdebug_dump_fontset (MFontset *fontset, int indent)
858 char *prefix = (char *) alloca (indent + 1);
859 MPlist *plist, *pl, *p;
861 memset (prefix, 32, indent);
864 fprintf (stderr, "(fontset %s", fontset->name->name);
865 if (fontset->per_script)
866 MPLIST_DO (plist, fontset->per_script)
868 fprintf (stderr, "\n %s(%s", prefix, MPLIST_KEY (plist)->name);
869 MPLIST_DO (pl, MPLIST_PLIST (plist))
871 fprintf (stderr, "\n %s(%s", prefix, MPLIST_KEY (pl)->name);
872 MPLIST_DO (p, MPLIST_PLIST (pl))
874 fprintf (stderr, "\n %s(%s ", prefix,
875 MPLIST_KEY (p)->name);
876 mdebug_dump_font (MPLIST_VAL (p));
877 fprintf (stderr, ")");
879 fprintf (stderr, ")");
881 fprintf (stderr, ")");
883 if (fontset->per_charset)
884 MPLIST_DO (pl, fontset->per_charset)
886 fprintf (stderr, "\n %s(%s", prefix, MPLIST_KEY (pl)->name);
887 MPLIST_DO (p, MPLIST_PLIST (pl))
889 fprintf (stderr, "\n %s(%s ", prefix, MPLIST_KEY (p)->name);
890 mdebug_dump_font (MPLIST_VAL (p));
891 fprintf (stderr, ")");
893 fprintf (stderr, ")");
896 if (fontset->fallback)
897 MPLIST_DO (p, fontset->fallback)
899 fprintf (stderr, "\n %s(%s ", prefix, MPLIST_KEY (p)->name);
900 mdebug_dump_font (MPLIST_VAL (p));
901 fprintf (stderr, ")");
904 fprintf (stderr, ")");