aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2003-03-16 20:45:20 +0000
committerKim F. Storm2003-03-16 20:45:20 +0000
commitd5cc60b8f99957c6569cf7471f1fe3ec1570da85 (patch)
tree9b6a252b271450865e2734b3f30f4727c8fd67e7 /src
parent03eb5fab70ed42f94ab8e7e3bade5a8b5ad03fab (diff)
downloademacs-d5cc60b8f99957c6569cf7471f1fe3ec1570da85.tar.gz
emacs-d5cc60b8f99957c6569cf7471f1fe3ec1570da85.zip
(struct glyph): Reduce face_id member from 22 to
21 bits (this reduces number of faces from 4M to 2M). Replace W32 specific w32_font_type member (2 bits) by generic font_type member (3 bits) for portability. (FONT_TYPE_UNKNOWN): New define, default for font_type member. (enum draw_glyphs_face): Define here. (struct glyph_string): Define here. Merge W32 and X versions. (struct redisplay_interface): New members per_char_metric, encode_char, compute_glyph_string_overhangs, draw_glyph_string. (VCENTER_BASELINE_OFFSET): Define here. (dump_glyph_string, x_get_glyph_overhangs, x_produce_glyphs) (x_draw_glyphs, notice_overwritten_cursor): Declare prototypes here.
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h224
1 files changed, 215 insertions, 9 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index 37ef222aa0f..643f76e66cd 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -240,7 +240,7 @@ enum glyph_type
240/* Glyphs. 240/* Glyphs.
241 241
242 Be extra careful when changing this structure! Esp. make sure that 242 Be extra careful when changing this structure! Esp. make sure that
243 functions producing glyphs, like x_append_glyph, fill ALL of the 243 functions producing glyphs, like append_glyph, fill ALL of the
244 glyph structure, and that GLYPH_EQUAL_P compares all 244 glyph structure, and that GLYPH_EQUAL_P compares all
245 display-relevant members of glyphs (not to imply that these are the 245 display-relevant members of glyphs (not to imply that these are the
246 only things to check when you add a member). */ 246 only things to check when you add a member). */
@@ -302,15 +302,13 @@ struct glyph
302 unsigned glyph_not_available_p : 1; 302 unsigned glyph_not_available_p : 1;
303 303
304 /* Face of the glyph. */ 304 /* Face of the glyph. */
305 unsigned face_id : 22; 305 unsigned face_id : 21;
306 306
307#ifdef WINDOWSNT 307 /* Type of font used to display the character glyph. May be used to
308 /* Type of font used to display the character glyph. Used to
309 determine which set of functions to use to obtain font metrics 308 determine which set of functions to use to obtain font metrics
310 for the glyph. Value should be an enumerator of the type 309 for the glyph. On W32, value should be an enumerator of the type
311 w32_char_font_type. */ 310 w32_char_font_type. Otherwise it equals FONT_TYPE_UNKNOWN. */
312 unsigned w32_font_type : 2; 311 unsigned font_type : 3;
313#endif
314 312
315 /* A union of sub-structures for different glyph types. */ 313 /* A union of sub-structures for different glyph types. */
316 union 314 union
@@ -341,6 +339,10 @@ struct glyph
341}; 339};
342 340
343 341
342/* Default value of the glyph font_type field. */
343
344#define FONT_TYPE_UNKNOWN 0
345
344/* Is GLYPH a space? */ 346/* Is GLYPH a space? */
345 347
346#define CHAR_GLYPH_SPACE_P(GLYPH) \ 348#define CHAR_GLYPH_SPACE_P(GLYPH) \
@@ -915,6 +917,142 @@ extern struct glyph_row scratch_glyph_row;
915 917
916 918
917/************************************************************************ 919/************************************************************************
920 Glyph Strings
921 ************************************************************************/
922
923/* Enumeration for overriding/changing the face to use for drawing
924 glyphs in x_draw_glyphs. */
925
926enum draw_glyphs_face
927{
928 DRAW_NORMAL_TEXT,
929 DRAW_INVERSE_VIDEO,
930 DRAW_CURSOR,
931 DRAW_MOUSE_FACE,
932 DRAW_IMAGE_RAISED,
933 DRAW_IMAGE_SUNKEN
934};
935
936/* A sequence of glyphs to be drawn in the same face. */
937
938struct glyph_string
939{
940 /* X-origin of the string. */
941 int x;
942
943 /* Y-origin and y-position of the base line of this string. */
944 int y, ybase;
945
946 /* The width of the string, not including a face extension. */
947 int width;
948
949 /* The width of the string, including a face extension. */
950 int background_width;
951
952 /* The height of this string. This is the height of the line this
953 string is drawn in, and can be different from the height of the
954 font the string is drawn in. */
955 int height;
956
957 /* Number of pixels this string overwrites in front of its x-origin.
958 This number is zero if the string has an lbearing >= 0; it is
959 -lbearing, if the string has an lbearing < 0. */
960 int left_overhang;
961
962 /* Number of pixels this string overwrites past its right-most
963 nominal x-position, i.e. x + width. Zero if the string's
964 rbearing is <= its nominal width, rbearing - width otherwise. */
965 int right_overhang;
966
967 /* The frame on which the glyph string is drawn. */
968 struct frame *f;
969
970 /* The window on which the glyph string is drawn. */
971 struct window *w;
972
973 /* X display and window for convenience. */
974 Display *display;
975 Window window;
976
977 /* The glyph row for which this string was built. It determines the
978 y-origin and height of the string. */
979 struct glyph_row *row;
980
981 /* The area within row. */
982 enum glyph_row_area area;
983
984 /* Characters to be drawn, and number of characters. */
985 XChar2b *char2b;
986 int nchars;
987
988 /* A face-override for drawing cursors, mouse face and similar. */
989 enum draw_glyphs_face hl;
990
991 /* Face in which this string is to be drawn. */
992 struct face *face;
993
994 /* Font in which this string is to be drawn. */
995 XFontStruct *font;
996
997 /* Font info for this string. */
998 struct font_info *font_info;
999
1000 /* Non-null means this string describes (part of) a composition.
1001 All characters from char2b are drawn composed. */
1002 struct composition *cmp;
1003
1004 /* Index of this glyph string's first character in the glyph
1005 definition of CMP. If this is zero, this glyph string describes
1006 the first character of a composition. */
1007 int gidx;
1008
1009 /* 1 means this glyph strings face has to be drawn to the right end
1010 of the window's drawing area. */
1011 unsigned extends_to_end_of_line_p : 1;
1012
1013 /* 1 means the background of this string has been drawn. */
1014 unsigned background_filled_p : 1;
1015
1016 /* 1 means glyph string must be drawn with 16-bit functions. */
1017 unsigned two_byte_p : 1;
1018
1019 /* 1 means that the original font determined for drawing this glyph
1020 string could not be loaded. The member `font' has been set to
1021 the frame's default font in this case. */
1022 unsigned font_not_found_p : 1;
1023
1024 /* 1 means that the face in which this glyph string is drawn has a
1025 stipple pattern. */
1026 unsigned stippled_p : 1;
1027
1028 /* 1 means only the foreground of this glyph string must be drawn,
1029 and we should use the physical height of the line this glyph
1030 string appears in as clip rect. */
1031 unsigned for_overlaps_p : 1;
1032
1033 /* The GC to use for drawing this glyph string. */
1034#if defined(HAVE_X_WINDOWS) || defined(HAVE_CARBON)
1035 GC gc;
1036#endif
1037#if defined(HAVE_NTGUI)
1038 XGCValues *gc;
1039 HDC hdc;
1040#endif
1041
1042 /* A pointer to the first glyph in the string. This glyph
1043 corresponds to char2b[0]. Needed to draw rectangles if
1044 font_not_found_p is 1. */
1045 struct glyph *first_glyph;
1046
1047 /* Image, if any. */
1048 struct image *img;
1049
1050 struct glyph_string *next, *prev;
1051};
1052
1053
1054
1055/************************************************************************
918 Display Dimensions 1056 Display Dimensions
919 ************************************************************************/ 1057 ************************************************************************/
920 1058
@@ -1799,7 +1937,7 @@ struct it
1799 1937
1800 /* The character to display, possibly translated to multibyte 1938 /* The character to display, possibly translated to multibyte
1801 if unibyte_display_via_language_environment is set. This 1939 if unibyte_display_via_language_environment is set. This
1802 is set after x_produce_glyphs has been called. */ 1940 is set after produce_glyphs has been called. */
1803 int char_to_display; 1941 int char_to_display;
1804 1942
1805 /* If what == IT_IMAGE, the id of the image to display. */ 1943 /* If what == IT_IMAGE, the id of the image to display. */
@@ -2026,6 +2164,24 @@ struct redisplay_interface
2026 void (*draw_fringe_bitmap) P_ ((struct window *w, struct glyph_row *row, 2164 void (*draw_fringe_bitmap) P_ ((struct window *w, struct glyph_row *row,
2027 struct draw_fringe_bitmap_params *p)); 2165 struct draw_fringe_bitmap_params *p));
2028 2166
2167/* Get metrics of character CHAR2B in FONT of type FONT_TYPE.
2168 Value is null if CHAR2B is not contained in the font. */
2169 XCharStruct * (*per_char_metric) P_ ((XFontStruct *font, XChar2b *char2b,
2170 int font_type));
2171
2172/* Encode CHAR2B using encoding information from FONT_INFO. CHAR2B is
2173 the two-byte form of C. Encoding is returned in *CHAR2B. If
2174 TWO_BYTE_P is non-null, return non-zero there if font is two-byte. */
2175 int (*encode_char) P_ ((int c, XChar2b *char2b,
2176 struct font_info *font_into, int *two_byte_p));
2177
2178/* Compute left and right overhang of glyph string S.
2179 A NULL pointer if platform does not support this. */
2180 void (*compute_glyph_string_overhangs) P_ ((struct glyph_string *s));
2181
2182/* Draw a glyph string S. */
2183 void (*draw_glyph_string) P_ ((struct glyph_string *s));
2184
2029}; 2185};
2030 2186
2031/* The current interface for window-based redisplay. */ 2187/* The current interface for window-based redisplay. */
@@ -2037,6 +2193,41 @@ extern struct redisplay_interface *rif;
2037extern int (* estimate_mode_line_height_hook) P_ ((struct frame *, 2193extern int (* estimate_mode_line_height_hook) P_ ((struct frame *,
2038 enum face_id)); 2194 enum face_id));
2039 2195
2196
2197/* Return proper value to be used as baseline offset of font that has
2198 ASCENT and DESCENT to draw characters by the font at the vertical
2199 center of the line of frame F.
2200
2201 Here, out task is to find the value of BOFF in the following figure;
2202
2203 -------------------------+-----------+-
2204 -+-+---------+-+ | |
2205 | | | | | |
2206 | | | | F_ASCENT F_HEIGHT
2207 | | | ASCENT | |
2208 HEIGHT | | | | |
2209 | | |-|-+------+-----------|------- baseline
2210 | | | | BOFF | |
2211 | |---------|-+-+ | |
2212 | | | DESCENT | |
2213 -+-+---------+-+ F_DESCENT |
2214 -------------------------+-----------+-
2215
2216 -BOFF + DESCENT + (F_HEIGHT - HEIGHT) / 2 = F_DESCENT
2217 BOFF = DESCENT + (F_HEIGHT - HEIGHT) / 2 - F_DESCENT
2218 DESCENT = FONT->descent
2219 HEIGHT = FONT_HEIGHT (FONT)
2220 F_DESCENT = (F->output_data.x->font->descent
2221 - F->output_data.x->baseline_offset)
2222 F_HEIGHT = FRAME_LINE_HEIGHT (F)
2223*/
2224
2225#define VCENTER_BASELINE_OFFSET(FONT, F) \
2226 (FONT_DESCENT (FONT) \
2227 + (FRAME_LINE_HEIGHT ((F)) - FONT_HEIGHT ((FONT)) \
2228 + (FRAME_LINE_HEIGHT ((F)) > FONT_HEIGHT ((FONT)))) / 2 \
2229 - (FONT_DESCENT (FRAME_FONT (F)) - FRAME_BASELINE_OFFSET (F)))
2230
2040 2231
2041/*********************************************************************** 2232/***********************************************************************
2042 Images 2233 Images
@@ -2343,6 +2534,21 @@ extern void add_to_log P_ ((char *, Lisp_Object, Lisp_Object));
2343extern int help_echo_showing_p; 2534extern int help_echo_showing_p;
2344extern int current_mode_line_height, current_header_line_height; 2535extern int current_mode_line_height, current_header_line_height;
2345 2536
2537#if GLYPH_DEBUG
2538extern void dump_glyph_string P_ ((struct glyph_string *));
2539#endif
2540
2541extern void x_get_glyph_overhangs P_ ((struct glyph *, struct frame *,
2542 int *, int *));
2543extern void x_produce_glyphs P_ ((struct it *));
2544extern int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,
2545 enum glyph_row_area, int, int,
2546 enum draw_glyphs_face, int));
2547
2548extern void notice_overwritten_cursor P_ ((struct window *,
2549 enum glyph_row_area,
2550 int, int, int, int));
2551
2346/* Defined in sysdep.c */ 2552/* Defined in sysdep.c */
2347 2553
2348void get_frame_size P_ ((int *, int *)); 2554void get_frame_size P_ ((int *, int *));