struct xftfont_info
{
struct font font;
- /* The following three members must be here in this order to be
+ /* The following four members must be here in this order to be
compatible with struct ftfont_info (in ftfont.c). */
#ifdef HAVE_LIBOTF
int maybe_otf; /* Flag to tell if this may be OTF or not. */
OTF *otf;
#endif /* HAVE_LIBOTF */
FT_Size ft_size;
+ int index;
Display *display;
int screen;
XftFont *xftfont;
static void xftfont_close P_ ((FRAME_PTR, struct font *));
static int xftfont_prepare_face P_ ((FRAME_PTR, struct face *));
static void xftfont_done_face P_ ((FRAME_PTR, struct face *));
+static int xftfont_has_char P_ ((Lisp_Object, int));
static unsigned xftfont_encode_char P_ ((struct font *, int));
static int xftfont_text_extents P_ ((struct font *, unsigned *, int,
struct font_metrics *));
Lisp_Object spec;
{
Lisp_Object list = ftfont_driver.list (frame, spec), tail;
-
+
for (tail = list; CONSP (tail); tail = XCDR (tail))
ASET (XCAR (tail), FONT_TYPE_INDEX, Qxft);
return list;
FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename));
FcPatternAddInteger (pat, FC_INDEX, XINT (index));
-
+
BLOCK_INPUT;
match = XftFontMatch (display, FRAME_X_SCREEN_NUMBER (f), pat, &result);
font->space_width = extents.xOff;
if (font->space_width <= 0)
/* dirty workaround */
- font->space_width = pixel_size;
+ font->space_width = pixel_size;
XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents);
font->average_width = (font->space_width + extents.xOff) / 95;
}
int upEM = ft_face->units_per_EM;
font->underline_position = -ft_face->underline_position * size / upEM;
- font->underline_thickness = -ft_face->underline_thickness * size / upEM;
+ font->underline_thickness = ft_face->underline_thickness * size / upEM;
if (font->underline_thickness > 2)
font->underline_position -= font->underline_thickness / 2;
}
struct face *face;
{
struct xftface_info *xftface_info;
-
+
#if 0
/* This doesn't work if face->ascii_face doesn't use an Xft font. */
if (face != face->ascii_face
}
}
+extern Lisp_Object Qja, Qko;
+
+static int
+xftfont_has_char (font, c)
+ Lisp_Object font;
+ int c;
+{
+ struct xftfont_info *xftfont_info;
+ struct charset *cs = NULL;
+
+ if (FONT_ENTITY_P (font))
+ return ftfont_driver.has_char (font, c);
+
+ if (EQ (AREF (font, FONT_ADSTYLE_INDEX), Qja)
+ && charset_jisx0208 >= 0)
+ cs = CHARSET_FROM_ID (charset_jisx0208);
+ else if (EQ (AREF (font, FONT_ADSTYLE_INDEX), Qko)
+ && charset_ksc5601 >= 0)
+ cs = CHARSET_FROM_ID (charset_ksc5601);
+ if (cs)
+ return (ENCODE_CHAR (cs, c) != CHARSET_INVALID_CODE (cs));
+
+ xftfont_info = (struct xftfont_info *) XFONT_OBJECT (font);
+ return (XftCharExists (xftfont_info->display, xftfont_info->xftfont,
+ (FcChar32) c) == FcTrue);
+}
+
static unsigned
xftfont_encode_char (font, c)
struct font *font;
struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
unsigned code = XftCharIndex (xftfont_info->display, xftfont_info->xftfont,
(FcChar32) c);
-
+
return (code ? code : FONT_INVALID_CODE);
}
xftfont_get_xft_draw (f)
FRAME_PTR f;
{
- XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver);;
+ XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver);
if (! xft_draw)
{
xftfont_driver.close = xftfont_close;
xftfont_driver.prepare_face = xftfont_prepare_face;
xftfont_driver.done_face = xftfont_done_face;
+ xftfont_driver.has_char = xftfont_has_char;
xftfont_driver.encode_char = xftfont_encode_char;
xftfont_driver.text_extents = xftfont_text_extents;
xftfont_driver.draw = xftfont_draw;