}
}
-\f
-
-/* Internal API */
-
-int
-mfont__fontset_init ()
-{
- Mfontset = msymbol ("fontset");
- Mfontset->managing_key = 1;
- fontset_list = mplist ();
- default_fontset = mfontset ("default");
- if (! default_fontset->mdb)
- {
- MFont font;
-
- MFONT_INIT (&font);
- mfont_put_prop (&font, Mregistry, msymbol ("iso8859-1"));
- mfontset_modify_entry (default_fontset, Mnil, Mnil, Mnil,
- &font, Mnil, 1);
- mfont_put_prop (&font, Mregistry, msymbol ("iso10646-1"));
- mfontset_modify_entry (default_fontset, Mnil, Mnil, Mnil,
- &font, Mnil, 1);
- }
- return 0;
-}
-
-
-void
-mfont__fontset_fini ()
-{
- while (! MPLIST_TAIL_P (fontset_list))
- free_fontset ((MFontset *) MPLIST_VAL (fontset_list));
- M17N_OBJECT_UNREF (fontset_list);
- fontset_list = NULL;
-}
-
-
-MRealizedFontset *
-mfont__realize_fontset (MFrame *frame, MFontset *fontset, MFace *face)
+static void
+realize_fontset_elements (MFrame *frame, MRealizedFontset *realized,
+ MFontset *fontset, MFont *request)
{
- MRealizedFontset *realized;
- MFont request;
MPlist *per_script, *per_lang, *per_charset, *font_group;
- MPlist *plist, *pl, *p;
-
- if (fontset->mdb)
- load_fontset_contents (fontset);
-
- mfont__set_spec_from_face (&request, face);
- if (request.property[MFONT_SIZE] <= 0)
- {
- mdebug_hook ();
- request.property[MFONT_SIZE] = 120;
- }
- MPLIST_DO (p, frame->realized_fontset_list)
- {
- realized = (MRealizedFontset *) MPLIST_VAL (p);
- if (fontset->name == MPLIST_KEY (p)
- && ! memcmp (&request, &realized->spec, sizeof (request)))
- return realized;
- }
+ MPlist *plist, *pl;
- MSTRUCT_MALLOC (realized, MERROR_FONTSET);
realized->fontset = fontset;
realized->tick = fontset->tick;
- realized->spec = request;
+ realized->spec = *request;
realized->frame = frame;
realized->per_script = per_script = mplist ();
MPLIST_DO (plist, fontset->per_script)
realized->fallback = mplist ();
mplist_add (realized->fallback, Mplist, fontset->fallback);
- mplist_add (frame->realized_fontset_list, fontset->name, realized);
- return realized;
}
-
-void
-mfont__free_realized_fontset (MRealizedFontset *realized)
+static void
+free_realized_fontset_elements (MRealizedFontset *realized)
{
MPlist *plist, *pl, *p;
MRealizedFont *rfont;
free (rfont);
M17N_OBJECT_UNREF (realized->fallback);
}
+}
+
+static void
+update_fontset_elements (MRealizedFontset *realized)
+{
+ free_realized_fontset_elements (realized);
+ realize_fontset_elements (realized->frame, realized, realized->fontset,
+ &realized->spec);
+}
+
+
+\f
+
+/* Internal API */
+
+int
+mfont__fontset_init ()
+{
+ Mfontset = msymbol ("fontset");
+ Mfontset->managing_key = 1;
+ fontset_list = mplist ();
+ default_fontset = mfontset ("default");
+ if (! default_fontset->mdb)
+ {
+ MFont font;
+
+ MFONT_INIT (&font);
+ mfont_put_prop (&font, Mregistry, msymbol ("iso8859-1"));
+ mfontset_modify_entry (default_fontset, Mnil, Mnil, Mnil,
+ &font, Mnil, 1);
+ mfont_put_prop (&font, Mregistry, msymbol ("iso10646-1"));
+ mfontset_modify_entry (default_fontset, Mnil, Mnil, Mnil,
+ &font, Mnil, 1);
+ }
+ return 0;
+}
+
+
+void
+mfont__fontset_fini ()
+{
+ while (! MPLIST_TAIL_P (fontset_list))
+ free_fontset ((MFontset *) MPLIST_VAL (fontset_list));
+ M17N_OBJECT_UNREF (fontset_list);
+ fontset_list = NULL;
+}
+
+
+MRealizedFontset *
+mfont__realize_fontset (MFrame *frame, MFontset *fontset, MFace *face)
+{
+ MRealizedFontset *realized;
+ MFont request;
+ MPlist *plist;
+
+ if (fontset->mdb)
+ load_fontset_contents (fontset);
+
+ mfont__set_spec_from_face (&request, face);
+ if (request.property[MFONT_SIZE] <= 0)
+ {
+ mdebug_hook ();
+ request.property[MFONT_SIZE] = 120;
+ }
+ MPLIST_DO (plist, frame->realized_fontset_list)
+ {
+ realized = (MRealizedFontset *) MPLIST_VAL (plist);
+ if (fontset->name == MPLIST_KEY (plist)
+ && ! memcmp (&request, &realized->spec, sizeof (request)))
+ return realized;
+ }
+
+ MSTRUCT_MALLOC (realized, MERROR_FONTSET);
+ realize_fontset_elements (frame, realized, fontset, &request);
+ mplist_add (frame->realized_fontset_list, fontset->name, realized);
+ return realized;
+}
+
+void
+mfont__free_realized_fontset (MRealizedFontset *realized)
+{
+ free_realized_fontset_elements (realized);
free (realized);
}
MRealizedFont *rfont;
int i;
+ if (realized->tick != realized->fontset->tick)
+ update_fontset_elements (realized);
+
if (preferred_charset
&& (per_charset = mplist_get (realized->per_charset, charset)) != NULL)
font_groups[n_font_group++] = per_charset;
}
}
+ fontset->tick++;
return 0;
}
+/*=*/
+
+/***en
+ @brief Lookup a fontset.
+
+ The mfontset_lookup () function lookups $FONTSET and returns a
+ plist that describes the contents of $FONTSET corresponding to the
+ specified script, language, and charset.
+
+ If $SCRIPT is @c Mt, keys of the returned plist are script name
+ symbols for which some fonts are specified and values are NULL.
+
+ If $SCIRPT is a script symbol, the returned plist is decided by
+ $LANGUAGE.
+
+ If $LANGUAGE is @c Mt, keys of the plist are language name symbols
+ for which some fonts are specified and values are NULL. A key may
+ be @c Mt which means some fallback fonts are specified for the
+ script.
+
+ If $LANGUAGE is a language name symbol, the plist is a @c
+ FONT-GROUP for the specified script and langauge.
+
+ If $LANGAUGE is @c Mt, the plist is fallback @c FONT-GROUP for the
+ script.
+
+ If $SCRIPT is @c Mnil, the returned plist is decided as below.
+
+ If $CHARSET is @c Mt, keys of the returned plist are charset name
+ symbols for which some fonts are specified and values are NULL.
+
+ If $CHARSET is a charset symbol, the plist is a @c FONT-GROUP for
+ the charset.
+
+ If $CHARSET is @c Mnil, the plist is a fallback @c FONT-GROUP.
+
+ @c FONT-GROUP is a plist whose keys are FLT name symbols (@c Mt if
+ no FLT is associated with the font) and values are pointers to
+ #MFont.
+
+ @return
+ It returns a plist describing the contents of a fontset. The
+ plist should be freed by m17n_object_unref (). */
+
+MPlist *
+mfontset_lookup (MFontset *fontset,
+ MSymbol script, MSymbol language, MSymbol charset)
+{
+ MPlist *plist = mplist (), *pl, *p;
+
+ if (fontset->mdb)
+ load_fontset_contents (fontset);
+ if (script == Mt)
+ {
+ if (! fontset->per_script)
+ return plist;
+ p = plist;
+ MPLIST_DO (pl, fontset->per_script)
+ p = mplist_add (p, MPLIST_KEY (pl), NULL);
+ return plist;
+ }
+ if (script != Mnil)
+ {
+ if (! fontset->per_script)
+ return plist;
+ pl = mplist_get (fontset->per_script, script);
+ if (! pl)
+ return plist;
+ if (language == Mt)
+ {
+ p = plist;
+ MPLIST_DO (pl, pl)
+ p = mplist_add (p, MPLIST_KEY (pl), NULL);
+ return plist;
+ }
+ if (language == Mnil)
+ language = Mt;
+ pl = mplist_get (pl, language);
+ }
+ else if (charset != Mnil)
+ {
+ if (! fontset->per_charset)
+ return plist;
+ if (charset == Mt)
+ {
+ p = plist;
+ MPLIST_DO (pl, fontset->per_charset)
+ p = mplist_add (p, MPLIST_KEY (pl), NULL);
+ return plist;
+ }
+ pl = mplist_get (fontset->per_charset, charset);
+ }
+ else
+ pl = fontset->fallback;
+ if (! pl)
+ return plist;
+ return mplist_copy (pl);
+}
+
+
/*** @} */
/*** @addtogroup m17nDebug */