Re: font size problem with pango



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

Noah

On Tue, Jul 22, 2003 at  5:13:15 +0300, Gürer Özen wrote:
> I'm working on a small application which takes a data file and renders
> it into a GtkDrawingArea with the help of pango.
> 
> Data format is something like:
> This is a 28cm x 21cm page.
> There is a "hello world" text at 7cm,1.25cm with 12pt size.
> There is a 5cm x 5cm gfx at 0,0
> ...
> 
> All objects are scaled to the widget size, so you can zoom the image via
> changing the window size. That is important for application.
> 
> My problem is with font size. If font size is 12pt, then
> 
> font_size_cm = 12 * 2.54 / 72;
> font_size_pix = font_size_cm * widget_height_pix / page_height_cm;
> 
> gives the correct size for font height in pixels. i can use this method
> for drawing lines, curves, and pixbufs but pango api uses a special
> pango unit and i couldn't find a way to make that convertion.
> 
> If i use (font_size_pix * PANGO_SCALE * 0.8) in <span size="..."> I get
> a mostly correct rendering on my 75 dpi laptop, but render is broken on
> a 91 dpi monitor with the same data and same widget size. Changing 0.8
> to 0.6 fixes rendering on the monitor.
> 
> Since this factor changes with display device, i guess pango is changing
> its unit size depending on the dpi?
> 
> Is there a way to set font size in pixels or a generic formula for
> converting pixel size to pango units?
> 
> thanks in advance.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]