Re: Pango Font Scaling
- From: Haran Shivanan <shivanan shire symonds net>
- To: Owen Taylor <otaylor redhat com>
- Cc: gtk-i18n-list gnome org
- Subject: Re: Pango Font Scaling
- Date: Thu, 19 Aug 2004 20:37:02 +0600 (LKT)
On Mon, 16 Aug 2004, Owen Taylor wrote:
> If you want linear scaling, you need to turn off hinting -- which
> requires using a separate font map. Unfortunately, that does require
> using the FT2 backend, since there is only one fontmap per screen
> for Xft.
I tried turning of hinting. It doesn't look like the fonts scale linearly.
I'm not sure if I'm doing anything wrong or if thats just how its supposed
to work.
Here's some code:
=====8<====================
#include <pango/pango.h>
#include <pango/pangoft2.h>
static void substitute_func (FcPattern *pattern, gpointer data)
{
g_print ("Substitute func called\n");
FcPatternAddBool (pattern, FC_HINTING, FALSE);
FcPatternDel (pattern, FC_HINTING);
}
int get_width (PangoLayout * layout)
{
PangoRectangle ink,logical;
pango_layout_get_extents (layout, &ink, &logical);
return logical.height;
}
int main()
{
PangoLayout * layout;
PangoFontMap * fontmap;
PangoFontDescription * pfd;
int size;
int scale = 1;
int width,width_1;
fontmap = pango_ft2_font_map_for_display();
layout = pango_layout_new (pango_ft2_font_map_create_context(
PANGO_FT2_FONT_MAP(fontmap)));
pango_layout_set_width (layout, -1);
pango_layout_set_text(layout,"some text",-1);
pango_ft2_font_map_set_default_substitute (PANGO_FT2_FONT_MAP(fontmap), substitute_func, NULL, NULL);
pfd = pango_context_get_font_description (pango_layout_get_context(layout));
size = pango_font_description_get_size(pfd);
scale = 1;
pango_font_description_set_size(pfd,size*scale);
pango_layout_set_font_description (layout, pfd);
width_1 = get_width(layout);
g_print("Width:%i\n",width_1);
scale = 4;
pango_font_description_set_size(pfd,size*scale);
pango_layout_set_font_description (layout, pfd);
width = get_width(layout);
g_print("Quad Width:%i, Scaled By:%f\n",width,(float)width/(float)width_1);
scale = 3;
pango_font_description_set_size(pfd,size*scale);
pango_layout_set_font_description (layout, pfd);
width = get_width(layout);
g_print("Triple Width:%i, Scaled By:%f\n",width,(float)width/(float)width_1);
scale = 2;
pango_font_description_set_size(pfd,size*scale);
pango_layout_set_font_description (layout, pfd);
width = get_width(layout);
g_print("Double Width:%i, Scaled By:%f\n",width,(float)width/(float)width_1);
}
====8<=====
And here's the output:
Substitute func called
Width:18432
Substitute func called
Quad Width:63488, Scaled By:3.444444
Substitute func called
Triple Width:49152, Scaled By:2.666667
Substitute func called
Double Width:32768, Scaled By:1.777778
Am I doing something wrong here?
Thanks,
Haran
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]