From ce3067b4d5cf6ac4547d3abf525ea77def9e8234 Mon Sep 17 00:00:00 2001 From: handa Date: Fri, 2 Dec 2005 04:36:49 +0000 Subject: [PATCH] (get_font_from_group): New function. (mfontset__get_font): New function. --- src/fontset.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/src/fontset.c b/src/fontset.c index fb684e9..f054199 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -845,6 +845,105 @@ mfont__lookup_fontset (MRealizedFontset *realized, MGlyph *g, int *num, return NULL; } +MRealizedFont * +get_font_from_group (MFrame *frame, MPlist *plist, MFont *font) +{ + MRealizedFont *rfont; + + MPLIST_DO (plist, plist) + { + MFont spec = *(MFont *) MPLIST_VAL (plist); + if (mfont__merge (&spec, font, 1) < 0) + continue; + if (font->type == MFONT_TYPE_SPEC) + rfont = (MRealizedFont *) mfont_find (frame, &spec, NULL, 0); + else if (font->type == MFONT_TYPE_OBJECT) + rfont = mfont__open (frame, font, &spec); + else + rfont = (MRealizedFont *) font; + if (rfont + && (spec.capability == Mnil + || mfont__check_capability (rfont, spec.capability) == 0)) + { + rfont->layouter + = MPLIST_KEY (plist) == Mt ? Mnil : MPLIST_KEY (plist); + return rfont; + } + } + return NULL; +} + +MRealizedFont * +mfontset__get_font (MFrame *frame, MFontset *fontset, + MSymbol script, MSymbol language, MFont *font, + int *best) +{ + MPlist *per_script, *per_lang; + MRealizedFont *rfont; + + if (best) + *best = 0; + + if (script != Mnil) + { + per_script = get_per_script (fontset, script); + if (language == Mnil) + language = Mt; + if ((per_lang = mplist_get (per_script, language)) + && (rfont = get_font_from_group (frame, per_lang, font))) + { + if (best) + *best = 1; + return rfont; + } + if (best) + *best = per_lang ? 0 : 1; + if (language == Mt) + { + MPLIST_DO (per_script, per_script) + if (MPLIST_KEY (per_script) != language + && (rfont = get_font_from_group (frame, + MPLIST_PLIST (per_script), + font))) + return rfont; + } + else + { + if ((per_lang = mplist_get (per_script, Mt)) + && (rfont = get_font_from_group (frame, per_lang, font))) + return rfont; + if (best) + *best = 0; + MPLIST_DO (per_script, per_script) + if (MPLIST_KEY (per_script) != language + && MPLIST_KEY (per_script) != Mt + && (rfont = get_font_from_group (frame, + MPLIST_PLIST (per_script), + font))) + return rfont; + } + } + + if (language != Mnil) + MPLIST_DO (per_script, fontset->per_script) + { + if ((per_lang = mplist_get (MPLIST_PLIST (per_script), language)) + && (rfont = get_font_from_group (frame, per_lang, font))) + { + if (best) + *best = 1; + return rfont; + } + } + + if (best) + *best = 0; + if ((rfont = get_font_from_group (frame, fontset->fallback, font))) + return rfont; + return NULL; +} + + /*** @} */ #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */ -- 1.7.10.4