diff options
| author | Kenichi Handa | 2000-12-04 06:26:38 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-12-04 06:26:38 +0000 |
| commit | 8e1b21a7db4a23759ec6423c035f5c5e4ccdcc42 (patch) | |
| tree | 5a771c7293316586e2333ecd4d616bbe9e29c033 /src | |
| parent | 1bdeec2e3cfaef16b3efeea508b8d36153a60949 (diff) | |
| download | emacs-8e1b21a7db4a23759ec6423c035f5c5e4ccdcc42.tar.gz emacs-8e1b21a7db4a23759ec6423c035f5c5e4ccdcc42.zip | |
(struct font_name): New member registry_priority.
(split_font_name): Initialize the above member to zero.
(concat_font_list): New function.
(font_list): Include fonts of all alternative registries.
(FONT_POINT_SIZE_QUANTUM): New macro.
(better_font_p): Ignore point size difference less than
FONT_POINT_SIZE_QUANTUM. Use registry_prioprity as a last resort.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfaces.c | 68 |
1 files changed, 58 insertions, 10 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index 4499bca6e4e..cad7c072502 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -1827,6 +1827,9 @@ struct font_name | |||
| 1827 | /* Numeric values for those fields that interest us. See | 1827 | /* Numeric values for those fields that interest us. See |
| 1828 | split_font_name for which these are. */ | 1828 | split_font_name for which these are. */ |
| 1829 | int numeric[XLFD_LAST]; | 1829 | int numeric[XLFD_LAST]; |
| 1830 | |||
| 1831 | /* Lower value mean higher priority. */ | ||
| 1832 | int registry_priority; | ||
| 1830 | }; | 1833 | }; |
| 1831 | 1834 | ||
| 1832 | /* The frame in effect when sorting font names. Set temporarily in | 1835 | /* The frame in effect when sorting font names. Set temporarily in |
| @@ -2176,6 +2179,10 @@ split_font_name (f, font, numeric_p) | |||
| 2176 | font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font); | 2179 | font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font); |
| 2177 | } | 2180 | } |
| 2178 | 2181 | ||
| 2182 | /* Initialize it to zero. It will be overridden by font_list while | ||
| 2183 | trying alternate registries. */ | ||
| 2184 | font->registry_priority = 0; | ||
| 2185 | |||
| 2179 | return success_p; | 2186 | return success_p; |
| 2180 | } | 2187 | } |
| 2181 | 2188 | ||
| @@ -2547,13 +2554,34 @@ font_list_1 (f, pattern, family, registry, fonts) | |||
| 2547 | } | 2554 | } |
| 2548 | 2555 | ||
| 2549 | 2556 | ||
| 2557 | /* Concatenate font list FONTS1 and FONTS2. FONTS1 and FONTS2 | ||
| 2558 | contains NFONTS1 fonts and NFONTS2 fonts respectively. Return a | ||
| 2559 | pointer to a newly allocated font list. FONTS1 and FONTS2 are | ||
| 2560 | freed. */ | ||
| 2561 | |||
| 2562 | static struct font_name * | ||
| 2563 | concat_font_list (fonts1, nfonts1, fonts2, nfonts2) | ||
| 2564 | struct font_name *fonts1, *fonts2; | ||
| 2565 | int nfonts1, nfonts2; | ||
| 2566 | { | ||
| 2567 | int new_nfonts = nfonts1 + nfonts2; | ||
| 2568 | struct font_name *new_fonts; | ||
| 2569 | |||
| 2570 | new_fonts = (struct font_name *) xmalloc (sizeof *new_fonts * new_nfonts); | ||
| 2571 | bcopy (fonts1, new_fonts, sizeof *new_fonts * nfonts1); | ||
| 2572 | bcopy (fonts2, new_fonts + nfonts1, sizeof *new_fonts * nfonts2); | ||
| 2573 | xfree (fonts1); | ||
| 2574 | xfree (fonts2); | ||
| 2575 | return new_fonts; | ||
| 2576 | } | ||
| 2577 | |||
| 2578 | |||
| 2550 | /* Get a sorted list of fonts of family FAMILY on frame F. | 2579 | /* Get a sorted list of fonts of family FAMILY on frame F. |
| 2551 | 2580 | ||
| 2552 | If PATTERN is non-nil list fonts matching that pattern. | 2581 | If PATTERN is non-nil list fonts matching that pattern. |
| 2553 | 2582 | ||
| 2554 | If REGISTRY is non-nil, retur fonts with that registry. If none | 2583 | If REGISTRY is non-nil, return fonts with that registry and the |
| 2555 | are found, try alternative registries from | 2584 | alternative registries from Vface_alternative_font_registry_alist. |
| 2556 | Vface_alternative_font_registry_alist. | ||
| 2557 | 2585 | ||
| 2558 | If REGISTRY is nil return fonts of any registry. | 2586 | If REGISTRY is nil return fonts of any registry. |
| 2559 | 2587 | ||
| @@ -2569,8 +2597,7 @@ font_list (f, pattern, family, registry, fonts) | |||
| 2569 | { | 2597 | { |
| 2570 | int nfonts = font_list_1 (f, pattern, family, registry, fonts); | 2598 | int nfonts = font_list_1 (f, pattern, family, registry, fonts); |
| 2571 | 2599 | ||
| 2572 | if (nfonts == 0 | 2600 | if (!NILP (registry) |
| 2573 | && !NILP (registry) | ||
| 2574 | && CONSP (Vface_alternative_font_registry_alist)) | 2601 | && CONSP (Vface_alternative_font_registry_alist)) |
| 2575 | { | 2602 | { |
| 2576 | Lisp_Object alter; | 2603 | Lisp_Object alter; |
| @@ -2578,11 +2605,25 @@ font_list (f, pattern, family, registry, fonts) | |||
| 2578 | alter = Fassoc (registry, Vface_alternative_font_registry_alist); | 2605 | alter = Fassoc (registry, Vface_alternative_font_registry_alist); |
| 2579 | if (CONSP (alter)) | 2606 | if (CONSP (alter)) |
| 2580 | { | 2607 | { |
| 2581 | for (alter = XCDR (alter); | 2608 | int reg_prio, i; |
| 2582 | CONSP (alter) && nfonts == 0; | 2609 | |
| 2583 | alter = XCDR (alter)) | 2610 | for (alter = XCDR (alter), reg_prio = 1; |
| 2611 | CONSP (alter); | ||
| 2612 | alter = XCDR (alter), reg_prio++) | ||
| 2584 | if (STRINGP (XCAR (alter))) | 2613 | if (STRINGP (XCAR (alter))) |
| 2585 | nfonts = font_list_1 (f, pattern, family, XCAR (alter), fonts); | 2614 | { |
| 2615 | int nfonts2; | ||
| 2616 | struct font_name *fonts2; | ||
| 2617 | |||
| 2618 | nfonts2 = font_list_1 (f, pattern, family, XCAR (alter), | ||
| 2619 | &fonts2); | ||
| 2620 | for (i = 0; i < nfonts2; i++) | ||
| 2621 | fonts2[i].registry_priority = reg_prio; | ||
| 2622 | *fonts = (nfonts > 0 | ||
| 2623 | ? concat_font_list (*fonts, nfonts, fonts2, nfonts2) | ||
| 2624 | : fonts2); | ||
| 2625 | nfonts += nfonts2; | ||
| 2626 | } | ||
| 2586 | } | 2627 | } |
| 2587 | } | 2628 | } |
| 2588 | 2629 | ||
| @@ -5614,6 +5655,10 @@ font_scalable_p (font) | |||
| 5614 | } | 5655 | } |
| 5615 | 5656 | ||
| 5616 | 5657 | ||
| 5658 | /* Ignore the difference of font point size less than this value. */ | ||
| 5659 | |||
| 5660 | #define FONT_POINT_SIZE_QUANTUM 5 | ||
| 5661 | |||
| 5617 | /* Value is non-zero if FONT1 is a better match for font attributes | 5662 | /* Value is non-zero if FONT1 is a better match for font attributes |
| 5618 | VALUES than FONT2. VALUES is an array of face attribute values in | 5663 | VALUES than FONT2. VALUES is an array of face attribute values in |
| 5619 | font sort order. COMPARE_PT_P zero means don't compare point | 5664 | font sort order. COMPARE_PT_P zero means don't compare point |
| @@ -5636,6 +5681,9 @@ better_font_p (values, font1, font2, compare_pt_p) | |||
| 5636 | int delta1 = abs (values[i] - font1->numeric[xlfd_idx]); | 5681 | int delta1 = abs (values[i] - font1->numeric[xlfd_idx]); |
| 5637 | int delta2 = abs (values[i] - font2->numeric[xlfd_idx]); | 5682 | int delta2 = abs (values[i] - font2->numeric[xlfd_idx]); |
| 5638 | 5683 | ||
| 5684 | if (xlfd_idx == XLFD_POINT_SIZE | ||
| 5685 | && abs (delta1 - delta2) < FONT_POINT_SIZE_QUANTUM) | ||
| 5686 | continue; | ||
| 5639 | if (delta1 > delta2) | 5687 | if (delta1 > delta2) |
| 5640 | return 0; | 5688 | return 0; |
| 5641 | else if (delta1 < delta2) | 5689 | else if (delta1 < delta2) |
| @@ -5653,7 +5701,7 @@ better_font_p (values, font1, font2, compare_pt_p) | |||
| 5653 | } | 5701 | } |
| 5654 | } | 5702 | } |
| 5655 | 5703 | ||
| 5656 | return 0; | 5704 | return (font1->registry_priority < font2->registry_priority); |
| 5657 | } | 5705 | } |
| 5658 | 5706 | ||
| 5659 | 5707 | ||