Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307, USA. */
+#include "config.h"
+
+#ifdef HAVE_X11
+
#if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
/*** @addtogroup m17nInternal
@{ */
-#include "config.h"
-
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int alt_mask;
int super_mask;
int hyper_mask;
+
+ Atom MULE_BASELINE_OFFSET;
+ Atom AVERAGE_WIDTH;
} MDisplayInfo;
/* Anchor of the chain of MDisplayInfo objects. */
int nfonts;
int i, j;
MFont font;
+ int for_full_width;
plist = mplist_get (font_list, registry);
if (plist)
font_names = XListFonts (disp_info->display, pattern, 0x8000, &nfonts);
if (nfonts == 0)
return plist;
+ {
+ char *reg_name = msymbol_name (registry);
+
+ for_full_width = (strncmp (reg_name, "jis", 3) == 0
+ || strncmp (reg_name, "gb", 2) == 0
+ || strncmp (reg_name, "big5", 4) == 0
+ || strncmp (reg_name, "ksc", 3) == 0);
+ }
names = alloca (sizeof (char *) * nfonts);
memcpy (names, font_names, sizeof (char *) * nfonts);
qsort (names, nfonts, sizeof (char *), font_compare);
sizes[nsizes++] = size;
}
+ font.for_full_width = for_full_width;
font.type = MFONT_TYPE_OBJECT;
font.source = MFONT_SOURCE_X;
MSTRUCT_CALLOC (fontx, MERROR_WIN);
rfont->font = font;
rfont->driver = &xfont_driver;
rfont->info = x_rfont;
- rfont->ascent = xfont->ascent;
- rfont->descent = xfont->descent;
+ {
+ MDisplayInfo *disp_info = FRAME_DEVICE (frame)->display_info;
+ unsigned long value;
+
+ rfont->baseline_offset
+ = (XGetFontProperty (xfont, disp_info->MULE_BASELINE_OFFSET, &value)
+ ? (int) value : 0);
+ rfont->average_width
+ = (XGetFontProperty (xfont, disp_info->AVERAGE_WIDTH, &value)
+ ? (int) value / 10 : 0);
+ }
+ rfont->ascent = xfont->ascent + rfont->baseline_offset;
+ rfont->descent = xfont->descent - rfont->baseline_offset;
rfont->max_advance = xfont->max_bounds.width;
rfont->fontp = xfont;
rfont->next = MPLIST_VAL (frame->realized_font_list);
g->descent = xfont->descent;
}
}
+ g->ascent += rfont->baseline_offset;
+ g->descent -= rfont->baseline_offset;
}
}
GC gc = ((GCInfo *) rface->info)->gc[reverse ? GC_INVERSE : GC_NORMAL];
MGlyph *g;
int i;
+ int baseline_offset;
if (from == to)
return;
+ baseline_offset = rface->rfont->baseline_offset;
if (region)
gc = set_region (rface->frame, gc, region);
XSetFont (display, gc, ((XFontStruct *) rface->rfont->fontp)->fid);
else if (g->xoff != 0 || g->yoff != 0 || g->right_padding)
{
XDrawString16 (display, (Window) win, gc,
- x + g->xoff, y + g->yoff, code + (g - from), 1);
+ x + g->xoff, y + g->yoff - baseline_offset,
+ code + (g - from), 1);
x += g->width;
g++;
}
g < to && g->type == GLYPH_CHAR && g->xoff == 0 && g->yoff == 0;
i++, g++)
x += g->width;
- XDrawString16 (display, (Window) win, gc, orig_x, y,
- code + code_idx, i);
+ XDrawString16 (display, (Window) win, gc,
+ orig_x, y - baseline_offset, code + code_idx, i);
}
}
}
FcBool anti_alias = FRAME_DEVICE (frame)->depth > 1 ? FcTrue : FcFalse;
double size = font->size ? font->size : spec->size;
XftFont *xft_font;
+ int ascent, descent, max_advance, average_width, baseline_offset;
if (rfont)
{
rfont = (mfont__ft_driver.open) (frame, font, spec, rfont);
if (! rfont)
return NULL;
+ ascent = rfont->ascent;
+ descent = rfont->descent;
+ max_advance = rfont->max_advance;
+ average_width = rfont->average_width;
+ baseline_offset = rfont->baseline_offset;
spec = &rfont->spec;
ft_face = rfont->fontp;
xft_font = xft_open_font (display, font->file, size / 10, anti_alias);
rfont->font = font;
rfont->driver = &xft_driver;
rfont->info = rfont_xft;
- rfont->ascent = ft_face->size->metrics.ascender >> 6;
- rfont->descent = - ft_face->size->metrics.descender >> 6;
- rfont->max_advance = ft_face->size->metrics.max_advance >> 6;
+ rfont->ascent = ascent;
+ rfont->descent = descent;
+ rfont->max_advance = max_advance;
+ rfont->average_width = average_width;
+ rfont->baseline_offset = baseline_offset;
rfont->fontp = xft_font;
rfont->next = MPLIST_VAL (frame->realized_font_list);
MPLIST_VAL (frame->realized_font_list) = rfont;
}
}
- XftDrawChange (xft_draw, (Drawable) win);
+ if (XftDrawDrawable (xft_draw) != (Drawable) win)
+ XftDrawChange (xft_draw, (Drawable) win);
XftDrawSetClip (xft_draw, (Region) region);
+ y -= rfont->baseline_offset;
glyphs = alloca (sizeof (FT_UInt) * (to - from));
for (last_x = x, nglyphs = 0, g = from; g < to; x += g++->width)
{
static void
mwin__destroy_window (MFrame *frame, MDrawWindow win)
{
+#ifdef HAVE_XFT2
+ XftDraw *xft_draw = FRAME_DEVICE (frame)->xft_draw;
+
+ if (XftDrawDrawable (xft_draw) == (Drawable) win)
+ XftDrawChange (xft_draw, FRAME_DEVICE (frame)->drawable);
+#endif /* HAVE_XFT2 */
XDestroyWindow (FRAME_DISPLAY (frame), (Window) win);
}
disp_info->auto_display = auto_display;
disp_info->font_list = mplist ();
find_modifier_bits (disp_info);
+ disp_info->MULE_BASELINE_OFFSET
+ = XInternAtom (display, "_MULE_BASELINE_OFFSET", False);
+ disp_info->AVERAGE_WIDTH
+ = XInternAtom (display, "AVERAGE_WIDTH", False);
mplist_add (display_info_list, Mt, disp_info);
}
/*** @} */
+#else /* not HAVE_X11 */
+
+int device_open () { return -1; }
+
+#endif /* not HAVE_X11 */
+
/*
Local Variables:
coding: euc-japan