Mercurial > hg > xemacs-beta
comparison src/fontcolor-msw.c @ 5470:0af042a0c116
Merge with trunk.
author | Mats Lidell <matsl@xemacs.org> |
---|---|
date | Mon, 07 Feb 2011 21:22:17 +0100 |
parents | 308d34e9f07d 94bbd4792049 |
children | 56144c8593a8 |
comparison
equal
deleted
inserted
replaced
5469:2a8a04f73c15 | 5470:0af042a0c116 |
---|---|
1194 /* Function for sorting lists of fonts as obtained from | 1194 /* Function for sorting lists of fonts as obtained from |
1195 mswindows_enumerate_fonts(). These come in a known format: | 1195 mswindows_enumerate_fonts(). These come in a known format: |
1196 "family::::charset" for TrueType fonts, "family::size::charset" | 1196 "family::::charset" for TrueType fonts, "family::size::charset" |
1197 otherwise. */ | 1197 otherwise. */ |
1198 | 1198 |
1199 static Lisp_Object | 1199 static Boolint |
1200 sort_font_list_function (Lisp_Object obj1, Lisp_Object obj2, | 1200 sort_font_list_function (Lisp_Object UNUSED (pred), Lisp_Object UNUSED (key), |
1201 Lisp_Object UNUSED (pred), | 1201 Lisp_Object obj1, Lisp_Object obj2) |
1202 Lisp_Object UNUSED (key_function)) | |
1203 { | 1202 { |
1204 Ibyte *font1, *font2; | 1203 Ibyte *font1, *font2; |
1205 Ibyte *c1, *c2; | 1204 Ibyte *c1, *c2; |
1206 int t1, t2; | 1205 int t1, t2; |
1207 | 1206 |
1211 3. TrueType over non-TrueType. | 1210 3. TrueType over non-TrueType. |
1212 4. Within non-TrueType, sizes closer to 10pt over sizes farther from 10pt. | 1211 4. Within non-TrueType, sizes closer to 10pt over sizes farther from 10pt. |
1213 5. Courier New over other families. | 1212 5. Courier New over other families. |
1214 */ | 1213 */ |
1215 | 1214 |
1216 /* The sort function should return non-nil if OBJ1 < OBJ2, nil otherwise. | 1215 /* The sort function should return non-zero if OBJ1 < OBJ2, zero |
1217 NOTE: This is backwards from the way qsort() works. */ | 1216 otherwise. */ |
1218 | 1217 |
1219 t1 = !NILP (XCDR (obj1)); | 1218 t1 = !NILP (XCDR (obj1)); |
1220 t2 = !NILP (XCDR (obj2)); | 1219 t2 = !NILP (XCDR (obj2)); |
1221 | 1220 |
1222 if (t1 && !t2) | 1221 if (t1 && !t2) |
1223 return Qt; | 1222 return 1; |
1224 if (t2 && !t1) | 1223 if (t2 && !t1) |
1225 return Qnil; | 1224 return 0; |
1226 | 1225 |
1227 font1 = XSTRING_DATA (XCAR (obj1)); | 1226 font1 = XSTRING_DATA (XCAR (obj1)); |
1228 font2 = XSTRING_DATA (XCAR (obj2)); | 1227 font2 = XSTRING_DATA (XCAR (obj2)); |
1229 | 1228 |
1230 c1 = qxestrrchr (font1, ':'); | 1229 c1 = qxestrrchr (font1, ':'); |
1232 | 1231 |
1233 t1 = !qxestrcasecmp_ascii (c1 + 1, "western"); | 1232 t1 = !qxestrcasecmp_ascii (c1 + 1, "western"); |
1234 t2 = !qxestrcasecmp_ascii (c2 + 1, "western"); | 1233 t2 = !qxestrcasecmp_ascii (c2 + 1, "western"); |
1235 | 1234 |
1236 if (t1 && !t2) | 1235 if (t1 && !t2) |
1237 return Qt; | 1236 return 1; |
1238 if (t2 && !t1) | 1237 if (t2 && !t1) |
1239 return Qnil; | 1238 return 0; |
1240 | 1239 |
1241 c1 -= 2; | 1240 c1 -= 2; |
1242 c2 -= 2; | 1241 c2 -= 2; |
1243 t1 = *c1 == ':'; | 1242 t1 = *c1 == ':'; |
1244 t2 = *c2 == ':'; | 1243 t2 = *c2 == ':'; |
1245 | 1244 |
1246 if (t1 && !t2) | 1245 if (t1 && !t2) |
1247 return Qt; | 1246 return 1; |
1248 if (t2 && !t1) | 1247 if (t2 && !t1) |
1249 return Qnil; | 1248 return 0; |
1250 | 1249 |
1251 if (!t1 && !t2) | 1250 if (!t1 && !t2) |
1252 { | 1251 { |
1253 while (isdigit (*c1)) | 1252 while (isdigit (*c1)) |
1254 c1--; | 1253 c1--; |
1257 | 1256 |
1258 t1 = qxeatoi (c1 + 1) - 10; | 1257 t1 = qxeatoi (c1 + 1) - 10; |
1259 t2 = qxeatoi (c2 + 1) - 10; | 1258 t2 = qxeatoi (c2 + 1) - 10; |
1260 | 1259 |
1261 if (abs (t1) < abs (t2)) | 1260 if (abs (t1) < abs (t2)) |
1262 return Qt; | 1261 return 1; |
1263 else if (abs (t2) < abs (t1)) | 1262 else if (abs (t2) < abs (t1)) |
1264 return Qnil; | 1263 return 0; |
1265 else if (t1 < t2) | 1264 else if (t1 < t2) |
1266 /* Prefer a smaller font over a larger one just as far away | 1265 /* Prefer a smaller font over a larger one just as far away |
1267 because the smaller one won't upset the total line height if it's | 1266 because the smaller one won't upset the total line height if it's |
1268 just a few chars. */ | 1267 just a few chars. */ |
1269 return Qt; | 1268 return 1; |
1270 } | 1269 } |
1271 | 1270 |
1272 t1 = !qxestrncasecmp_ascii (font1, "courier new:", 12); | 1271 t1 = !qxestrncasecmp_ascii (font1, "courier new:", 12); |
1273 t2 = !qxestrncasecmp_ascii (font2, "courier new:", 12); | 1272 t2 = !qxestrncasecmp_ascii (font2, "courier new:", 12); |
1274 | 1273 |
1275 if (t1 && !t2) | 1274 if (t1 && !t2) |
1276 return Qt; | 1275 return 1; |
1277 if (t2 && !t1) | 1276 if (t2 && !t1) |
1278 return Qnil; | 1277 return 0; |
1279 | 1278 |
1280 return Qnil; | 1279 return 0; |
1281 } | 1280 } |
1282 | 1281 |
1283 /* | 1282 /* |
1284 * Enumerate the available on the HDC fonts and return a list of string | 1283 * Enumerate the available on the HDC fonts and return a list of string |
1285 * font names. | 1284 * font names. |