Re: font size problem with pango
- From: Owen Taylor <otaylor redhat com>
- To: Noah Levitt <nlevitt columbia edu>
- Cc: Gürer Özen <madcat e-kolay net>, gtk-i18n-list gnome org
- Subject: Re: font size problem with pango
- Date: 04 Aug 2003 09:58:30 -0400
On Tue, 2003-07-22 at 01:16, Noah Levitt wrote:
> I was wondering the same thing today. Probably your best bet
> is to calculate the conversion using gdk_screen_get_height_mm ()
> something like
>
> font_size_pt = font_size_px * (gdk_screen_get_height_mm/gdk_screen_get_height) * 72.27pt/1in * 1in/25.4mm
Actually, this doesn't work. The problem is that height_mm/height gives
you the "physical DPI" of the screen ... the best approximation to
the size of the pixels on the screen that the X server knows.
This is distinct from the "logical DPI" used by the Pango backend
to convert a font size into a pixel size.
There is no current portable way of retrieving the logical DPI.
If you know that you are using Xft+fontconfig, then you can
do something like the following:
* Check if there is a gtk-xft-dpi setting
GtkSettings *settings = gtk_widget_get_settings (widget);
GObjectClass *klass;
klass = G_OBJECT_CLASS(GTK_SETTINGS_GET_CLASS(settings));
if (g_object_class_find_property(klass, "gtk-xft-dpi"))
{
int int_dpi;
g_object_get (settings, "gtk-xft-dpi", &int_dpi);
dpi = int_dpi / PANGO_SCALE;
g_signal_connect (settings, "notify::gtk-xft-dpi",
G_CALLBACK (dpi_changed_callback), NULL);
}
* If not, call XftDefaultSubstitute() on an empty pattern
and check the FC_DPI value of the result:
else
{
GdkScreen *screen = gdk_widget_get_screen (widget);
FcPattern *pattern;
dpi = 96.; /* following will not normally fail, but
in case it does */
pattern = FcPatternCreate();
if (pattern)
{
XftDefaultSubstitute (GDK_SCREEN_XDISPLAY (screen),
GDK_SCREEN_XNUMBER (screen),
pattern);
FcPatternGetDouble (pattern, FC_DPI, 0, &dpi);
FcPatternDestroy (pattern);
}
}
The above isn't tested, but it should be about right.
I've filed:
http://bugzilla.gnome.org/show_bug.cgi?id=119081
because clearly this should not be necessary.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]