diff options
| author | Kenichi Handa | 2008-12-13 03:29:47 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2008-12-13 03:29:47 +0000 |
| commit | 55e4177003ca6015a81ec734536442143282b9f7 (patch) | |
| tree | a49a044e7139dc9008b6ca68a9407466cc0f8757 /src | |
| parent | 96f9306b8b3659c5f9e39a398ab5c8aad48431d5 (diff) | |
| download | emacs-55e4177003ca6015a81ec734536442143282b9f7.tar.gz emacs-55e4177003ca6015a81ec734536442143282b9f7.zip | |
(font_rescale_ratio): Moved from xfaces.c. Argument
type changed. Handle a font-spec too.
(font_score): Check Vface_font_rescale_alist.
(font_open_entity): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/font.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/font.c b/src/font.c index 4eed6d315f8..10e3483462f 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -2165,6 +2165,38 @@ static int font_compare P_ ((const void *, const void *)); | |||
| 2165 | static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object, | 2165 | static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object, |
| 2166 | Lisp_Object, int)); | 2166 | Lisp_Object, int)); |
| 2167 | 2167 | ||
| 2168 | /* Return a rescaling ratio of FONT_ENTITY. */ | ||
| 2169 | extern Lisp_Object Vface_font_rescale_alist; | ||
| 2170 | |||
| 2171 | static double | ||
| 2172 | font_rescale_ratio (font_entity) | ||
| 2173 | Lisp_Object font_entity; | ||
| 2174 | { | ||
| 2175 | Lisp_Object tail, elt; | ||
| 2176 | Lisp_Object name = Qnil; | ||
| 2177 | |||
| 2178 | for (tail = Vface_font_rescale_alist; CONSP (tail); tail = XCDR (tail)) | ||
| 2179 | { | ||
| 2180 | elt = XCAR (tail); | ||
| 2181 | if (FLOATP (XCDR (elt))) | ||
| 2182 | { | ||
| 2183 | if (STRINGP (XCAR (elt))) | ||
| 2184 | { | ||
| 2185 | if (NILP (name)) | ||
| 2186 | name = Ffont_xlfd_name (font_entity, Qnil); | ||
| 2187 | if (fast_string_match_ignore_case (XCAR (elt), name) >= 0) | ||
| 2188 | return XFLOAT_DATA (XCDR (elt)); | ||
| 2189 | } | ||
| 2190 | else if (FONT_SPEC_P (XCAR (elt))) | ||
| 2191 | { | ||
| 2192 | if (font_match_p (XCAR (elt), font_entity)) | ||
| 2193 | return XFLOAT_DATA (XCDR (elt)); | ||
| 2194 | } | ||
| 2195 | } | ||
| 2196 | } | ||
| 2197 | return 1.0; | ||
| 2198 | } | ||
| 2199 | |||
| 2168 | /* We sort fonts by scoring each of them against a specified | 2200 | /* We sort fonts by scoring each of them against a specified |
| 2169 | font-spec. The score value is 32 bit (`unsigned'), and the smaller | 2201 | font-spec. The score value is 32 bit (`unsigned'), and the smaller |
| 2170 | the value is, the closer the font is to the font-spec. | 2202 | the value is, the closer the font is to the font-spec. |
| @@ -2205,12 +2237,17 @@ font_score (entity, spec_prop) | |||
| 2205 | 2237 | ||
| 2206 | /* Score the size. Maximum difference is 127. */ | 2238 | /* Score the size. Maximum difference is 127. */ |
| 2207 | i = FONT_SIZE_INDEX; | 2239 | i = FONT_SIZE_INDEX; |
| 2208 | if (! NILP (spec_prop[i]) && XINT (AREF (entity, i)) > 0) | 2240 | if (! NILP (spec_prop[FONT_SIZE_INDEX]) |
| 2241 | && XINT (AREF (entity, FONT_SIZE_INDEX)) > 0) | ||
| 2209 | { | 2242 | { |
| 2210 | /* We use the higher 6-bit for the actual size difference. The | 2243 | /* We use the higher 6-bit for the actual size difference. The |
| 2211 | lowest bit is set if the DPI is different. */ | 2244 | lowest bit is set if the DPI is different. */ |
| 2212 | int diff = XINT (spec_prop[i]) - XINT (AREF (entity, i)); | 2245 | int diff; |
| 2246 | int pixel_size = XINT (spec_prop[FONT_SIZE_INDEX]); | ||
| 2213 | 2247 | ||
| 2248 | if (CONSP (Vface_font_rescale_alist)) | ||
| 2249 | pixel_size *= font_rescale_ratio (entity); | ||
| 2250 | diff = pixel_size - XINT (AREF (entity, FONT_SIZE_INDEX)); | ||
| 2214 | if (diff < 0) | 2251 | if (diff < 0) |
| 2215 | diff = - diff; | 2252 | diff = - diff; |
| 2216 | diff <<= 1; | 2253 | diff <<= 1; |
| @@ -2845,6 +2882,8 @@ font_open_entity (f, entity, pixel_size) | |||
| 2845 | size = AREF (entity, FONT_SIZE_INDEX); | 2882 | size = AREF (entity, FONT_SIZE_INDEX); |
| 2846 | if (XINT (size) != 0) | 2883 | if (XINT (size) != 0) |
| 2847 | pixel_size = XINT (size); | 2884 | pixel_size = XINT (size); |
| 2885 | else if (CONSP (Vface_font_rescale_alist)) | ||
| 2886 | pixel_size *= font_rescale_ratio (entity); | ||
| 2848 | 2887 | ||
| 2849 | for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); | 2888 | for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); |
| 2850 | objlist = XCDR (objlist)) | 2889 | objlist = XCDR (objlist)) |