diff options
| author | Miles Bader | 2002-11-17 23:54:10 +0000 |
|---|---|---|
| committer | Miles Bader | 2002-11-17 23:54:10 +0000 |
| commit | 6ae2cd571572e3a1b503caed67e3760e9e1d7c0d (patch) | |
| tree | 9c94f7929fe9a749dc466f5e2925b92f1cc4dca7 /src | |
| parent | fce134490974b60d08188228b8e7d7289fd88de0 (diff) | |
| download | emacs-6ae2cd571572e3a1b503caed67e3760e9e1d7c0d.tar.gz emacs-6ae2cd571572e3a1b503caed67e3760e9e1d7c0d.zip | |
(load_face_font): Set `face->overstrike' based on result from
choose_face_font.
(best_matching_font, choose_face_font): Add `needs_overstrike'
argument, and use it to return whether overstriking is desirable
for this face/font combo.
(set_font_frame_param: Pass new argument to choose_face_font.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/xfaces.c | 54 |
2 files changed, 57 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b174d8d6ab1..9531520ea3e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,4 +1,17 @@ | |||
| 1 | 2002-11-18 Miles Bader <miles@gnu.org> | ||
| 2 | |||
| 3 | * dispextern.h (struct face): Add `overstrike' field. | ||
| 4 | * xterm.c (x_draw_glyph_string_foreground) | ||
| 5 | (x_draw_composite_glyph_string_foreground): Implement overstriking. | ||
| 6 | * xfaces.c (load_face_font): Set `face->overstrike' based on | ||
| 7 | result from choose_face_font. | ||
| 8 | (best_matching_font, choose_face_font): Add `needs_overstrike' | ||
| 9 | argument, and use it to return whether overstriking is desirable | ||
| 10 | for this face/font combo. | ||
| 11 | (set_font_frame_param: Pass new argument to choose_face_font. | ||
| 12 | |||
| 1 | 2002-11-17 Ben Key <BKey1@tampabay.rr.com> | 13 | 2002-11-17 Ben Key <BKey1@tampabay.rr.com> |
| 14 | |||
| 2 | * w32.c: Added wrapper functions around the win32 API functions | 15 | * w32.c: Added wrapper functions around the win32 API functions |
| 3 | OpenProcessToken, GetTokenInformation, LookupAccountSid, and | 16 | OpenProcessToken, GetTokenInformation, LookupAccountSid, and |
| 4 | GetSidIdentifierAuthority. These wrapper functions serve two | 17 | GetSidIdentifierAuthority. These wrapper functions serve two |
| @@ -65,7 +78,6 @@ | |||
| 65 | * s/ms-w32.h: Defined the symbol HAVE_SOUND so that the newly | 78 | * s/ms-w32.h: Defined the symbol HAVE_SOUND so that the newly |
| 66 | added support for play-sound-internal under Windows would be | 79 | added support for play-sound-internal under Windows would be |
| 67 | included in the build of Emacs. | 80 | included in the build of Emacs. |
| 68 | |||
| 69 | 81 | ||
| 70 | 2002-11-16 Jason Rumney <jasonr@gnu.org> | 82 | 2002-11-16 Jason Rumney <jasonr@gnu.org> |
| 71 | 83 | ||
diff --git a/src/xfaces.c b/src/xfaces.c index e66bc16192a..4dd0d76155f 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -522,7 +522,7 @@ static int face_numeric_weight P_ ((Lisp_Object)); | |||
| 522 | static int face_numeric_slant P_ ((Lisp_Object)); | 522 | static int face_numeric_slant P_ ((Lisp_Object)); |
| 523 | static int face_numeric_swidth P_ ((Lisp_Object)); | 523 | static int face_numeric_swidth P_ ((Lisp_Object)); |
| 524 | static int face_fontset P_ ((Lisp_Object *)); | 524 | static int face_fontset P_ ((Lisp_Object *)); |
| 525 | static char *choose_face_font P_ ((struct frame *, Lisp_Object *, int, int)); | 525 | static char *choose_face_font P_ ((struct frame *, Lisp_Object *, int, int, int*)); |
| 526 | static void merge_face_vectors P_ ((struct frame *, Lisp_Object *, Lisp_Object*, Lisp_Object)); | 526 | static void merge_face_vectors P_ ((struct frame *, Lisp_Object *, Lisp_Object*, Lisp_Object)); |
| 527 | static void merge_face_inheritance P_ ((struct frame *f, Lisp_Object, | 527 | static void merge_face_inheritance P_ ((struct frame *f, Lisp_Object, |
| 528 | Lisp_Object *, Lisp_Object)); | 528 | Lisp_Object *, Lisp_Object)); |
| @@ -534,7 +534,7 @@ static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); | |||
| 534 | static struct face *make_realized_face P_ ((Lisp_Object *)); | 534 | static struct face *make_realized_face P_ ((Lisp_Object *)); |
| 535 | static void free_realized_faces P_ ((struct face_cache *)); | 535 | static void free_realized_faces P_ ((struct face_cache *)); |
| 536 | static char *best_matching_font P_ ((struct frame *, Lisp_Object *, | 536 | static char *best_matching_font P_ ((struct frame *, Lisp_Object *, |
| 537 | struct font_name *, int, int)); | 537 | struct font_name *, int, int, int *)); |
| 538 | static void cache_face P_ ((struct face_cache *, struct face *, unsigned)); | 538 | static void cache_face P_ ((struct face_cache *, struct face *, unsigned)); |
| 539 | static void uncache_face P_ ((struct face_cache *, struct face *)); | 539 | static void uncache_face P_ ((struct face_cache *, struct face *)); |
| 540 | static int xlfd_numeric_slant P_ ((struct font_name *)); | 540 | static int xlfd_numeric_slant P_ ((struct font_name *)); |
| @@ -1257,11 +1257,13 @@ load_face_font (f, face, c) | |||
| 1257 | { | 1257 | { |
| 1258 | struct font_info *font_info = NULL; | 1258 | struct font_info *font_info = NULL; |
| 1259 | char *font_name; | 1259 | char *font_name; |
| 1260 | int needs_overstrike; | ||
| 1260 | 1261 | ||
| 1261 | face->font_info_id = -1; | 1262 | face->font_info_id = -1; |
| 1262 | face->font = NULL; | 1263 | face->font = NULL; |
| 1263 | 1264 | ||
| 1264 | font_name = choose_face_font (f, face->lface, face->fontset, c); | 1265 | font_name = choose_face_font (f, face->lface, face->fontset, c, |
| 1266 | &needs_overstrike); | ||
| 1265 | if (!font_name) | 1267 | if (!font_name) |
| 1266 | return; | 1268 | return; |
| 1267 | 1269 | ||
| @@ -1274,6 +1276,7 @@ load_face_font (f, face, c) | |||
| 1274 | face->font_info_id = font_info->font_idx; | 1276 | face->font_info_id = font_info->font_idx; |
| 1275 | face->font = font_info->font; | 1277 | face->font = font_info->font; |
| 1276 | face->font_name = font_info->full_name; | 1278 | face->font_name = font_info->full_name; |
| 1279 | face->overstrike = needs_overstrike; | ||
| 1277 | if (face->gc) | 1280 | if (face->gc) |
| 1278 | { | 1281 | { |
| 1279 | x_free_gc (f, face->gc); | 1282 | x_free_gc (f, face->gc); |
| @@ -4313,7 +4316,7 @@ set_font_frame_param (frame, lface) | |||
| 4313 | /* Choose a font name that reflects LFACE's attributes and has | 4316 | /* Choose a font name that reflects LFACE's attributes and has |
| 4314 | the registry and encoding pattern specified in the default | 4317 | the registry and encoding pattern specified in the default |
| 4315 | fontset (3rd arg: -1) for ASCII characters (4th arg: 0). */ | 4318 | fontset (3rd arg: -1) for ASCII characters (4th arg: 0). */ |
| 4316 | font = choose_face_font (f, XVECTOR (lface)->contents, -1, 0); | 4319 | font = choose_face_font (f, XVECTOR (lface)->contents, -1, 0, 0); |
| 4317 | if (!font) | 4320 | if (!font) |
| 4318 | error ("No font matches the specified attribute"); | 4321 | error ("No font matches the specified attribute"); |
| 4319 | font_name = build_string (font); | 4322 | font_name = build_string (font); |
| @@ -6140,15 +6143,20 @@ may_use_scalable_font_p (font) | |||
| 6140 | widths if ATTRS specifies such a width. | 6143 | widths if ATTRS specifies such a width. |
| 6141 | 6144 | ||
| 6142 | Value is a font name which is allocated from the heap. FONTS is | 6145 | Value is a font name which is allocated from the heap. FONTS is |
| 6143 | freed by this function. */ | 6146 | freed by this function. |
| 6147 | |||
| 6148 | If NEEDS_OVERSTRIKE is non-zero, a boolean is returned in it to | ||
| 6149 | indicate whether the resulting font should be drawn using overstrike | ||
| 6150 | to simulate bold-face. */ | ||
| 6144 | 6151 | ||
| 6145 | static char * | 6152 | static char * |
| 6146 | best_matching_font (f, attrs, fonts, nfonts, width_ratio) | 6153 | best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike) |
| 6147 | struct frame *f; | 6154 | struct frame *f; |
| 6148 | Lisp_Object *attrs; | 6155 | Lisp_Object *attrs; |
| 6149 | struct font_name *fonts; | 6156 | struct font_name *fonts; |
| 6150 | int nfonts; | 6157 | int nfonts; |
| 6151 | int width_ratio; | 6158 | int width_ratio; |
| 6159 | int *needs_overstrike; | ||
| 6152 | { | 6160 | { |
| 6153 | char *font_name; | 6161 | char *font_name; |
| 6154 | struct font_name *best; | 6162 | struct font_name *best; |
| @@ -6183,6 +6191,9 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio) | |||
| 6183 | 6191 | ||
| 6184 | exact_p = 0; | 6192 | exact_p = 0; |
| 6185 | 6193 | ||
| 6194 | if (needs_overstrike) | ||
| 6195 | *needs_overstrike = 0; | ||
| 6196 | |||
| 6186 | /* Start with the first non-scalable font in the list. */ | 6197 | /* Start with the first non-scalable font in the list. */ |
| 6187 | for (i = 0; i < nfonts; ++i) | 6198 | for (i = 0; i < nfonts; ++i) |
| 6188 | if (!font_scalable_p (fonts + i)) | 6199 | if (!font_scalable_p (fonts + i)) |
| @@ -6203,7 +6214,6 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio) | |||
| 6203 | if (exact_p) | 6214 | if (exact_p) |
| 6204 | break; | 6215 | break; |
| 6205 | } | 6216 | } |
| 6206 | |||
| 6207 | } | 6217 | } |
| 6208 | else | 6218 | else |
| 6209 | best = NULL; | 6219 | best = NULL; |
| @@ -6236,6 +6246,24 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio) | |||
| 6236 | && !better_font_p (specified, best, fonts + i, 0, 0))) | 6246 | && !better_font_p (specified, best, fonts + i, 0, 0))) |
| 6237 | best = fonts + i; | 6247 | best = fonts + i; |
| 6238 | } | 6248 | } |
| 6249 | |||
| 6250 | if (needs_overstrike) | ||
| 6251 | { | ||
| 6252 | enum xlfd_weight want_weight = specified[XLFD_WEIGHT]; | ||
| 6253 | enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT]; | ||
| 6254 | |||
| 6255 | if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight) | ||
| 6256 | { | ||
| 6257 | /* We want a bold font, but didn't get one; try to use | ||
| 6258 | overstriking instead to simulate bold-face. However, | ||
| 6259 | don't overstrike an already-bold fontn unless the | ||
| 6260 | desired weight grossly exceeds the available weight. */ | ||
| 6261 | if (got_weight > XLFD_WEIGHT_MEDIUM) | ||
| 6262 | *needs_overstrike = (got_weight - want_weight) > 2; | ||
| 6263 | else | ||
| 6264 | *needs_overstrike = 1; | ||
| 6265 | } | ||
| 6266 | } | ||
| 6239 | } | 6267 | } |
| 6240 | 6268 | ||
| 6241 | if (font_scalable_p (best)) | 6269 | if (font_scalable_p (best)) |
| @@ -6393,13 +6421,18 @@ face_fontset (attrs) | |||
| 6393 | allocated from the heap and must be freed by the caller, or NULL if | 6421 | allocated from the heap and must be freed by the caller, or NULL if |
| 6394 | we can get no information about the font name of C. It is assured | 6422 | we can get no information about the font name of C. It is assured |
| 6395 | that we always get some information for a single byte | 6423 | that we always get some information for a single byte |
| 6396 | character. */ | 6424 | character. |
| 6425 | |||
| 6426 | If NEEDS_OVERSTRIKE is non-zero, a boolean is returned in it to | ||
| 6427 | indicate whether the resulting font should be drawn using overstrike | ||
| 6428 | to simulate bold-face. */ | ||
| 6397 | 6429 | ||
| 6398 | static char * | 6430 | static char * |
| 6399 | choose_face_font (f, attrs, fontset, c) | 6431 | choose_face_font (f, attrs, fontset, c, needs_overstrike) |
| 6400 | struct frame *f; | 6432 | struct frame *f; |
| 6401 | Lisp_Object *attrs; | 6433 | Lisp_Object *attrs; |
| 6402 | int fontset, c; | 6434 | int fontset, c; |
| 6435 | int *needs_overstrike; | ||
| 6403 | { | 6436 | { |
| 6404 | Lisp_Object pattern; | 6437 | Lisp_Object pattern; |
| 6405 | char *font_name = NULL; | 6438 | char *font_name = NULL; |
| @@ -6427,7 +6460,8 @@ choose_face_font (f, attrs, fontset, c) | |||
| 6427 | width_ratio = (SINGLE_BYTE_CHAR_P (c) | 6460 | width_ratio = (SINGLE_BYTE_CHAR_P (c) |
| 6428 | ? 1 | 6461 | ? 1 |
| 6429 | : CHARSET_WIDTH (CHAR_CHARSET (c))); | 6462 | : CHARSET_WIDTH (CHAR_CHARSET (c))); |
| 6430 | font_name = best_matching_font (f, attrs, fonts, nfonts, width_ratio); | 6463 | font_name = best_matching_font (f, attrs, fonts, nfonts, width_ratio, |
| 6464 | needs_overstrike); | ||
| 6431 | return font_name; | 6465 | return font_name; |
| 6432 | } | 6466 | } |
| 6433 | 6467 | ||