diff options
| author | Dmitry Antipov | 2013-08-01 14:33:25 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-08-01 14:33:25 +0400 |
| commit | fdb396e222923dc98d46c170381c6b33dc1e8d99 (patch) | |
| tree | 9cf9c6074b8386eec0f9e7d0e610b98447894d4a /src/font.c | |
| parent | 2f935d86fd7aa551e2c61d71c14a1c1a8b3ba707 (diff) | |
| download | emacs-fdb396e222923dc98d46c170381c6b33dc1e8d99.tar.gz emacs-fdb396e222923dc98d46c170381c6b33dc1e8d99.zip | |
Avoid redundant Lisp_Object <-> struct frame conversions in font API.
* font.h (struct font_driver): Change list, match, and list_family
functions to accept struct frame * as first arg.
* font.c (font_score, font_compare, font_sort_entities): Remove
prototypes.
(font_sort_entities, font_list_entities, font_select_entity):
(font_find_for_lface, Flist_fonts, Ffont_family_list): Adjust to
match font API change.
* xfont.c (xfont_list, xfont_match, xfont_list_family):
* ftfont.c (ftfont_list, ftfont_match, ftfont_list_family):
* ftxfont.c (ftxfont_list, ftxfont_match):
* xftfont.c (xftfont_list, xftfont_match):
* nsfont.m (nsfont_list, nsfont_match, nsfont_list_family):
* w32font.c (w32font_list, w32font_match, w32font_list):
(w32font_list_internal, w32_font_match_internal): Likewise.
* xfaces.c (Fx_family_fonts): Adjust user.
Diffstat (limited to 'src/font.c')
| -rw-r--r-- | src/font.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/src/font.c b/src/font.c index 124d5f9bd9e..c9b9b5722a3 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -2037,11 +2037,6 @@ font_otf_Anchor (OTF_Anchor *anchor) | |||
| 2037 | 2037 | ||
| 2038 | /* Font sorting. */ | 2038 | /* Font sorting. */ |
| 2039 | 2039 | ||
| 2040 | static unsigned font_score (Lisp_Object, Lisp_Object *); | ||
| 2041 | static int font_compare (const void *, const void *); | ||
| 2042 | static Lisp_Object font_sort_entities (Lisp_Object, Lisp_Object, | ||
| 2043 | Lisp_Object, int); | ||
| 2044 | |||
| 2045 | static double | 2040 | static double |
| 2046 | font_rescale_ratio (Lisp_Object font_entity) | 2041 | font_rescale_ratio (Lisp_Object font_entity) |
| 2047 | { | 2042 | { |
| @@ -2186,14 +2181,14 @@ font_compare (const void *d1, const void *d2) | |||
| 2186 | such a case. */ | 2181 | such a case. */ |
| 2187 | 2182 | ||
| 2188 | static Lisp_Object | 2183 | static Lisp_Object |
| 2189 | font_sort_entities (Lisp_Object list, Lisp_Object prefer, Lisp_Object frame, int best_only) | 2184 | font_sort_entities (Lisp_Object list, Lisp_Object prefer, |
| 2185 | struct frame *f, int best_only) | ||
| 2190 | { | 2186 | { |
| 2191 | Lisp_Object prefer_prop[FONT_SPEC_MAX]; | 2187 | Lisp_Object prefer_prop[FONT_SPEC_MAX]; |
| 2192 | int len, maxlen, i; | 2188 | int len, maxlen, i; |
| 2193 | struct font_sort_data *data; | 2189 | struct font_sort_data *data; |
| 2194 | unsigned best_score; | 2190 | unsigned best_score; |
| 2195 | Lisp_Object best_entity; | 2191 | Lisp_Object best_entity; |
| 2196 | struct frame *f = XFRAME (frame); | ||
| 2197 | Lisp_Object tail, vec IF_LINT (= Qnil); | 2192 | Lisp_Object tail, vec IF_LINT (= Qnil); |
| 2198 | USE_SAFE_ALLOCA; | 2193 | USE_SAFE_ALLOCA; |
| 2199 | 2194 | ||
| @@ -2201,7 +2196,7 @@ font_sort_entities (Lisp_Object list, Lisp_Object prefer, Lisp_Object frame, int | |||
| 2201 | prefer_prop[i] = AREF (prefer, i); | 2196 | prefer_prop[i] = AREF (prefer, i); |
| 2202 | if (FLOATP (prefer_prop[FONT_SIZE_INDEX])) | 2197 | if (FLOATP (prefer_prop[FONT_SIZE_INDEX])) |
| 2203 | prefer_prop[FONT_SIZE_INDEX] | 2198 | prefer_prop[FONT_SIZE_INDEX] |
| 2204 | = make_number (font_pixel_size (XFRAME (frame), prefer)); | 2199 | = make_number (font_pixel_size (f, prefer)); |
| 2205 | 2200 | ||
| 2206 | if (NILP (XCDR (list))) | 2201 | if (NILP (XCDR (list))) |
| 2207 | { | 2202 | { |
| @@ -2692,9 +2687,8 @@ font_delete_unmatched (Lisp_Object vec, Lisp_Object spec, int size) | |||
| 2692 | same font-driver. */ | 2687 | same font-driver. */ |
| 2693 | 2688 | ||
| 2694 | Lisp_Object | 2689 | Lisp_Object |
| 2695 | font_list_entities (Lisp_Object frame, Lisp_Object spec) | 2690 | font_list_entities (struct frame *f, Lisp_Object spec) |
| 2696 | { | 2691 | { |
| 2697 | FRAME_PTR f = XFRAME (frame); | ||
| 2698 | struct font_driver_list *driver_list = f->font_driver_list; | 2692 | struct font_driver_list *driver_list = f->font_driver_list; |
| 2699 | Lisp_Object ftype, val; | 2693 | Lisp_Object ftype, val; |
| 2700 | Lisp_Object list = Qnil; | 2694 | Lisp_Object list = Qnil; |
| @@ -2738,7 +2732,7 @@ font_list_entities (Lisp_Object frame, Lisp_Object spec) | |||
| 2738 | { | 2732 | { |
| 2739 | Lisp_Object copy; | 2733 | Lisp_Object copy; |
| 2740 | 2734 | ||
| 2741 | val = driver_list->driver->list (frame, scratch_font_spec); | 2735 | val = driver_list->driver->list (f, scratch_font_spec); |
| 2742 | if (NILP (val)) | 2736 | if (NILP (val)) |
| 2743 | val = zero_vector; | 2737 | val = zero_vector; |
| 2744 | else | 2738 | else |
| @@ -2770,10 +2764,8 @@ font_matching_entity (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec) | |||
| 2770 | { | 2764 | { |
| 2771 | struct font_driver_list *driver_list = f->font_driver_list; | 2765 | struct font_driver_list *driver_list = f->font_driver_list; |
| 2772 | Lisp_Object ftype, size, entity; | 2766 | Lisp_Object ftype, size, entity; |
| 2773 | Lisp_Object frame; | ||
| 2774 | Lisp_Object work = copy_font_spec (spec); | 2767 | Lisp_Object work = copy_font_spec (spec); |
| 2775 | 2768 | ||
| 2776 | XSETFRAME (frame, f); | ||
| 2777 | ftype = AREF (spec, FONT_TYPE_INDEX); | 2769 | ftype = AREF (spec, FONT_TYPE_INDEX); |
| 2778 | size = AREF (spec, FONT_SIZE_INDEX); | 2770 | size = AREF (spec, FONT_SIZE_INDEX); |
| 2779 | 2771 | ||
| @@ -2797,7 +2789,7 @@ font_matching_entity (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec) | |||
| 2797 | entity = XCDR (entity); | 2789 | entity = XCDR (entity); |
| 2798 | else | 2790 | else |
| 2799 | { | 2791 | { |
| 2800 | entity = driver_list->driver->match (frame, work); | 2792 | entity = driver_list->driver->match (f, work); |
| 2801 | copy = copy_font_spec (work); | 2793 | copy = copy_font_spec (work); |
| 2802 | ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type); | 2794 | ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type); |
| 2803 | XSETCDR (cache, Fcons (Fcons (copy, entity), XCDR (cache))); | 2795 | XSETCDR (cache, Fcons (Fcons (copy, entity), XCDR (cache))); |
| @@ -3039,12 +3031,12 @@ font_clear_prop (Lisp_Object *attrs, enum font_property_index prop) | |||
| 3039 | supports C and is the best match for ATTRS and PIXEL_SIZE. */ | 3031 | supports C and is the best match for ATTRS and PIXEL_SIZE. */ |
| 3040 | 3032 | ||
| 3041 | static Lisp_Object | 3033 | static Lisp_Object |
| 3042 | font_select_entity (Lisp_Object frame, Lisp_Object entities, Lisp_Object *attrs, int pixel_size, int c) | 3034 | font_select_entity (struct frame *f, Lisp_Object entities, |
| 3035 | Lisp_Object *attrs, int pixel_size, int c) | ||
| 3043 | { | 3036 | { |
| 3044 | Lisp_Object font_entity; | 3037 | Lisp_Object font_entity; |
| 3045 | Lisp_Object prefer; | 3038 | Lisp_Object prefer; |
| 3046 | int i; | 3039 | int i; |
| 3047 | FRAME_PTR f = XFRAME (frame); | ||
| 3048 | 3040 | ||
| 3049 | if (NILP (XCDR (entities)) | 3041 | if (NILP (XCDR (entities)) |
| 3050 | && ASIZE (XCAR (entities)) == 1) | 3042 | && ASIZE (XCAR (entities)) == 1) |
| @@ -3075,7 +3067,7 @@ font_select_entity (Lisp_Object frame, Lisp_Object entities, Lisp_Object *attrs, | |||
| 3075 | FONT_SET_STYLE (prefer, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); | 3067 | FONT_SET_STYLE (prefer, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); |
| 3076 | ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size)); | 3068 | ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size)); |
| 3077 | 3069 | ||
| 3078 | return font_sort_entities (entities, prefer, frame, c); | 3070 | return font_sort_entities (entities, prefer, f, c); |
| 3079 | } | 3071 | } |
| 3080 | 3072 | ||
| 3081 | /* Return a font-entity that satisfies SPEC and is the best match for | 3073 | /* Return a font-entity that satisfies SPEC and is the best match for |
| @@ -3086,7 +3078,7 @@ Lisp_Object | |||
| 3086 | font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) | 3078 | font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) |
| 3087 | { | 3079 | { |
| 3088 | Lisp_Object work; | 3080 | Lisp_Object work; |
| 3089 | Lisp_Object frame, entities, val; | 3081 | Lisp_Object entities, val; |
| 3090 | Lisp_Object foundry[3], *family, registry[3], adstyle[3]; | 3082 | Lisp_Object foundry[3], *family, registry[3], adstyle[3]; |
| 3091 | int pixel_size; | 3083 | int pixel_size; |
| 3092 | int i, j, k, l; | 3084 | int i, j, k, l; |
| @@ -3118,7 +3110,6 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) | |||
| 3118 | 3110 | ||
| 3119 | work = copy_font_spec (spec); | 3111 | work = copy_font_spec (spec); |
| 3120 | ASET (work, FONT_TYPE_INDEX, AREF (spec, FONT_TYPE_INDEX)); | 3112 | ASET (work, FONT_TYPE_INDEX, AREF (spec, FONT_TYPE_INDEX)); |
| 3121 | XSETFRAME (frame, f); | ||
| 3122 | pixel_size = font_pixel_size (f, spec); | 3113 | pixel_size = font_pixel_size (f, spec); |
| 3123 | if (pixel_size == 0 && INTEGERP (attrs[LFACE_HEIGHT_INDEX])) | 3114 | if (pixel_size == 0 && INTEGERP (attrs[LFACE_HEIGHT_INDEX])) |
| 3124 | { | 3115 | { |
| @@ -3212,10 +3203,10 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) | |||
| 3212 | for (l = 0; SYMBOLP (adstyle[l]); l++) | 3203 | for (l = 0; SYMBOLP (adstyle[l]); l++) |
| 3213 | { | 3204 | { |
| 3214 | ASET (work, FONT_ADSTYLE_INDEX, adstyle[l]); | 3205 | ASET (work, FONT_ADSTYLE_INDEX, adstyle[l]); |
| 3215 | entities = font_list_entities (frame, work); | 3206 | entities = font_list_entities (f, work); |
| 3216 | if (! NILP (entities)) | 3207 | if (! NILP (entities)) |
| 3217 | { | 3208 | { |
| 3218 | val = font_select_entity (frame, entities, | 3209 | val = font_select_entity (f, entities, |
| 3219 | attrs, pixel_size, c); | 3210 | attrs, pixel_size, c); |
| 3220 | if (! NILP (val)) | 3211 | if (! NILP (val)) |
| 3221 | return val; | 3212 | return val; |
| @@ -4110,12 +4101,10 @@ control the order of the returned list. Fonts are sorted by | |||
| 4110 | how close they are to PREFER. */) | 4101 | how close they are to PREFER. */) |
| 4111 | (Lisp_Object font_spec, Lisp_Object frame, Lisp_Object num, Lisp_Object prefer) | 4102 | (Lisp_Object font_spec, Lisp_Object frame, Lisp_Object num, Lisp_Object prefer) |
| 4112 | { | 4103 | { |
| 4104 | struct frame *f = decode_live_frame (frame); | ||
| 4113 | Lisp_Object vec, list; | 4105 | Lisp_Object vec, list; |
| 4114 | EMACS_INT n = 0; | 4106 | EMACS_INT n = 0; |
| 4115 | 4107 | ||
| 4116 | if (NILP (frame)) | ||
| 4117 | frame = selected_frame; | ||
| 4118 | CHECK_LIVE_FRAME (frame); | ||
| 4119 | CHECK_FONT_SPEC (font_spec); | 4108 | CHECK_FONT_SPEC (font_spec); |
| 4120 | if (! NILP (num)) | 4109 | if (! NILP (num)) |
| 4121 | { | 4110 | { |
| @@ -4127,7 +4116,7 @@ how close they are to PREFER. */) | |||
| 4127 | if (! NILP (prefer)) | 4116 | if (! NILP (prefer)) |
| 4128 | CHECK_FONT_SPEC (prefer); | 4117 | CHECK_FONT_SPEC (prefer); |
| 4129 | 4118 | ||
| 4130 | list = font_list_entities (frame, font_spec); | 4119 | list = font_list_entities (f, font_spec); |
| 4131 | if (NILP (list)) | 4120 | if (NILP (list)) |
| 4132 | return Qnil; | 4121 | return Qnil; |
| 4133 | if (NILP (XCDR (list)) | 4122 | if (NILP (XCDR (list)) |
| @@ -4135,7 +4124,7 @@ how close they are to PREFER. */) | |||
| 4135 | return list1 (AREF (XCAR (list), 0)); | 4124 | return list1 (AREF (XCAR (list), 0)); |
| 4136 | 4125 | ||
| 4137 | if (! NILP (prefer)) | 4126 | if (! NILP (prefer)) |
| 4138 | vec = font_sort_entities (list, prefer, frame, 0); | 4127 | vec = font_sort_entities (list, prefer, f, 0); |
| 4139 | else | 4128 | else |
| 4140 | vec = font_vconcat_entity_vectors (list); | 4129 | vec = font_vconcat_entity_vectors (list); |
| 4141 | if (n == 0 || n >= ASIZE (vec)) | 4130 | if (n == 0 || n >= ASIZE (vec)) |
| @@ -4163,13 +4152,11 @@ If FRAME is omitted or nil, the selected frame is used. */) | |||
| 4163 | struct font_driver_list *driver_list; | 4152 | struct font_driver_list *driver_list; |
| 4164 | Lisp_Object list = Qnil; | 4153 | Lisp_Object list = Qnil; |
| 4165 | 4154 | ||
| 4166 | XSETFRAME (frame, f); | ||
| 4167 | |||
| 4168 | for (driver_list = f->font_driver_list; driver_list; | 4155 | for (driver_list = f->font_driver_list; driver_list; |
| 4169 | driver_list = driver_list->next) | 4156 | driver_list = driver_list->next) |
| 4170 | if (driver_list->driver->list_family) | 4157 | if (driver_list->driver->list_family) |
| 4171 | { | 4158 | { |
| 4172 | Lisp_Object val = driver_list->driver->list_family (frame); | 4159 | Lisp_Object val = driver_list->driver->list_family (f); |
| 4173 | Lisp_Object tail = list; | 4160 | Lisp_Object tail = list; |
| 4174 | 4161 | ||
| 4175 | for (; CONSP (val); val = XCDR (val)) | 4162 | for (; CONSP (val); val = XCDR (val)) |