}
MRealizedFont *
-mfont__select (MFrame *frame, MFont *spec, MFont *request, int limited_size)
+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];
+ MRealizedFont *best_font[MFONT_TYPE_MAX], *best;
int best_index;
int i;
int mdebug_mask = MDEBUG_FONT;
MPLIST_DO (realized_font_list, frame->realized_font_list)
{
- MRealizedFont *best = MPLIST_VAL (realized_font_list);
-
+ best = MPLIST_VAL (realized_font_list);
if (MPLIST_KEY (realized_font_list) == registry
&& ! memcmp (&best->spec, spec, sizeof (MFont))
&& ! memcmp (&best->request, request, sizeof (MFont)))
- return best;
+ {
+ if (best->layouter != layouter)
+ {
+ MRealizedFont *copy;
+
+ MSTRUCT_MALLOC (copy, MERROR_FONT);
+ *copy = *best;
+ copy->layouter = layouter;
+ if (copy->info)
+ M17N_OBJECT_REF (copy->info);
+ mplist_add (frame->realized_font_list, registry, copy);
+ best = copy;
+ }
+ return best;
+ }
}
MDEBUG_PUSH_TIME ();
+ best = NULL;
best_index = -1;
for (i = 0; i < MFONT_TYPE_MAX; i++)
{
: NULL);
if (best_font[i]
&& (best_index < 0
- || best_font[best_index]->score > best_font[i]->score))
+ || best_font[best_index]->score < best_font[i]->score))
best_index = i;
}
for (i = 0; i < MFONT_TYPE_MAX; i++)
{
if (i == best_index)
- mplist_add (frame->realized_font_list, registry, best_font[i]);
+ best = best_font[i];
else if (best_font[i])
free (best_font[i]);
}
font.property[i] = request->property[i];
gen_font_name (buf2, &font);
- if (best_index >= 0)
+ if (best)
MDEBUG_PRINT_TIME ("FONT",
(stderr, " to select <%s> from <%s>.",
- gen_font_name (buf1,
- &best_font[best_index]->font),
+ gen_font_name (buf1, &best->font),
buf2));
else
MDEBUG_PRINT_TIME ("FONT", (stderr, " to fail to find <%s>.", buf2));
MDEBUG_POP_TIME ();
}
- return (best_index >= 0 ? best_font[best_index] : NULL);
+ if (! best)
+ return NULL;
+ best->layouter = layouter;
+ mplist_add (frame->realized_font_list, registry, best);
+ return best;
}
MFONT_INIT (&spec_copy);
spec_copy.property[MFONT_REGISTRY] = spec->property[MFONT_REGISTRY];
- rfont = mfont__select (frame, &spec_copy, spec, limited_size);
+ rfont = mfont__select (frame, &spec_copy, spec, limited_size, Mnil);
if (!rfont)
return NULL;
if (score)
mplist_set (font_group, Mnil, NULL);
MPLIST_DO (pl, plist)
{
+ MSymbol layouter = MPLIST_KEY (pl);
MRealizedFont *rfont = mfont__select (frame, MPLIST_VAL (pl), request,
- size);
+ size,
+ layouter == Mt ? Mnil : layouter);
if (rfont)
{
- rfont->layouter = MPLIST_KEY (pl);
- if (rfont->layouter == Mt)
- rfont->layouter = Mnil;
MPLIST_DO (p, font_group)
if (((MRealizedFont *) (MPLIST_VAL (p)))->score > rfont->score)
break;
}
}
-int
-check_fontset_element (MFrame *frame, MPlist *element, MGlyph *g, int size)
-{
- MRealizedFont *rfont = (MRealizedFont *) MPLIST_VAL (element);
-
- if (! rfont)
- /* We have already failed to select this font. */
- return 0;
- if (! rfont->frame)
- {
- rfont = mfont__select (frame, &rfont->spec, &rfont->request, size);
- free (MPLIST_VAL (element));
- MPLIST_VAL (element) = rfont;
- if (! rfont)
- /* No font matches this spec. */
- return 0;
- }
-
- g->code = mfont__encode_char (rfont, g->c);
- return (g->code != MCHAR_INVALID_CODE);
-}
-
\f
/* Internal API */