aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2003-12-29 06:54:55 +0000
committerKenichi Handa2003-12-29 06:54:55 +0000
commitb64c9a0407fd9dca20476063af98e604bdd2701f (patch)
treea0de14ddbb12a656587df4ecac952ac606034148 /src
parent2f65c7b5ef9afed29c365ed08c7b149e0b8ac69c (diff)
downloademacs-b64c9a0407fd9dca20476063af98e604bdd2701f.tar.gz
emacs-b64c9a0407fd9dca20476063af98e604bdd2701f.zip
(face_font_available_p): New function.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 55455abdbd7..bb95b1494fe 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -2562,6 +2562,69 @@ x_face_list_fonts (f, pattern, pfonts, nfonts, try_alternatives_p)
2562} 2562}
2563 2563
2564 2564
2565/* Check if a font matching pattern_offset_t on frame F is available
2566 or not. PATTERN may be a cons (FAMILY . REGISTRY), in which case,
2567 a font name pattern is generated from FAMILY and REGISTRY. */
2568
2569int
2570face_font_available_p (f, pattern)
2571 struct frame *f;
2572 Lisp_Object pattern;
2573{
2574 Lisp_Object fonts;
2575
2576 if (! STRINGP (pattern))
2577 {
2578 Lisp_Object family, registry;
2579 char *family_str, *registry_str, *pattern_str;
2580
2581 CHECK_CONS (pattern);
2582 family = XCAR (pattern);
2583 if (NILP (family))
2584 family_str = "*";
2585 else
2586 {
2587 CHECK_STRING (family);
2588 family_str = (char *) SDATA (family);
2589 }
2590 registry = XCDR (pattern);
2591 if (NILP (registry))
2592 registry_str = "*";
2593 else
2594 {
2595 CHECK_STRING (registry);
2596 registry_str = (char *) SDATA (registry);
2597 }
2598
2599 pattern_str = (char *) alloca (strlen (family_str)
2600 + strlen (registry_str)
2601 + 10);
2602 strcpy (pattern_str, index (family_str, '-') ? "-" : "-*-");
2603 strcat (pattern_str, family_str);
2604 strcat (pattern_str, "-*-");
2605 strcat (pattern_str, registry_str);
2606 if (!index (registry_str, '-'))
2607 {
2608 if (registry_str[strlen (registry_str) - 1] == '*')
2609 strcat (pattern_str, "-*");
2610 else
2611 strcat (pattern_str, "*-*");
2612 }
2613 pattern = build_string (pattern_str);
2614 }
2615
2616 /* Get the list of fonts matching PATTERN. */
2617#ifdef WINDOWSNT
2618 BLOCK_INPUT;
2619 fonts = w32_list_fonts (f, pattern, 0, 1);
2620 UNBLOCK_INPUT;
2621#else
2622 fonts = x_list_fonts (f, pattern, -1, 1);
2623#endif
2624 return XINT (Flength (fonts));
2625}
2626
2627
2565/* Determine fonts matching PATTERN on frame F. Sort resulting fonts 2628/* Determine fonts matching PATTERN on frame F. Sort resulting fonts
2566 using comparison function CMPFN. Value is the number of fonts 2629 using comparison function CMPFN. Value is the number of fonts
2567 found. If value is non-zero, *FONTS is set to a vector of 2630 found. If value is non-zero, *FONTS is set to a vector of