void XftDefaultSubstitute (Display *dpy, int screen, XftPattern *pattern) { XftValue v; double size; double scale; if (XftPatternGet (pattern, XFT_STYLE, 0, &v) == XftResultNoMatch) { if (XftPatternGet (pattern, XFT_WEIGHT, 0, &v) == XftResultNoMatch ) { XftPatternAddInteger (pattern, XFT_WEIGHT, XFT_WEIGHT_MEDIUM); } if (XftPatternGet (pattern, XFT_SLANT, 0, &v) == XftResultNoMatch) { XftPatternAddInteger (pattern, XFT_SLANT, XFT_SLANT_ROMAN); } } if (XftPatternGet (pattern, XFT_ENCODING, 0, &v) == XftResultNoMatch) XftPatternAddString (pattern, XFT_ENCODING, "iso8859-1"); if (XftPatternGet (pattern, XFT_RENDER, 0, &v) == XftResultNoMatch) { XftPatternAddBool (pattern, XFT_RENDER, XftDefaultGetBool (dpy, XFT_RENDER, screen, XftDefaultHasRender (dpy))); } if (XftPatternGet (pattern, XFT_CORE, 0, &v) == XftResultNoMatch) { XftPatternAddBool (pattern, XFT_CORE, XftDefaultGetBool (dpy, XFT_CORE, screen, !XftDefaultHasRender (dpy))); } if (XftPatternGet (pattern, XFT_ANTIALIAS, 0, &v) == XftResultNoMatch) { XftPatternAddBool (pattern, XFT_ANTIALIAS, XftDefaultGetBool (dpy, XFT_ANTIALIAS, screen, True)); } if (XftPatternGet (pattern, XFT_RGBA, 0, &v) == XftResultNoMatch) { int subpixel = XFT_RGBA_NONE; #if RENDER_MAJOR > 0 || RENDER_MINOR >= 6 int render_order = XRenderQuerySubpixelOrder (dpy, screen); switch (render_order) { default: case SubPixelUnknown: subpixel = XFT_RGBA_NONE; break; case SubPixelHorizontalRGB: subpixel = XFT_RGBA_RGB; break; case SubPixelHorizontalBGR: subpixel = XFT_RGBA_BGR; break; case SubPixelVerticalRGB: subpixel = XFT_RGBA_VRGB; break; case SubPixelVerticalBGR: subpixel = XFT_RGBA_VBGR; break; case SubPixelNone: subpixel = XFT_RGBA_NONE; break; } #endif XftPatternAddInteger (pattern, XFT_RGBA, XftDefaultGetInteger (dpy, XFT_RGBA, screen, subpixel)); } if (XftPatternGet (pattern, XFT_MINSPACE, 0, &v) == XftResultNoMatch) { XftPatternAddBool (pattern, XFT_MINSPACE, XftDefaultGetBool (dpy, XFT_MINSPACE, screen, False)); } if (XftPatternGet (pattern, XFT_PIXEL_SIZE, 0, &v) == XftResultNoMatch) { int pixels, mm; double dpi; if (XftPatternGet (pattern, XFT_SIZE, 0, &v) != XftResultMatch) { size = 12.0; XftPatternAddDouble (pattern, XFT_SIZE, size); } else { switch (v.type) { case XftTypeInteger: size = (double) v.u.i; break; case XftTypeDouble: size = v.u.d; break; default: size = 12.0; break; } } scale = XftDefaultGetDouble (dpy, XFT_SCALE, screen, 1.0); size *= scale; pixels = DisplayHeight (dpy, screen); mm = DisplayHeightMM (dpy, screen); dpi = (((double) DisplayHeight (dpy, screen) * 25.4) / (double) DisplayHeightMM (dpy, screen)); dpi = XftDefaultGetDouble (dpy, XFT_DPI, screen, dpi); size = size * dpi / 72.0; XftPatternAddDouble (pattern, XFT_PIXEL_SIZE, size); } }
static void _cairo_xlib_init_screen_font_options (Display *dpy, cairo_xlib_screen_info_t *info) { cairo_bool_t xft_hinting; cairo_bool_t xft_antialias; int xft_hintstyle; int xft_rgba; cairo_antialias_t antialias; cairo_subpixel_order_t subpixel_order; cairo_hint_style_t hint_style; if (!get_boolean_default (dpy, "antialias", &xft_antialias)) xft_antialias = TRUE; if (!get_boolean_default (dpy, "hinting", &xft_hinting)) xft_hinting = TRUE; if (!get_integer_default (dpy, "hintstyle", &xft_hintstyle)) xft_hintstyle = FC_HINT_FULL; if (!get_integer_default (dpy, "rgba", &xft_rgba)) { xft_rgba = FC_RGBA_UNKNOWN; #if RENDER_MAJOR > 0 || RENDER_MINOR >= 6 if (info->has_render) { int render_order = XRenderQuerySubpixelOrder (dpy, XScreenNumberOfScreen (info->screen)); switch (render_order) { default: case SubPixelUnknown: xft_rgba = FC_RGBA_UNKNOWN; break; case SubPixelHorizontalRGB: xft_rgba = FC_RGBA_RGB; break; case SubPixelHorizontalBGR: xft_rgba = FC_RGBA_BGR; break; case SubPixelVerticalRGB: xft_rgba = FC_RGBA_VRGB; break; case SubPixelVerticalBGR: xft_rgba = FC_RGBA_VBGR; break; case SubPixelNone: xft_rgba = FC_RGBA_NONE; break; } } #endif } if (xft_hinting) { switch (xft_hintstyle) { case FC_HINT_NONE: hint_style = CAIRO_HINT_STYLE_NONE; break; case FC_HINT_SLIGHT: hint_style = CAIRO_HINT_STYLE_SLIGHT; break; case FC_HINT_MEDIUM: hint_style = CAIRO_HINT_STYLE_MEDIUM; break; case FC_HINT_FULL: hint_style = CAIRO_HINT_STYLE_FULL; break; default: hint_style = CAIRO_HINT_STYLE_DEFAULT; } } else { hint_style = CAIRO_HINT_STYLE_NONE; } switch (xft_rgba) { case FC_RGBA_RGB: subpixel_order = CAIRO_SUBPIXEL_ORDER_RGB; break; case FC_RGBA_BGR: subpixel_order = CAIRO_SUBPIXEL_ORDER_BGR; break; case FC_RGBA_VRGB: subpixel_order = CAIRO_SUBPIXEL_ORDER_VRGB; break; case FC_RGBA_VBGR: subpixel_order = CAIRO_SUBPIXEL_ORDER_VBGR; break; case FC_RGBA_UNKNOWN: case FC_RGBA_NONE: default: subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT; } if (xft_antialias) { if (subpixel_order == CAIRO_SUBPIXEL_ORDER_DEFAULT) antialias = CAIRO_ANTIALIAS_GRAY; else antialias = CAIRO_ANTIALIAS_SUBPIXEL; } else { antialias = CAIRO_ANTIALIAS_NONE; } cairo_font_options_set_hint_style (&info->font_options, hint_style); cairo_font_options_set_antialias (&info->font_options, antialias); cairo_font_options_set_subpixel_order (&info->font_options, subpixel_order); cairo_font_options_set_hint_metrics (&info->font_options, CAIRO_HINT_METRICS_ON); }
static void init_xft_settings (GdkScreen *screen) { GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen); Display *xdisplay = GDK_SCREEN_XDISPLAY (screen); int xscreen = GDK_SCREEN_XNUMBER (screen); double dpi_double; if (screen_x11->xft_init) return; screen_x11->xft_init = TRUE; if (!get_boolean_default (xdisplay, "antialias", &screen_x11->xft_antialias)) screen_x11->xft_antialias = TRUE; if (!get_boolean_default (xdisplay, "hinting", &screen_x11->xft_hinting)) screen_x11->xft_hinting = TRUE; if (!get_integer_default (xdisplay, "hintstyle", &screen_x11->xft_hintstyle)) screen_x11->xft_hintstyle = FC_HINT_FULL; if (!get_integer_default (xdisplay, "rgba", &screen_x11->xft_rgba)) { int subpixel = FC_RGBA_UNKNOWN; #if RENDER_MAJOR > 0 || RENDER_MINOR >= 6 if (_gdk_x11_have_render (screen_x11->display)) { int render_order = XRenderQuerySubpixelOrder (xdisplay, xscreen); switch (render_order) { default: case SubPixelUnknown: subpixel = FC_RGBA_UNKNOWN; break; case SubPixelHorizontalRGB: subpixel = FC_RGBA_RGB; break; case SubPixelHorizontalBGR: subpixel = FC_RGBA_BGR; break; case SubPixelVerticalRGB: subpixel = FC_RGBA_VRGB; break; case SubPixelVerticalBGR: subpixel = FC_RGBA_VBGR; break; case SubPixelNone: subpixel = FC_RGBA_NONE; break; } } #endif screen_x11->xft_rgba = subpixel; } if (!get_double_default (xdisplay, "dpi", &dpi_double)) dpi_double = (((double) DisplayHeight (xdisplay, xscreen) * 25.4) / (double) DisplayHeightMM (xdisplay, xscreen)); screen_x11->xft_dpi = (int)(0.5 + PANGO_SCALE * dpi_double); }