Mercurial > emacs
comparison src/font.c @ 100385:4504aa7cb434
(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.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sat, 13 Dec 2008 03:29:47 +0000 |
parents | d53183123ad7 |
children | b8012399df73 |
comparison
equal
deleted
inserted
replaced
100384:4757ef3107ec | 100385:4504aa7cb434 |
---|---|
2163 static unsigned font_score P_ ((Lisp_Object, Lisp_Object *)); | 2163 static unsigned font_score P_ ((Lisp_Object, Lisp_Object *)); |
2164 static int font_compare P_ ((const void *, const void *)); | 2164 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. |
2171 | 2203 |
2172 The lowest 2 bits of the score is used for driver type. The font | 2204 The lowest 2 bits of the score is used for driver type. The font |
2203 score |= min (diff, 127) << sort_shift_bits[i]; | 2235 score |= min (diff, 127) << sort_shift_bits[i]; |
2204 } | 2236 } |
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; |
2213 | 2246 int pixel_size = XINT (spec_prop[FONT_SIZE_INDEX]); |
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; |
2217 if (! NILP (spec_prop[FONT_DPI_INDEX]) | 2254 if (! NILP (spec_prop[FONT_DPI_INDEX]) |
2218 && ! EQ (spec_prop[FONT_DPI_INDEX], AREF (entity, FONT_DPI_INDEX))) | 2255 && ! EQ (spec_prop[FONT_DPI_INDEX], AREF (entity, FONT_DPI_INDEX))) |
2843 | 2880 |
2844 font_assert (FONT_ENTITY_P (entity)); | 2881 font_assert (FONT_ENTITY_P (entity)); |
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)) |
2851 if (! NILP (AREF (XCAR (objlist), FONT_TYPE_INDEX)) | 2890 if (! NILP (AREF (XCAR (objlist), FONT_TYPE_INDEX)) |
2852 && XFONT_OBJECT (XCAR (objlist))->pixel_size == pixel_size) | 2891 && XFONT_OBJECT (XCAR (objlist))->pixel_size == pixel_size) |