aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2007-11-05 12:52:51 +0000
committerKenichi Handa2007-11-05 12:52:51 +0000
commit45eb10fb91764130622ba9430d4fcb8c87c8e227 (patch)
treeb765b06820b99e5e9ec04a961f75dedcdfba2818 /src
parentc5bb82f677c3e405ce4190bae34ae310e3346b35 (diff)
downloademacs-45eb10fb91764130622ba9430d4fcb8c87c8e227.tar.gz
emacs-45eb10fb91764130622ba9430d4fcb8c87c8e227.zip
(font_prop_validate_symbol): The argument prop_index is
deleted. (font_prop_validate_style, font_prop_validate_non_neg) (font_prop_validate_spacing): Likewise. (font_property_table): Arguments to validater changed. Callers changed. (font_lispy_object): Deleted. (font_at): Use font_find_object instead fo font_lispy_object.
Diffstat (limited to 'src')
-rw-r--r--src/font.c229
1 files changed, 166 insertions, 63 deletions
diff --git a/src/font.c b/src/font.c
index b35e462ae66..d192a29ded0 100644
--- a/src/font.c
+++ b/src/font.c
@@ -88,7 +88,7 @@ Lisp_Object null_string;
88Lisp_Object null_vector; 88Lisp_Object null_vector;
89 89
90/* Vector of 3 elements. Each element is an alist for one of font 90/* Vector of 3 elements. Each element is an alist for one of font
91 style properties (weight, slant, width). The alist contains a 91 style properties (weight, slant, width). Each alist contains a
92 mapping between symbolic property values (e.g. `medium' for weight) 92 mapping between symbolic property values (e.g. `medium' for weight)
93 and numeric property values (e.g. 100). So, it looks like this: 93 and numeric property values (e.g. 100). So, it looks like this:
94 [((thin . 0) ... (heavy . 210)) 94 [((thin . 0) ... (heavy . 210))
@@ -232,6 +232,11 @@ intern_downcase (str, len)
232 232
233extern Lisp_Object Vface_alternative_font_family_alist; 233extern Lisp_Object Vface_alternative_font_family_alist;
234 234
235/* Setup font_family_alist of the form:
236 ((FAMILY-SYMBOL ALIAS-SYMBOL ...) ...)
237 from Vface_alternative_font_family_alist of the form:
238 ((FAMILY-STRING ALIAS-STRING ...) ...) */
239
235static void 240static void
236build_font_family_alist () 241build_font_family_alist ()
237{ 242{
@@ -248,22 +253,18 @@ build_font_family_alist ()
248} 253}
249 254
250 255
251/* Font property validater. */ 256/* Font property value validaters. See the comment of
252 257 font_property_table for the meaning of the arguments. */
253static Lisp_Object font_prop_validate_symbol P_ ((enum font_property_index, 258
254 Lisp_Object, Lisp_Object)); 259static Lisp_Object font_prop_validate_symbol P_ ((Lisp_Object, Lisp_Object));
255static Lisp_Object font_prop_validate_style P_ ((enum font_property_index, 260static Lisp_Object font_prop_validate_style P_ ((Lisp_Object, Lisp_Object));
256 Lisp_Object, Lisp_Object)); 261static Lisp_Object font_prop_validate_non_neg P_ ((Lisp_Object, Lisp_Object));
257static Lisp_Object font_prop_validate_non_neg P_ ((enum font_property_index, 262static Lisp_Object font_prop_validate_spacing P_ ((Lisp_Object, Lisp_Object));
258 Lisp_Object, Lisp_Object));
259static Lisp_Object font_prop_validate_spacing P_ ((enum font_property_index,
260 Lisp_Object, Lisp_Object));
261static int get_font_prop_index P_ ((Lisp_Object, int)); 263static int get_font_prop_index P_ ((Lisp_Object, int));
262static Lisp_Object font_prop_validate P_ ((Lisp_Object)); 264static Lisp_Object font_prop_validate P_ ((Lisp_Object));
263 265
264static Lisp_Object 266static Lisp_Object
265font_prop_validate_symbol (prop_index, prop, val) 267font_prop_validate_symbol (prop, val)
266 enum font_property_index prop_index;
267 Lisp_Object prop, val; 268 Lisp_Object prop, val;
268{ 269{
269 if (EQ (prop, QCotf)) 270 if (EQ (prop, QCotf))
@@ -282,8 +283,7 @@ font_prop_validate_symbol (prop_index, prop, val)
282} 283}
283 284
284static Lisp_Object 285static Lisp_Object
285font_prop_validate_style (prop_index, prop, val) 286font_prop_validate_style (prop, val)
286 enum font_property_index prop_index;
287 Lisp_Object prop, val; 287 Lisp_Object prop, val;
288{ 288{
289 if (! INTEGERP (val)) 289 if (! INTEGERP (val))
@@ -294,6 +294,11 @@ font_prop_validate_style (prop_index, prop, val)
294 val = Qerror; 294 val = Qerror;
295 else 295 else
296 { 296 {
297 enum font_property_index prop_index
298 = (EQ (prop, QCweight) ? FONT_WEIGHT_INDEX
299 : EQ (prop, QCslant) ? FONT_SLANT_INDEX
300 : FONT_WIDTH_INDEX);
301
297 val = prop_name_to_numeric (prop_index, val); 302 val = prop_name_to_numeric (prop_index, val);
298 if (NILP (val)) 303 if (NILP (val))
299 val = Qerror; 304 val = Qerror;
@@ -303,8 +308,7 @@ font_prop_validate_style (prop_index, prop, val)
303} 308}
304 309
305static Lisp_Object 310static Lisp_Object
306font_prop_validate_non_neg (prop_index, prop, val) 311font_prop_validate_non_neg (prop, val)
307 enum font_property_index prop_index;
308 Lisp_Object prop, val; 312 Lisp_Object prop, val;
309{ 313{
310 return (NATNUMP (val) || (FLOATP (val) && XFLOAT_DATA (val) >= 0) 314 return (NATNUMP (val) || (FLOATP (val) && XFLOAT_DATA (val) >= 0)
@@ -312,8 +316,7 @@ font_prop_validate_non_neg (prop_index, prop, val)
312} 316}
313 317
314static Lisp_Object 318static Lisp_Object
315font_prop_validate_spacing (prop_index, prop, val) 319font_prop_validate_spacing (prop, val)
316 enum font_property_index prop_index;
317 Lisp_Object prop, val; 320 Lisp_Object prop, val;
318{ 321{
319 if (NILP (val) || (NATNUMP (val) && XINT (val) <= FONT_SPACING_CHARCELL)) 322 if (NILP (val) || (NATNUMP (val) && XINT (val) <= FONT_SPACING_CHARCELL))
@@ -333,9 +336,10 @@ struct
333{ 336{
334 /* Pointer to the key symbol. */ 337 /* Pointer to the key symbol. */
335 Lisp_Object *key; 338 Lisp_Object *key;
336 /* Function to validate the value VAL, or NULL if any value is ok. */ 339 /* Function to validate PROP's value VAL, or NULL if any value is
337 Lisp_Object (*validater) P_ ((enum font_property_index prop_index, 340 ok. The value is VAL or its regularized value if VAL is valid,
338 Lisp_Object prop, Lisp_Object val)); 341 and Qerror if not. */
342 Lisp_Object (*validater) P_ ((Lisp_Object prop, Lisp_Object val));
339} font_property_table[] = 343} font_property_table[] =
340 { { &QCtype, font_prop_validate_symbol }, 344 { { &QCtype, font_prop_validate_symbol },
341 { &QCfoundry, font_prop_validate_symbol }, 345 { &QCfoundry, font_prop_validate_symbol },
@@ -354,9 +358,14 @@ struct
354 { &QCotf, font_prop_validate_symbol } 358 { &QCotf, font_prop_validate_symbol }
355 }; 359 };
356 360
361/* Size (number of elements) of the above table. */
357#define FONT_PROPERTY_TABLE_SIZE \ 362#define FONT_PROPERTY_TABLE_SIZE \
358 ((sizeof font_property_table) / (sizeof *font_property_table)) 363 ((sizeof font_property_table) / (sizeof *font_property_table))
359 364
365/* Return an index number of font property KEY or -1 if KEY is not an
366 already known property. Start searching font_property_table from
367 index FROM (which is 0 or FONT_EXTRA_INDEX). */
368
360static int 369static int
361get_font_prop_index (key, from) 370get_font_prop_index (key, from)
362 Lisp_Object key; 371 Lisp_Object key;
@@ -368,6 +377,10 @@ get_font_prop_index (key, from)
368 return -1; 377 return -1;
369} 378}
370 379
380/* Validate font properties in SPEC (vector) while updating elements
381 to regularized values. Signal an error if an invalid property is
382 found. */
383
371static Lisp_Object 384static Lisp_Object
372font_prop_validate (spec) 385font_prop_validate (spec)
373 Lisp_Object spec; 386 Lisp_Object spec;
@@ -380,7 +393,7 @@ font_prop_validate (spec)
380 if (! NILP (AREF (spec, i))) 393 if (! NILP (AREF (spec, i)))
381 { 394 {
382 prop = *font_property_table[i].key; 395 prop = *font_property_table[i].key;
383 val = (font_property_table[i].validater) (i, prop, AREF (spec, i)); 396 val = (font_property_table[i].validater) (prop, AREF (spec, i));
384 if (EQ (val, Qerror)) 397 if (EQ (val, Qerror))
385 Fsignal (Qfont, list2 (build_string ("invalid font property"), 398 Fsignal (Qfont, list2 (build_string ("invalid font property"),
386 Fcons (prop, AREF (spec, i)))); 399 Fcons (prop, AREF (spec, i))));
@@ -397,7 +410,7 @@ font_prop_validate (spec)
397 if (i >= 0 410 if (i >= 0
398 && font_property_table[i].validater) 411 && font_property_table[i].validater)
399 { 412 {
400 val = (font_property_table[i].validater) (i, prop, XCDR (elt)); 413 val = (font_property_table[i].validater) (prop, XCDR (elt));
401 if (EQ (val, Qerror)) 414 if (EQ (val, Qerror))
402 Fsignal (Qfont, list2 (build_string ("invalid font property"), 415 Fsignal (Qfont, list2 (build_string ("invalid font property"),
403 elt)); 416 elt));
@@ -407,6 +420,8 @@ font_prop_validate (spec)
407 return spec; 420 return spec;
408} 421}
409 422
423/* Store VAL as a value of extra font property PROP in FONT. */
424
410Lisp_Object 425Lisp_Object
411font_put_extra (font, prop, val) 426font_put_extra (font, prop, val)
412 Lisp_Object font, prop, val; 427 Lisp_Object font, prop, val;
@@ -1357,6 +1372,10 @@ font_parse_name (name, font)
1357 return font_parse_fcname (name, font); 1372 return font_parse_fcname (name, font);
1358} 1373}
1359 1374
1375/* Merge old style font specification (either a font name NAME or a
1376 combination of a family name FAMILY and a registry name REGISTRY
1377 into the font specification SPEC. */
1378
1360void 1379void
1361font_merge_old_spec (name, family, registry, spec) 1380font_merge_old_spec (name, family, registry, spec)
1362 Lisp_Object name, family, registry, spec; 1381 Lisp_Object name, family, registry, spec;
@@ -1401,22 +1420,11 @@ font_merge_old_spec (name, family, registry, spec)
1401 } 1420 }
1402} 1421}
1403 1422
1404static Lisp_Object 1423
1405font_lispy_object (font) 1424/* This part (through the next ^L) is still experimental and never
1406 struct font *font; 1425 tested. We may drastically change codes. */
1407{
1408 Lisp_Object objlist = AREF (font->entity, FONT_OBJLIST_INDEX);
1409
1410 for (; ! NILP (objlist); objlist = XCDR (objlist))
1411 {
1412 struct Lisp_Save_Value *p = XSAVE_VALUE (XCAR (objlist));
1413 1426
1414 if (font == (struct font *) p->pointer) 1427/* OTF handler */
1415 break;
1416 }
1417 xassert (! NILP (objlist));
1418 return XCAR (objlist);
1419}
1420 1428
1421#define LGSTRING_HEADER_SIZE 6 1429#define LGSTRING_HEADER_SIZE 6
1422#define LGSTRING_GLYPH_SIZE 8 1430#define LGSTRING_GLYPH_SIZE 8
@@ -1476,9 +1484,6 @@ check_gstring (gstring)
1476 return -1; 1484 return -1;
1477} 1485}
1478 1486
1479
1480/* OTF handler */
1481
1482static void 1487static void
1483check_otf_features (otf_features) 1488check_otf_features (otf_features)
1484 Lisp_Object otf_features; 1489 Lisp_Object otf_features;
@@ -1978,7 +1983,6 @@ font_drive_otf (font, otf_features, gstring_in, from, to, gstring_out, idx,
1978 1983
1979#endif /* HAVE_LIBOTF */ 1984#endif /* HAVE_LIBOTF */
1980 1985
1981
1982/* G-string (glyph string) handler */ 1986/* G-string (glyph string) handler */
1983 1987
1984/* G-string is a vector of the form [HEADER GLYPH ...]. 1988/* G-string is a vector of the form [HEADER GLYPH ...].
@@ -2105,7 +2109,7 @@ static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object,
2105 font-spec. The score value is 32 bit (`unsigned'), and the smaller 2109 font-spec. The score value is 32 bit (`unsigned'), and the smaller
2106 the value is, the closer the font is to the font-spec. 2110 the value is, the closer the font is to the font-spec.
2107 2111
2108 Each 1-bit in the highest 4 bits of the score is used for atomic 2112 Each 1-bit of the highest 4 bits of the score is used for atomic
2109 properties FOUNDRY, FAMILY, ADSTYLE, and REGISTRY. 2113 properties FOUNDRY, FAMILY, ADSTYLE, and REGISTRY.
2110 2114
2111 Each 7-bit in the lowest 28 bits are used for numeric properties 2115 Each 7-bit in the lowest 28 bits are used for numeric properties
@@ -2235,6 +2239,10 @@ font_sort_entites (vec, prefer, frame, spec)
2235 2239
2236/* API of Font Service Layer. */ 2240/* API of Font Service Layer. */
2237 2241
2242/* Reflect ORDER (see the variable font_sort_order in xfaces.c) to
2243 sort_shift_bits. Finternal_set_font_selection_order calls this
2244 function with font_sort_order after setting up it. */
2245
2238void 2246void
2239font_update_sort_order (order) 2247font_update_sort_order (order)
2240 int *order; 2248 int *order;
@@ -2256,6 +2264,9 @@ font_update_sort_order (order)
2256 } 2264 }
2257} 2265}
2258 2266
2267
2268/* Return weight property of FONT as symbol. */
2269
2259Lisp_Object 2270Lisp_Object
2260font_symbolic_weight (font) 2271font_symbolic_weight (font)
2261 Lisp_Object font; 2272 Lisp_Object font;
@@ -2267,6 +2278,9 @@ font_symbolic_weight (font)
2267 return weight; 2278 return weight;
2268} 2279}
2269 2280
2281
2282/* Return slant property of FONT as symbol. */
2283
2270Lisp_Object 2284Lisp_Object
2271font_symbolic_slant (font) 2285font_symbolic_slant (font)
2272 Lisp_Object font; 2286 Lisp_Object font;
@@ -2278,6 +2292,9 @@ font_symbolic_slant (font)
2278 return slant; 2292 return slant;
2279} 2293}
2280 2294
2295
2296/* Return width property of FONT as symbol. */
2297
2281Lisp_Object 2298Lisp_Object
2282font_symbolic_width (font) 2299font_symbolic_width (font)
2283 Lisp_Object font; 2300 Lisp_Object font;
@@ -2289,6 +2306,9 @@ font_symbolic_width (font)
2289 return width; 2306 return width;
2290} 2307}
2291 2308
2309
2310/* Check if ENTITY matches with the font specification SPEC. */
2311
2292int 2312int
2293font_match_p (spec, entity) 2313font_match_p (spec, entity)
2294 Lisp_Object spec, entity; 2314 Lisp_Object spec, entity;
@@ -2307,6 +2327,9 @@ font_match_p (spec, entity)
2307 return 1; 2327 return 1;
2308} 2328}
2309 2329
2330
2331/* Return a lispy font object corresponding to FONT. */
2332
2310Lisp_Object 2333Lisp_Object
2311font_find_object (font) 2334font_find_object (font)
2312 struct font *font; 2335 struct font *font;
@@ -2327,6 +2350,7 @@ font_find_object (font)
2327 2350
2328static Lisp_Object scratch_font_spec, scratch_font_prefer; 2351static Lisp_Object scratch_font_spec, scratch_font_prefer;
2329 2352
2353
2330/* Return a vector of font-entities matching with SPEC on frame F. */ 2354/* Return a vector of font-entities matching with SPEC on frame F. */
2331 2355
2332static Lisp_Object 2356static Lisp_Object
@@ -2402,6 +2426,9 @@ font_list_entities (frame, spec)
2402 return (i > 0 ? Fvconcat (i, vec) : null_vector); 2426 return (i > 0 ? Fvconcat (i, vec) : null_vector);
2403} 2427}
2404 2428
2429
2430/* Return a font entity matching with SPEC on FRAME. */
2431
2405static Lisp_Object 2432static Lisp_Object
2406font_matching_entity (frame, spec) 2433font_matching_entity (frame, spec)
2407 Lisp_Object frame, spec; 2434 Lisp_Object frame, spec;
@@ -2447,6 +2474,10 @@ font_matching_entity (frame, spec)
2447 2474
2448static int num_fonts; 2475static int num_fonts;
2449 2476
2477
2478/* Open a font of ENTITY and PIXEL_SIZE on frame F, and return the
2479 opened font object. */
2480
2450static Lisp_Object 2481static Lisp_Object
2451font_open_entity (f, entity, pixel_size) 2482font_open_entity (f, entity, pixel_size)
2452 FRAME_PTR f; 2483 FRAME_PTR f;
@@ -2493,6 +2524,9 @@ font_open_entity (f, entity, pixel_size)
2493 return val; 2524 return val;
2494} 2525}
2495 2526
2527
2528/* Close FONT_OBJECT that is opened on frame F. */
2529
2496void 2530void
2497font_close_object (f, font_object) 2531font_close_object (f, font_object)
2498 FRAME_PTR f; 2532 FRAME_PTR f;
@@ -2524,6 +2558,9 @@ font_close_object (f, font_object)
2524 abort (); 2558 abort ();
2525} 2559}
2526 2560
2561
2562/* Return 1 iff FONT on F has a glyph for character C. */
2563
2527int 2564int
2528font_has_char (f, font, c) 2565font_has_char (f, font, c)
2529 FRAME_PTR f; 2566 FRAME_PTR f;
@@ -2560,6 +2597,9 @@ font_has_char (f, font, c)
2560 return (fontp->driver->encode_char (fontp, c) != FONT_INVALID_CODE); 2597 return (fontp->driver->encode_char (fontp, c) != FONT_INVALID_CODE);
2561} 2598}
2562 2599
2600
2601/* Return the glyph ID of FONT_OBJECT for character C. */
2602
2563unsigned 2603unsigned
2564font_encode_char (font_object, c) 2604font_encode_char (font_object, c)
2565 Lisp_Object font_object; 2605 Lisp_Object font_object;
@@ -2570,6 +2610,9 @@ font_encode_char (font_object, c)
2570 return font->driver->encode_char (font, c); 2610 return font->driver->encode_char (font, c);
2571} 2611}
2572 2612
2613
2614/* Return the name of FONT_OBJECT. */
2615
2573Lisp_Object 2616Lisp_Object
2574font_get_name (font_object) 2617font_get_name (font_object)
2575 Lisp_Object font_object; 2618 Lisp_Object font_object;
@@ -2582,6 +2625,9 @@ font_get_name (font_object)
2582 return (name ? make_unibyte_string (name, strlen (name)) : null_string); 2625 return (name ? make_unibyte_string (name, strlen (name)) : null_string);
2583} 2626}
2584 2627
2628
2629/* Return the specification of FONT_OBJECT. */
2630
2585Lisp_Object 2631Lisp_Object
2586font_get_spec (font_object) 2632font_get_spec (font_object)
2587 Lisp_Object font_object; 2633 Lisp_Object font_object;
@@ -2596,6 +2642,10 @@ font_get_spec (font_object)
2596 return spec; 2642 return spec;
2597} 2643}
2598 2644
2645
2646/* Return the frame on which FONT exists. FONT is a font object or a
2647 font entity. */
2648
2599Lisp_Object 2649Lisp_Object
2600font_get_frame (font) 2650font_get_frame (font)
2601 Lisp_Object font; 2651 Lisp_Object font;
@@ -2606,6 +2656,7 @@ font_get_frame (font)
2606 return AREF (font, FONT_FRAME_INDEX); 2656 return AREF (font, FONT_FRAME_INDEX);
2607} 2657}
2608 2658
2659
2609/* Find a font entity best matching with LFACE. If SPEC is non-nil, 2660/* Find a font entity best matching with LFACE. If SPEC is non-nil,
2610 the font must exactly match with it. */ 2661 the font must exactly match with it. */
2611 2662
@@ -2667,14 +2718,11 @@ font_find_for_lface (f, lface, spec)
2667 if (! NILP (lface[LFACE_FAMILY_INDEX])) 2718 if (! NILP (lface[LFACE_FAMILY_INDEX]))
2668 font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, prefer); 2719 font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, prefer);
2669 ASET (prefer, FONT_WEIGHT_INDEX, 2720 ASET (prefer, FONT_WEIGHT_INDEX,
2670 font_prop_validate_style (FONT_WEIGHT_INDEX, QCweight, 2721 font_prop_validate_style (QCweight, lface[LFACE_WEIGHT_INDEX]));
2671 lface[LFACE_WEIGHT_INDEX]));
2672 ASET (prefer, FONT_SLANT_INDEX, 2722 ASET (prefer, FONT_SLANT_INDEX,
2673 font_prop_validate_style (FONT_SLANT_INDEX, QCslant, 2723 font_prop_validate_style (QCslant, lface[LFACE_SLANT_INDEX]));
2674 lface[LFACE_SLANT_INDEX]));
2675 ASET (prefer, FONT_WIDTH_INDEX, 2724 ASET (prefer, FONT_WIDTH_INDEX,
2676 font_prop_validate_style (FONT_WIDTH_INDEX, QCwidth, 2725 font_prop_validate_style (QCwidth, lface[LFACE_SWIDTH_INDEX]));
2677 lface[LFACE_SWIDTH_INDEX]));
2678 pt = XINT (lface[LFACE_HEIGHT_INDEX]); 2726 pt = XINT (lface[LFACE_HEIGHT_INDEX]);
2679 ASET (prefer, FONT_SIZE_INDEX, make_float (pt / 10)); 2727 ASET (prefer, FONT_SIZE_INDEX, make_float (pt / 10));
2680 2728
@@ -2684,6 +2732,9 @@ font_find_for_lface (f, lface, spec)
2684 return AREF (entities, 0); 2732 return AREF (entities, 0);
2685} 2733}
2686 2734
2735
2736
2737
2687Lisp_Object 2738Lisp_Object
2688font_open_for_lface (f, entity, lface, spec) 2739font_open_for_lface (f, entity, lface, spec)
2689 FRAME_PTR f; 2740 FRAME_PTR f;
@@ -2705,6 +2756,11 @@ font_open_for_lface (f, entity, lface, spec)
2705 return font_open_entity (f, entity, size); 2756 return font_open_entity (f, entity, size);
2706} 2757}
2707 2758
2759
2760/* Load a font best matching with FACE's font-related properties into
2761 FACE on frame F. If no proper font is found, record that FACE has
2762 no font. */
2763
2708void 2764void
2709font_load_for_face (f, face) 2765font_load_for_face (f, face)
2710 FRAME_PTR f; 2766 FRAME_PTR f;
@@ -2739,6 +2795,9 @@ font_load_for_face (f, face)
2739 } 2795 }
2740} 2796}
2741 2797
2798
2799/* Make FACE on frame F ready to use the font opened for FACE. */
2800
2742void 2801void
2743font_prepare_for_face (f, face) 2802font_prepare_for_face (f, face)
2744 FRAME_PTR f; 2803 FRAME_PTR f;
@@ -2750,6 +2809,9 @@ font_prepare_for_face (f, face)
2750 font->driver->prepare_face (f, face); 2809 font->driver->prepare_face (f, face);
2751} 2810}
2752 2811
2812
2813/* Make FACE on frame F stop using the font opened for FACE. */
2814
2753void 2815void
2754font_done_for_face (f, face) 2816font_done_for_face (f, face)
2755 FRAME_PTR f; 2817 FRAME_PTR f;
@@ -2762,6 +2824,10 @@ font_done_for_face (f, face)
2762 face->extra = NULL; 2824 face->extra = NULL;
2763} 2825}
2764 2826
2827
2828/* Open a font best matching with NAME on frame F. If no proper font
2829 is found, return Qnil. */
2830
2765Lisp_Object 2831Lisp_Object
2766font_open_by_name (f, name) 2832font_open_by_name (f, name)
2767 FRAME_PTR f; 2833 FRAME_PTR f;
@@ -2856,6 +2922,7 @@ register_font_driver (driver, f)
2856 num_font_drivers++; 2922 num_font_drivers++;
2857} 2923}
2858 2924
2925
2859/* Free font-driver list on frame F. It doesn't free font-drivers 2926/* Free font-driver list on frame F. It doesn't free font-drivers
2860 themselves. */ 2927 themselves. */
2861 2928
@@ -2872,6 +2939,7 @@ free_font_driver_list (f)
2872 } 2939 }
2873} 2940}
2874 2941
2942
2875/* Make the frame F use font backends listed in NEW_BACKENDS (list of 2943/* Make the frame F use font backends listed in NEW_BACKENDS (list of
2876 symbols). If NEW_BACKENDS is nil, make F use all available font 2944 symbols). If NEW_BACKENDS is nil, make F use all available font
2877 drivers. If no backend is available, dont't alter 2945 drivers. If no backend is available, dont't alter
@@ -2907,6 +2975,10 @@ font_update_drivers (f, new_drivers)
2907} 2975}
2908 2976
2909 2977
2978/* Return the font used to draw character C by FACE at buffer position
2979 POS in window W. If OBJECT is non-nil, it is a string containing C
2980 at index POS. */
2981
2910Lisp_Object 2982Lisp_Object
2911font_at (c, pos, face, w, object) 2983font_at (c, pos, face, w, object)
2912 int c; 2984 int c;
@@ -2936,14 +3008,15 @@ font_at (c, pos, face, w, object)
2936 face = FACE_FROM_ID (f, face_id); 3008 face = FACE_FROM_ID (f, face_id);
2937 if (! face->font_info) 3009 if (! face->font_info)
2938 return Qnil; 3010 return Qnil;
2939 return font_lispy_object ((struct font *) face->font_info); 3011 return font_find_object ((struct font *) face->font_info);
2940} 3012}
2941 3013
2942 3014
2943/* Lisp API */ 3015/* Lisp API */
2944 3016
2945DEFUN ("fontp", Ffontp, Sfontp, 1, 1, 0, 3017DEFUN ("fontp", Ffontp, Sfontp, 1, 1, 0,
2946 doc: /* Return t if OBJECT is a font-spec or font-entity. */) 3018 doc: /* Return t if OBJECT is a font-spec or font-entity.
3019Return nil otherwise. */)
2947 (object) 3020 (object)
2948 Lisp_Object object; 3021 Lisp_Object object;
2949{ 3022{
@@ -2951,8 +3024,35 @@ DEFUN ("fontp", Ffontp, Sfontp, 1, 1, 0,
2951} 3024}
2952 3025
2953DEFUN ("font-spec", Ffont_spec, Sfont_spec, 0, MANY, 0, 3026DEFUN ("font-spec", Ffont_spec, Sfont_spec, 0, MANY, 0,
2954 doc: /* Return a newly created font-spec with specified arguments as properties. 3027 doc: /* Return a newly created font-spec with arguments as properties.
2955usage: (font-spec &rest properties) */) 3028
3029ARGS must come in pairs KEY VALUE of font properties. KEY must be a
3030valid font property name listed below:
3031
3032`:family', `:weight', `:slant', `:width'
3033
3034They are the same as face attributes of the same name. See
3035`set-face-attribute.
3036
3037`:foundry'
3038
3039VALUE must be a string or a symbol specifying the font foundry, e.g. ``misc''.
3040
3041`:adstyle'
3042
3043VALUE must be a string or a symbol specifying the additional
3044typographic style information of a font, e.g. ``sans''. Usually null.
3045
3046`:registry'
3047
3048VALUE must be a string or a symbol specifying the charset registry and
3049encoding of a font, e.g. ``iso8859-1''.
3050
3051`:size'
3052
3053VALUE must be a non-negative integer or a floating point number
3054specifying the font size. It specifies the font size in 1/10 pixels
3055(if VALUE is an integer), or in points (if VALUE is a float). */)
2956 (nargs, args) 3056 (nargs, args)
2957 int nargs; 3057 int nargs;
2958 Lisp_Object *args; 3058 Lisp_Object *args;
@@ -2984,10 +3084,10 @@ usage: (font-spec &rest properties) */)
2984 3084
2985 3085
2986DEFUN ("font-get", Ffont_get, Sfont_get, 2, 2, 0, 3086DEFUN ("font-get", Ffont_get, Sfont_get, 2, 2, 0,
2987 doc: /* Return the value of FONT's PROP property. 3087 doc: /* Return the value of FONT's property KEY.
2988FONT is a font-spec, a font-entity, or a font-object. */) 3088FONT is a font-spec, a font-entity, or a font-object. */)
2989 (font, prop) 3089 (font, key)
2990 Lisp_Object font, prop; 3090 Lisp_Object font, key;
2991{ 3091{
2992 enum font_property_index idx; 3092 enum font_property_index idx;
2993 3093
@@ -2995,7 +3095,7 @@ FONT is a font-spec, a font-entity, or a font-object. */)
2995 { 3095 {
2996 struct font *fontp = XSAVE_VALUE (font)->pointer; 3096 struct font *fontp = XSAVE_VALUE (font)->pointer;
2997 3097
2998 if (EQ (prop, QCotf)) 3098 if (EQ (key, QCotf))
2999 { 3099 {
3000 if (fontp->driver->otf_capability) 3100 if (fontp->driver->otf_capability)
3001 return fontp->driver->otf_capability (fontp); 3101 return fontp->driver->otf_capability (fontp);
@@ -3006,17 +3106,17 @@ FONT is a font-spec, a font-entity, or a font-object. */)
3006 } 3106 }
3007 else 3107 else
3008 CHECK_FONT (font); 3108 CHECK_FONT (font);
3009 idx = get_font_prop_index (prop, 0); 3109 idx = get_font_prop_index (key, 0);
3010 if (idx < FONT_EXTRA_INDEX) 3110 if (idx < FONT_EXTRA_INDEX)
3011 return AREF (font, idx); 3111 return AREF (font, idx);
3012 if (FONT_ENTITY_P (font)) 3112 if (FONT_ENTITY_P (font))
3013 return Qnil; 3113 return Qnil;
3014 return Fcdr (Fassoc (AREF (font, FONT_EXTRA_INDEX), prop)); 3114 return Fcdr (Fassoc (AREF (font, FONT_EXTRA_INDEX), key));
3015} 3115}
3016 3116
3017 3117
3018DEFUN ("font-put", Ffont_put, Sfont_put, 3, 3, 0, 3118DEFUN ("font-put", Ffont_put, Sfont_put, 3, 3, 0,
3019 doc: /* Set one property of FONT-SPEC: give property PROP value VALUE. */) 3119 doc: /* Set one property of FONT-SPEC: give property KEY value VALUE. */)
3020 (font_spec, prop, val) 3120 (font_spec, prop, val)
3021 Lisp_Object font_spec, prop, val; 3121 Lisp_Object font_spec, prop, val;
3022{ 3122{
@@ -3040,8 +3140,9 @@ DEFUN ("list-fonts", Flist_fonts, Slist_fonts, 1, 4, 0,
3040 doc: /* List available fonts matching FONT-SPEC on the current frame. 3140 doc: /* List available fonts matching FONT-SPEC on the current frame.
3041Optional 2nd argument FRAME specifies the target frame. 3141Optional 2nd argument FRAME specifies the target frame.
3042Optional 3rd argument NUM, if non-nil, limits the number of returned fonts. 3142Optional 3rd argument NUM, if non-nil, limits the number of returned fonts.
3043Optional 4th argument PREFER, if non-nil, is a font-spec 3143Optional 4th argument PREFER, if non-nil, is a font-spec to
3044to which closeness fonts are sorted. */) 3144control the order of the returned list. Fonts are sorted by
3145how they are close to PREFER. */)
3045 (font_spec, frame, num, prefer) 3146 (font_spec, frame, num, prefer)
3046 Lisp_Object font_spec, frame, num, prefer; 3147 Lisp_Object font_spec, frame, num, prefer;
3047{ 3148{
@@ -3258,6 +3359,8 @@ sorted by numeric values. */)
3258 return Qnil; 3359 return Qnil;
3259} 3360}
3260 3361
3362/* The following three functions are still expremental. */
3363
3261DEFUN ("font-make-gstring", Ffont_make_gstring, Sfont_make_gstring, 2, 2, 0, 3364DEFUN ("font-make-gstring", Ffont_make_gstring, Sfont_make_gstring, 2, 2, 0,
3262 doc: /* Return a newly created g-string for FONT-OBJECT with NUM glyphs. 3365 doc: /* Return a newly created g-string for FONT-OBJECT with NUM glyphs.
3263FONT-OBJECT may be nil if it is not yet known. 3366FONT-OBJECT may be nil if it is not yet known.