aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/font.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/src/font.c b/src/font.c
index e526394122b..9b537296eb1 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1444,7 +1444,6 @@ font_parse_fcname (name, font)
1444 { 1444 {
1445 /* KEY=VAL pairs */ 1445 /* KEY=VAL pairs */
1446 Lisp_Object key; 1446 Lisp_Object key;
1447 char *keyhead = p;
1448 int prop; 1447 int prop;
1449 1448
1450 if (q - p == 10 && memcmp (p + 1, "pixelsize", 9) == 0) 1449 if (q - p == 10 && memcmp (p + 1, "pixelsize", 9) == 0)
@@ -1480,8 +1479,8 @@ font_parse_fcname (name, font)
1480 { 1479 {
1481 if (isdigit (*p)) 1480 if (isdigit (*p))
1482 { 1481 {
1483 char *r;
1484 int size_found = 1; 1482 int size_found = 1;
1483
1485 for (q = p + 1; *q && *q != ' '; q++) 1484 for (q = p + 1; *q && *q != ' '; q++)
1486 if (! isdigit (*q)) 1485 if (! isdigit (*q))
1487 { 1486 {
@@ -2166,8 +2165,7 @@ font_prepare_composition (cmp, f)
2166static unsigned font_score P_ ((Lisp_Object, Lisp_Object *)); 2165static unsigned font_score P_ ((Lisp_Object, Lisp_Object *));
2167static int font_compare P_ ((const void *, const void *)); 2166static int font_compare P_ ((const void *, const void *));
2168static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object, 2167static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object,
2169 Lisp_Object, Lisp_Object, 2168 Lisp_Object, int));
2170 int));
2171 2169
2172/* We sort fonts by scoring each of them against a specified 2170/* We sort fonts by scoring each of them against a specified
2173 font-spec. The score value is 32 bit (`unsigned'), and the smaller 2171 font-spec. The score value is 32 bit (`unsigned'), and the smaller
@@ -2252,15 +2250,14 @@ struct font_sort_data
2252/* Sort font-entities in vector VEC by closeness to font-spec PREFER. 2250/* Sort font-entities in vector VEC by closeness to font-spec PREFER.
2253 If PREFER specifies a point-size, calculate the corresponding 2251 If PREFER specifies a point-size, calculate the corresponding
2254 pixel-size from QCdpi property of PREFER or from the Y-resolution 2252 pixel-size from QCdpi property of PREFER or from the Y-resolution
2255 of FRAME before sorting. If SPEC is not nil, it is a font-spec to 2253 of FRAME before sorting.
2256 get the font-entities in VEC.
2257 2254
2258 If BEST-ONLY is nonzero, return the best matching entity. Otherwise, 2255 If BEST-ONLY is nonzero, return the best matching entity. Otherwise,
2259 return the sorted VEC. */ 2256 return the sorted VEC. */
2260 2257
2261static Lisp_Object 2258static Lisp_Object
2262font_sort_entites (vec, prefer, frame, spec, best_only) 2259font_sort_entites (vec, prefer, frame, best_only)
2263 Lisp_Object vec, prefer, frame, spec; 2260 Lisp_Object vec, prefer, frame;
2264 int best_only; 2261 int best_only;
2265{ 2262{
2266 Lisp_Object prefer_prop[FONT_SPEC_MAX]; 2263 Lisp_Object prefer_prop[FONT_SPEC_MAX];
@@ -2279,20 +2276,6 @@ font_sort_entites (vec, prefer, frame, spec, best_only)
2279 2276
2280 for (i = FONT_WEIGHT_INDEX; i <= FONT_DPI_INDEX; i++) 2277 for (i = FONT_WEIGHT_INDEX; i <= FONT_DPI_INDEX; i++)
2281 prefer_prop[i] = AREF (prefer, i); 2278 prefer_prop[i] = AREF (prefer, i);
2282
2283 if (! NILP (spec))
2284 {
2285 /* A font driver may return a font that has a property value
2286 different from the value specified in SPEC if the driver
2287 thinks they are the same. That happens, for instance, such a
2288 generic family name as "serif" is specified. So, to ignore
2289 such a difference, for all properties specified in SPEC, set
2290 the corresponding properties in PREFER_PROP to nil. */
2291 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++)
2292 if (! NILP (AREF (spec, i)))
2293 prefer_prop[i] = Qnil;
2294 }
2295
2296 if (FLOATP (prefer_prop[FONT_SIZE_INDEX])) 2279 if (FLOATP (prefer_prop[FONT_SIZE_INDEX]))
2297 prefer_prop[FONT_SIZE_INDEX] 2280 prefer_prop[FONT_SIZE_INDEX]
2298 = make_number (font_pixel_size (XFRAME (frame), prefer)); 2281 = make_number (font_pixel_size (XFRAME (frame), prefer));
@@ -2326,7 +2309,7 @@ font_sort_entites (vec, prefer, frame, spec, best_only)
2326 break; 2309 break;
2327 } 2310 }
2328 } 2311 }
2329 if (NILP (best_entity)) 2312 if (! best_only)
2330 { 2313 {
2331 qsort (data, len, sizeof *data, font_compare); 2314 qsort (data, len, sizeof *data, font_compare);
2332 for (i = 0; i < len; i++) 2315 for (i = 0; i < len; i++)
@@ -2546,7 +2529,7 @@ font_delete_unmatched (list, spec, size)
2546 && ((XINT (AREF (spec, prop)) >> 8) 2529 && ((XINT (AREF (spec, prop)) >> 8)
2547 != (XINT (AREF (entity, prop)) >> 8))) 2530 != (XINT (AREF (entity, prop)) >> 8)))
2548 prop = FONT_SPEC_MAX; 2531 prop = FONT_SPEC_MAX;
2549 if (prop++ <= FONT_SIZE_INDEX 2532 if (prop < FONT_SPEC_MAX
2550 && size 2533 && size
2551 && XINT (AREF (entity, FONT_SIZE_INDEX)) > 0) 2534 && XINT (AREF (entity, FONT_SIZE_INDEX)) > 0)
2552 { 2535 {
@@ -2557,6 +2540,17 @@ font_delete_unmatched (list, spec, size)
2557 : diff > FONT_PIXEL_SIZE_QUANTUM)) 2540 : diff > FONT_PIXEL_SIZE_QUANTUM))
2558 prop = FONT_SPEC_MAX; 2541 prop = FONT_SPEC_MAX;
2559 } 2542 }
2543 if (prop < FONT_SPEC_MAX
2544 && INTEGERP (AREF (spec, FONT_DPI_INDEX))
2545 && INTEGERP (AREF (entity, FONT_DPI_INDEX))
2546 && ! EQ (AREF (spec, FONT_DPI_INDEX), AREF (entity, FONT_DPI_INDEX)))
2547 prop = FONT_SPEC_MAX;
2548 if (prop < FONT_SPEC_MAX
2549 && INTEGERP (AREF (spec, FONT_AVGWIDTH_INDEX))
2550 && INTEGERP (AREF (entity, FONT_AVGWIDTH_INDEX))
2551 && ! EQ (AREF (spec, FONT_AVGWIDTH_INDEX),
2552 AREF (entity, FONT_AVGWIDTH_INDEX)))
2553 prop = FONT_SPEC_MAX;
2560 if (prop < FONT_SPEC_MAX) 2554 if (prop < FONT_SPEC_MAX)
2561 val = Fcons (entity, val); 2555 val = Fcons (entity, val);
2562 } 2556 }
@@ -3118,7 +3112,7 @@ font_find_for_lface (f, attrs, spec, c)
3118 if (NILP (AREF (prefer, FONT_WIDTH_INDEX))) 3112 if (NILP (AREF (prefer, FONT_WIDTH_INDEX)))
3119 FONT_SET_STYLE (prefer, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); 3113 FONT_SET_STYLE (prefer, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]);
3120 ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size)); 3114 ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size));
3121 entities = font_sort_entites (entities, prefer, frame, work, c < 0); 3115 entities = font_sort_entites (entities, prefer, frame, c < 0);
3122 } 3116 }
3123 if (c < 0) 3117 if (c < 0)
3124 return entities; 3118 return entities;
@@ -3885,7 +3879,7 @@ how close they are to PREFER. */)
3885 return Fcons (AREF (vec, 0), Qnil); 3879 return Fcons (AREF (vec, 0), Qnil);
3886 3880
3887 if (! NILP (prefer)) 3881 if (! NILP (prefer))
3888 vec = font_sort_entites (vec, prefer, frame, font_spec, 0); 3882 vec = font_sort_entites (vec, prefer, frame, 0);
3889 3883
3890 list = tail = Fcons (AREF (vec, 0), Qnil); 3884 list = tail = Fcons (AREF (vec, 0), Qnil);
3891 if (n == 0 || n > len) 3885 if (n == 0 || n > len)