aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2009-04-16 01:32:44 +0000
committerKenichi Handa2009-04-16 01:32:44 +0000
commitc9477f014bd802562bb511fe9804243631fbfa08 (patch)
tree7941d7fc59f02acd8275b5c0044c5262d2e6e82c
parent89dc9a8ed9dd5b6e1ad71c8a377899876d8a7c40 (diff)
downloademacs-c9477f014bd802562bb511fe9804243631fbfa08.tar.gz
emacs-c9477f014bd802562bb511fe9804243631fbfa08.zip
(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.
-rw-r--r--src/font.c53
1 files changed, 13 insertions, 40 deletions
diff --git a/src/font.c b/src/font.c
index f3615e2e9b1..b5496e82300 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2297,8 +2297,12 @@ struct font_sort_data
2297 pixel-size from QCdpi property of PREFER or from the Y-resolution 2297 pixel-size from QCdpi property of PREFER or from the Y-resolution
2298 of FRAME before sorting. 2298 of FRAME before sorting.
2299 2299
2300 If BEST-ONLY is nonzero, return the best matching entity. Otherwise, 2300 If BEST-ONLY is nonzero, return the best matching entity (that
2301 return the sorted VEC. */ 2301 supports the character BEST-ONLY if BEST-ONLY is positive, or any
2302 if BEST-ONLY is negative). Otherwise, return the sorted VEC.
2303
2304 This function does no optimization for the case that the length of
2305 VEC is 1. The caller should avoid calling this in such a case. */
2302 2306
2303static Lisp_Object 2307static Lisp_Object
2304font_sort_entites (vec, prefer, frame, best_only) 2308font_sort_entites (vec, prefer, frame, best_only)
@@ -2316,9 +2320,6 @@ font_sort_entites (vec, prefer, frame, best_only)
2316 USE_SAFE_ALLOCA; 2320 USE_SAFE_ALLOCA;
2317 2321
2318 len = ASIZE (vec); 2322 len = ASIZE (vec);
2319 if (len <= 1)
2320 return best_only ? AREF (vec, 0) : vec;
2321
2322 for (i = FONT_WEIGHT_INDEX; i <= FONT_DPI_INDEX; i++) 2323 for (i = FONT_WEIGHT_INDEX; i <= FONT_DPI_INDEX; i++)
2323 prefer_prop[i] = AREF (prefer, i); 2324 prefer_prop[i] = AREF (prefer, i);
2324 if (FLOATP (prefer_prop[FONT_SIZE_INDEX])) 2325 if (FLOATP (prefer_prop[FONT_SIZE_INDEX]))
@@ -2327,16 +2328,14 @@ font_sort_entites (vec, prefer, frame, best_only)
2327 2328
2328 /* Scoring and sorting. */ 2329 /* Scoring and sorting. */
2329 SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * len); 2330 SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * len);
2330 best_score = 0xFFFFFFFF;
2331 /* We are sure that the length of VEC > 1. */ 2331 /* We are sure that the length of VEC > 1. */
2332 driver_type = AREF (AREF (vec, 0), FONT_TYPE_INDEX); 2332 driver_type = AREF (AREF (vec, 0), FONT_TYPE_INDEX);
2333 for (driver_order = 0, list = f->font_driver_list; list; 2333 for (driver_order = 0, list = f->font_driver_list; list;
2334 driver_order++, list = list->next) 2334 driver_order++, list = list->next)
2335 if (EQ (driver_type, list->driver->type)) 2335 if (EQ (driver_type, list->driver->type))
2336 break; 2336 break;
2337 best_entity = data[0].entity = AREF (vec, 0); 2337 best_score = 0xFFFFFFFF;
2338 best_score = data[0].score 2338 best_entity = Qnil;
2339 = font_score (data[0].entity, prefer_prop) | driver_order;
2340 for (i = 0; i < len; i++) 2339 for (i = 0; i < len; i++)
2341 { 2340 {
2342 if (!EQ (driver_type, AREF (AREF (vec, i), FONT_TYPE_INDEX))) 2341 if (!EQ (driver_type, AREF (AREF (vec, i), FONT_TYPE_INDEX)))
@@ -2345,7 +2344,10 @@ font_sort_entites (vec, prefer, frame, best_only)
2345 if (EQ (driver_type, list->driver->type)) 2344 if (EQ (driver_type, list->driver->type))
2346 break; 2345 break;
2347 data[i].entity = AREF (vec, i); 2346 data[i].entity = AREF (vec, i);
2348 data[i].score = font_score (data[i].entity, prefer_prop) | driver_order; 2347 data[i].score
2348 = (best_only <= 0 || font_has_char (f, data[i].entity, best_only) > 0
2349 ? font_score (data[i].entity, prefer_prop) | driver_order
2350 : 0xFFFFFFFF);
2349 if (best_only && best_score > data[i].score) 2351 if (best_only && best_score > data[i].score)
2350 { 2352 {
2351 best_score = data[i].score; 2353 best_score = data[i].score;
@@ -3213,37 +3215,8 @@ font_select_entity (frame, entities, attrs, pixel_size, c)
3213 if (NILP (AREF (prefer, FONT_WIDTH_INDEX))) 3215 if (NILP (AREF (prefer, FONT_WIDTH_INDEX)))
3214 FONT_SET_STYLE (prefer, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); 3216 FONT_SET_STYLE (prefer, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]);
3215 ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size)); 3217 ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size));
3216 entities = font_sort_entites (entities, prefer, frame, c < 0);
3217
3218 if (c < 0)
3219 return entities;
3220
3221 for (i = 0; i < ASIZE (entities); i++)
3222 {
3223 int j;
3224 3218
3225 font_entity = AREF (entities, i); 3219 return font_sort_entites (entities, prefer, frame, c);
3226#if 0
3227 /* The following code is intended to avoid checking of
3228 font_has_char repeatedly for bitmap fonts that differs only
3229 in pixelsize. But, it doesn't work well if fontconfig is
3230 configured to find BDF/PFC fonts. */
3231 if (i > 0)
3232 {
3233 for (j = FONT_FOUNDRY_INDEX; j <= FONT_REGISTRY_INDEX; j++)
3234 if (! EQ (AREF (font_entity, j), props[j]))
3235 break;
3236 if (j > FONT_REGISTRY_INDEX)
3237 continue;
3238 }
3239 for (j = FONT_FOUNDRY_INDEX; j <= FONT_REGISTRY_INDEX; j++)
3240 props[j] = AREF (font_entity, j);
3241#endif
3242 result = font_has_char (f, font_entity, c);
3243 if (result > 0)
3244 return font_entity;
3245 }
3246 return Qnil;
3247} 3220}
3248 3221
3249/* Return a font-entity satisfying SPEC and best matching with face's 3222/* Return a font-entity satisfying SPEC and best matching with face's