aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2006-06-06 03:52:26 +0000
committerKenichi Handa2006-06-06 03:52:26 +0000
commite37ba1131075a6a9cadf38a741b2a2bd1133b3d2 (patch)
tree2702d4c3190775ab45b0eb3553d6220dcf79e874 /src
parent698ca23e826335143568d1deb1e37b3d25c41d2e (diff)
downloademacs-e37ba1131075a6a9cadf38a741b2a2bd1133b3d2.tar.gz
emacs-e37ba1131075a6a9cadf38a741b2a2bd1133b3d2.zip
If USE_FONT_BACKEND is defined, include "font.h".
Through out the file, use FONT_INFO_FROM_FACE instead of FONT_INFO_FROM_ID, use get_per_char_metric instead of rif->per_char_metric. (handle_composition_prop) [USE_FONT_BACKEND]: If the composition method is COMPOSITION_WITH_GLYPH_STRING, just set it->c to ' '. (get_glyph_face_and_encoding, fill_composite_glyph_string) (get_char_face_and_encoding, BUILD_COMPOSITE_GLYPH_STRING) (x_produce_glyphs) [USE_FONT_BACKEND]: If enable_font_backend is nonzero, use font-backend mechanism. (get_per_char_metric): New function.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c139
1 files changed, 126 insertions, 13 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 0ee3b19d638..9b5b913938b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -202,6 +202,12 @@ Boston, MA 02110-1301, USA. */
202#include "macterm.h" 202#include "macterm.h"
203#endif 203#endif
204 204
205#ifdef HAVE_WINDOW_SYSTEM
206#ifdef USE_FONT_BACKEND
207#include "font.h"
208#endif /* USE_FONT_BACKEND */
209#endif /* HAVE_WINDOW_SYSTEM */
210
205#ifndef FRAME_X_OUTPUT 211#ifndef FRAME_X_OUTPUT
206#define FRAME_X_OUTPUT(f) ((f)->output_data.x) 212#define FRAME_X_OUTPUT(f) ((f)->output_data.x)
207#endif 213#endif
@@ -4564,6 +4570,11 @@ handle_composition_prop (it)
4564 it->method = GET_FROM_COMPOSITION; 4570 it->method = GET_FROM_COMPOSITION;
4565 it->cmp_id = id; 4571 it->cmp_id = id;
4566 it->cmp_len = COMPOSITION_LENGTH (prop); 4572 it->cmp_len = COMPOSITION_LENGTH (prop);
4573#ifdef USE_FONT_BACKEND
4574 if (composition_table[id]->method == COMPOSITION_WITH_GLYPH_STRING)
4575 it->c = ' ';
4576 else
4577#endif /* USE_FONT_BACKEND */
4567 /* For a terminal, draw only the first character of the 4578 /* For a terminal, draw only the first character of the
4568 components. */ 4579 components. */
4569 it->c = COMPOSITION_GLYPH (composition_table[id], 0); 4580 it->c = COMPOSITION_GLYPH (composition_table[id], 0);
@@ -18636,6 +18647,23 @@ get_glyph_face_and_encoding (f, glyph, char2b, two_byte_p)
18636 if (two_byte_p) 18647 if (two_byte_p)
18637 *two_byte_p = 0; 18648 *two_byte_p = 0;
18638 18649
18650#ifdef USE_FONT_BACKEND
18651 if (enable_font_backend)
18652 {
18653 struct font *font = (struct font *) face->font_info;
18654
18655 if (font)
18656 {
18657 unsigned code = font->driver->encode_char (font, glyph->u.ch);
18658
18659 if (code != FONT_INVALID_CODE)
18660 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
18661 else
18662 STORE_XCHAR2B (char2b, 0, code);
18663 }
18664 }
18665 else
18666#endif /* USE_FONT_BACKEND */
18639 if (!glyph->multibyte_p) 18667 if (!glyph->multibyte_p)
18640 { 18668 {
18641 /* Unibyte case. We don't have to encode, but we have to make 18669 /* Unibyte case. We don't have to encode, but we have to make
@@ -18709,9 +18737,29 @@ fill_composite_glyph_string (s, faces, overlaps)
18709 else 18737 else
18710 { 18738 {
18711 s->font = s->face->font; 18739 s->font = s->face->font;
18712 s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id); 18740 s->font_info = FONT_INFO_FROM_FACE (s->f, s->face);
18713 } 18741 }
18714 18742
18743#ifdef USE_FONT_BACKEND
18744 if (enable_font_backend && s->cmp->method == COMPOSITION_WITH_GLYPH_STRING)
18745 {
18746 Lisp_Object gstring
18747 = AREF (XHASH_TABLE (composition_hash_table)->key_and_value,
18748 s->cmp->hash_index * 2);
18749
18750 for (i = 0; i < s->cmp->glyph_len; i++)
18751 {
18752 Lisp_Object g = LGSTRING_GLYPH (gstring, i);
18753 unsigned code = XUINT (LGLYPH_CODE (g));
18754
18755 STORE_XCHAR2B (s->char2b + i, code >> 8, code & 0xFF);
18756 }
18757 s->nchars = s->cmp->glyph_len;
18758 s->width = s->cmp->pixel_width;
18759 }
18760 else
18761 {
18762#endif /* USE_FONT_BACKEND */
18715 /* For all glyphs of this composition, starting at the offset 18763 /* For all glyphs of this composition, starting at the offset
18716 S->gidx, until we reach the end of the definition or encounter a 18764 S->gidx, until we reach the end of the definition or encounter a
18717 glyph that requires the different face, add it to S. */ 18765 glyph that requires the different face, add it to S. */
@@ -18725,6 +18773,9 @@ fill_composite_glyph_string (s, faces, overlaps)
18725 i.e. the width set for the first component of the composition. */ 18773 i.e. the width set for the first component of the composition. */
18726 18774
18727 s->width = s->first_glyph->pixel_width; 18775 s->width = s->first_glyph->pixel_width;
18776#ifdef USE_FONT_BACKEND
18777 }
18778#endif /* USE_FONT_BACKEND */
18728 18779
18729 /* If the specified font could not be loaded, use the frame's 18780 /* If the specified font could not be loaded, use the frame's
18730 default font, but record the fact that we couldn't load it in 18781 default font, but record the fact that we couldn't load it in
@@ -18796,7 +18847,7 @@ fill_glyph_string (s, face_id, start, end, overlaps)
18796 } 18847 }
18797 18848
18798 s->font = s->face->font; 18849 s->font = s->face->font;
18799 s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id); 18850 s->font_info = FONT_INFO_FROM_FACE (s->f, s->face);
18800 18851
18801 /* If the specified font could not be loaded, use the frame's font, 18852 /* If the specified font could not be loaded, use the frame's font,
18802 but record the fact that we couldn't load it in 18853 but record the fact that we couldn't load it in
@@ -18860,7 +18911,7 @@ fill_stretch_glyph_string (s, row, area, start, end)
18860 face_id = glyph->face_id; 18911 face_id = glyph->face_id;
18861 s->face = FACE_FROM_ID (s->f, face_id); 18912 s->face = FACE_FROM_ID (s->f, face_id);
18862 s->font = s->face->font; 18913 s->font = s->face->font;
18863 s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id); 18914 s->font_info = FONT_INFO_FROM_FACE (s->f, s->face);
18864 s->width = glyph->pixel_width; 18915 s->width = glyph->pixel_width;
18865 s->nchars = 1; 18916 s->nchars = 1;
18866 voffset = glyph->voffset; 18917 voffset = glyph->voffset;
@@ -18882,6 +18933,35 @@ fill_stretch_glyph_string (s, row, area, start, end)
18882 return glyph - s->row->glyphs[s->area]; 18933 return glyph - s->row->glyphs[s->area];
18883} 18934}
18884 18935
18936static XCharStruct *
18937get_per_char_metric (font, font_info, char2b, font_type)
18938 XFontStruct *font;
18939 struct font_info *font_info;
18940 XChar2b *char2b;
18941 int font_type;
18942{
18943#ifdef USE_FONT_BACKEND
18944 if (enable_font_backend)
18945 {
18946 static XCharStruct pcm_value;
18947 unsigned code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b);
18948 struct font *fontp;
18949 struct font_metrics metrics;
18950
18951 if (! font_info || code == FONT_INVALID_CODE)
18952 return NULL;
18953 fontp = (struct font *) font_info;
18954 fontp->driver->text_extents (fontp, &code, 1, &metrics);
18955 pcm_value.lbearing = metrics.lbearing;
18956 pcm_value.rbearing = metrics.rbearing;
18957 pcm_value.ascent = metrics.ascent;
18958 pcm_value.descent = metrics.descent;
18959 pcm_value.width = metrics.width;
18960 return &pcm_value;
18961 }
18962#endif /* USE_FONT_BACKEND */
18963 return rif->per_char_metric (font, char2b, font_type);
18964}
18885 18965
18886/* EXPORT for RIF: 18966/* EXPORT for RIF:
18887 Set *LEFT and *RIGHT to the left and right overhang of GLYPH on 18967 Set *LEFT and *RIGHT to the left and right overhang of GLYPH on
@@ -18906,9 +18986,9 @@ x_get_glyph_overhangs (glyph, f, left, right)
18906 18986
18907 face = get_glyph_face_and_encoding (f, glyph, &char2b, NULL); 18987 face = get_glyph_face_and_encoding (f, glyph, &char2b, NULL);
18908 font = face->font; 18988 font = face->font;
18909 font_info = FONT_INFO_FROM_ID (f, face->font_info_id); 18989 font_info = FONT_INFO_FROM_FACE (f, face);
18910 if (font /* ++KFS: Should this be font_info ? */ 18990 if (font /* ++KFS: Should this be font_info ? */
18911 && (pcm = rif->per_char_metric (font, &char2b, glyph->font_type))) 18991 && (pcm = get_per_char_metric (font, font_info, &char2b, glyph->font_type)))
18912 { 18992 {
18913 if (pcm->rbearing > pcm->width) 18993 if (pcm->rbearing > pcm->width)
18914 *right = pcm->rbearing - pcm->width; 18994 *right = pcm->rbearing - pcm->width;
@@ -19052,6 +19132,23 @@ get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p, display_p)
19052{ 19132{
19053 struct face *face = FACE_FROM_ID (f, face_id); 19133 struct face *face = FACE_FROM_ID (f, face_id);
19054 19134
19135#ifdef USE_FONT_BACKEND
19136 if (enable_font_backend)
19137 {
19138 struct font *font = (struct font *) face->font_info;
19139
19140 if (font)
19141 {
19142 unsigned code = font->driver->encode_char (font, c);
19143
19144 if (code != FONT_INVALID_CODE)
19145 STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
19146 else
19147 STORE_XCHAR2B (char2b, 0, 0);
19148 }
19149 }
19150 else
19151#endif /* USE_FONT_BACKEND */
19055 if (!multibyte_p) 19152 if (!multibyte_p)
19056 { 19153 {
19057 /* Unibyte case. We don't have to encode, but we have to make 19154 /* Unibyte case. We don't have to encode, but we have to make
@@ -19268,6 +19365,14 @@ compute_overhangs_and_x (s, x, backward_p)
19268 struct glyph_string *first_s = NULL; \ 19365 struct glyph_string *first_s = NULL; \
19269 int n; \ 19366 int n; \
19270 \ 19367 \
19368 if (cmp->method > COMPOSITION_WITH_RULE_ALTCHARS) \
19369 { \
19370 /* This happens only when USE_FONT_BACKEND is defined. */ \
19371 char2b = (XChar2b *) alloca ((sizeof *char2b) * glyph_len); \
19372 faces = &base_face; \
19373 } \
19374 else \
19375 { \
19271 base_face = base_face->ascii_face; \ 19376 base_face = base_face->ascii_face; \
19272 char2b = (XChar2b *) alloca ((sizeof *char2b) * glyph_len); \ 19377 char2b = (XChar2b *) alloca ((sizeof *char2b) * glyph_len); \
19273 faces = (struct face **) alloca ((sizeof *faces) * glyph_len); \ 19378 faces = (struct face **) alloca ((sizeof *faces) * glyph_len); \
@@ -19286,6 +19391,7 @@ compute_overhangs_and_x (s, x, backward_p)
19286 char2b + n, 1, 1); \ 19391 char2b + n, 1, 1); \
19287 } \ 19392 } \
19288 } \ 19393 } \
19394 } \
19289 \ 19395 \
19290 /* Make glyph_strings for each glyph sequence that is drawable by \ 19396 /* Make glyph_strings for each glyph sequence that is drawable by \
19291 the same face, and append them to HEAD/TAIL. */ \ 19397 the same face, and append them to HEAD/TAIL. */ \
@@ -20100,7 +20206,7 @@ calc_line_height_property (it, val, font, boff, override)
20100 if (font == NULL) 20206 if (font == NULL)
20101 return make_number (-1); 20207 return make_number (-1);
20102 20208
20103 font_info = FONT_INFO_FROM_ID (it->f, face->font_info_id); 20209 font_info = FONT_INFO_FROM_FACE (it->f, face);
20104 boff = font_info->baseline_offset; 20210 boff = font_info->baseline_offset;
20105 if (font_info->vertical_centering) 20211 if (font_info->vertical_centering)
20106 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; 20212 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
@@ -20194,7 +20300,7 @@ x_produce_glyphs (it)
20194 } 20300 }
20195 else 20301 else
20196 { 20302 {
20197 font_info = FONT_INFO_FROM_ID (it->f, face->font_info_id); 20303 font_info = FONT_INFO_FROM_FACE (it->f, face);
20198 boff = font_info->baseline_offset; 20304 boff = font_info->baseline_offset;
20199 if (font_info->vertical_centering) 20305 if (font_info->vertical_centering)
20200 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; 20306 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
@@ -20208,7 +20314,7 @@ x_produce_glyphs (it)
20208 20314
20209 it->nglyphs = 1; 20315 it->nglyphs = 1;
20210 20316
20211 pcm = rif->per_char_metric (font, &char2b, 20317 pcm = get_per_char_metric (font, font_info, &char2b,
20212 FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display)); 20318 FONT_TYPE_FOR_UNIBYTE (font, it->char_to_display));
20213 20319
20214 if (it->override_ascent >= 0) 20320 if (it->override_ascent >= 0)
@@ -20439,7 +20545,7 @@ x_produce_glyphs (it)
20439 multiplying the width of font by the width of the 20545 multiplying the width of font by the width of the
20440 character. */ 20546 character. */
20441 20547
20442 pcm = rif->per_char_metric (font, &char2b, 20548 pcm = get_per_char_metric (font, font_info, &char2b,
20443 FONT_TYPE_FOR_MULTIBYTE (font, it->c)); 20549 FONT_TYPE_FOR_MULTIBYTE (font, it->c));
20444 20550
20445 if (font_not_found_p || !pcm) 20551 if (font_not_found_p || !pcm)
@@ -20534,7 +20640,7 @@ x_produce_glyphs (it)
20534 } 20640 }
20535 else 20641 else
20536 { 20642 {
20537 font_info = FONT_INFO_FROM_ID (it->f, face->font_info_id); 20643 font_info = FONT_INFO_FROM_FACE (it->f, face);
20538 boff = font_info->baseline_offset; 20644 boff = font_info->baseline_offset;
20539 if (font_info->vertical_centering) 20645 if (font_info->vertical_centering)
20540 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; 20646 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
@@ -20558,6 +20664,13 @@ x_produce_glyphs (it)
20558 cmp->lbearing = cmp->rbearing = 0; 20664 cmp->lbearing = cmp->rbearing = 0;
20559 cmp->pixel_width = cmp->ascent = cmp->descent = 0; 20665 cmp->pixel_width = cmp->ascent = cmp->descent = 0;
20560 } 20666 }
20667#ifdef USE_FONT_BACKEND
20668 else if (cmp->method == COMPOSITION_WITH_GLYPH_STRING)
20669 {
20670 if (! cmp->font)
20671 font_prepare_composition (cmp);
20672 }
20673#endif /* USE_FONT_BACKEND */
20561 else if (cmp->font != (void *) font) 20674 else if (cmp->font != (void *) font)
20562 { 20675 {
20563 /* Ascent and descent of the font of the first character of 20676 /* Ascent and descent of the font of the first character of
@@ -20577,7 +20690,7 @@ x_produce_glyphs (it)
20577 20690
20578 /* Initialize the bounding box. */ 20691 /* Initialize the bounding box. */
20579 if (font_info 20692 if (font_info
20580 && (pcm = rif->per_char_metric (font, &char2b, 20693 && (pcm = get_per_char_metric (font, font_info, &char2b,
20581 FONT_TYPE_FOR_MULTIBYTE (font, it->c)))) 20694 FONT_TYPE_FOR_MULTIBYTE (font, it->c))))
20582 { 20695 {
20583 width = pcm->width; 20696 width = pcm->width;
@@ -20648,14 +20761,14 @@ x_produce_glyphs (it)
20648 else 20761 else
20649 { 20762 {
20650 font_info 20763 font_info
20651 = FONT_INFO_FROM_ID (it->f, face->font_info_id); 20764 = FONT_INFO_FROM_FACE (it->f, face);
20652 boff = font_info->baseline_offset; 20765 boff = font_info->baseline_offset;
20653 if (font_info->vertical_centering) 20766 if (font_info->vertical_centering)
20654 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; 20767 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
20655 } 20768 }
20656 20769
20657 if (font_info 20770 if (font_info
20658 && (pcm = rif->per_char_metric (font, &char2b, 20771 && (pcm = get_per_char_metric (font, font_info, &char2b,
20659 FONT_TYPE_FOR_MULTIBYTE (font, ch)))) 20772 FONT_TYPE_FOR_MULTIBYTE (font, ch))))
20660 { 20773 {
20661 width = pcm->width; 20774 width = pcm->width;