Mercurial > emacs
changeset 102990:a706504f064e
(font_sort_entites): Change the meaning of the arg
BEST-ONLY. Don't optimize for VEC of lenght 1.
(font_select_entity): Just return the value of font_sort_entites.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 16 Apr 2009 01:32:44 +0000 |
parents | 42574e6202e2 |
children | 18e317a87f12 |
files | src/font.c |
diffstat | 1 files changed, 14 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/src/font.c Thu Apr 16 01:08:24 2009 +0000 +++ b/src/font.c Thu Apr 16 01:32:44 2009 +0000 @@ -2297,8 +2297,12 @@ pixel-size from QCdpi property of PREFER or from the Y-resolution of FRAME before sorting. - If BEST-ONLY is nonzero, return the best matching entity. Otherwise, - return the sorted VEC. */ + If BEST-ONLY is nonzero, return the best matching entity (that + supports the character BEST-ONLY if BEST-ONLY is positive, or any + if BEST-ONLY is negative). Otherwise, return the sorted VEC. + + This function does no optimization for the case that the length of + VEC is 1. The caller should avoid calling this in such a case. */ static Lisp_Object font_sort_entites (vec, prefer, frame, best_only) @@ -2316,9 +2320,6 @@ USE_SAFE_ALLOCA; len = ASIZE (vec); - if (len <= 1) - return best_only ? AREF (vec, 0) : vec; - for (i = FONT_WEIGHT_INDEX; i <= FONT_DPI_INDEX; i++) prefer_prop[i] = AREF (prefer, i); if (FLOATP (prefer_prop[FONT_SIZE_INDEX])) @@ -2327,16 +2328,14 @@ /* Scoring and sorting. */ SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * len); - best_score = 0xFFFFFFFF; /* We are sure that the length of VEC > 1. */ driver_type = AREF (AREF (vec, 0), FONT_TYPE_INDEX); for (driver_order = 0, list = f->font_driver_list; list; driver_order++, list = list->next) if (EQ (driver_type, list->driver->type)) break; - best_entity = data[0].entity = AREF (vec, 0); - best_score = data[0].score - = font_score (data[0].entity, prefer_prop) | driver_order; + best_score = 0xFFFFFFFF; + best_entity = Qnil; for (i = 0; i < len; i++) { if (!EQ (driver_type, AREF (AREF (vec, i), FONT_TYPE_INDEX))) @@ -2345,7 +2344,10 @@ if (EQ (driver_type, list->driver->type)) break; data[i].entity = AREF (vec, i); - data[i].score = font_score (data[i].entity, prefer_prop) | driver_order; + data[i].score + = (best_only <= 0 || font_has_char (f, data[i].entity, best_only) > 0 + ? font_score (data[i].entity, prefer_prop) | driver_order + : 0xFFFFFFFF); if (best_only && best_score > data[i].score) { best_score = data[i].score; @@ -3213,37 +3215,8 @@ if (NILP (AREF (prefer, FONT_WIDTH_INDEX))) FONT_SET_STYLE (prefer, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size)); - entities = font_sort_entites (entities, prefer, frame, c < 0); - - if (c < 0) - return entities; - - for (i = 0; i < ASIZE (entities); i++) - { - int j; - - font_entity = AREF (entities, i); -#if 0 - /* The following code is intended to avoid checking of - font_has_char repeatedly for bitmap fonts that differs only - in pixelsize. But, it doesn't work well if fontconfig is - configured to find BDF/PFC fonts. */ - if (i > 0) - { - for (j = FONT_FOUNDRY_INDEX; j <= FONT_REGISTRY_INDEX; j++) - if (! EQ (AREF (font_entity, j), props[j])) - break; - if (j > FONT_REGISTRY_INDEX) - continue; - } - for (j = FONT_FOUNDRY_INDEX; j <= FONT_REGISTRY_INDEX; j++) - props[j] = AREF (font_entity, j); -#endif - result = font_has_char (f, font_entity, c); - if (result > 0) - return font_entity; - } - return Qnil; + + return font_sort_entites (entities, prefer, frame, c); } /* Return a font-entity satisfying SPEC and best matching with face's