[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/src font.c
From: |
Kenichi Handa |
Subject: |
[Emacs-diffs] emacs/src font.c |
Date: |
Thu, 16 Apr 2009 01:32:45 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Kenichi Handa <handa> 09/04/16 01:32:45
Modified files:
src : font.c
Log message:
(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.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/font.c?cvsroot=emacs&r1=1.122&r2=1.123
Patches:
Index: font.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/font.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -b -r1.122 -r1.123
--- font.c 14 Apr 2009 12:38:25 -0000 1.122
+++ font.c 16 Apr 2009 01:32:44 -0000 1.123
@@ -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