Help understanding Pango layout metrics

View: New views
3 Messages — Rating Filter:   Alert me  

Help understanding Pango layout metrics

by Martin Vollrathson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello!

I was recently confused by the metrics involved in laying out text
with Pango and Cairo.

What I needed and expected was a way to specify the size and family of
the font and the height of the lines and then have the text rendered
accordning to those specifications. However I was very confused by the
concept of line spacing and the absence of a line height property.

When I found the line spacing property I assumed that the _heigh_ of
the lines always was identical to the size of the font, however this
apperas not to be so. I am very accustomed to the concept of
line-height and font-size from CSS, perhaps that's why I find the
Pango counterparts difficult to grasp.

Could someone please elaborate on how I can most easily control the
height of the lines in a Pango layout?

What I want is a way to control the exact distance between the
baselines of each line of text in a layout and perhaps the position of
the baseline relative to each line.

/Martin
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list@...
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list

Re: Help understanding Pango layout metrics

by Jesper L. Nielsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Marting

On Nov 6, 2009, at 8:25 PM, Martin Vollrathson wrote:

> Hello!
>
> I was recently confused by the metrics involved in laying out text
> with Pango and Cairo.
>
> What I needed and expected was a way to specify the size and family of
> the font and the height of the lines and then have the text rendered
> accordning to those specifications. However I was very confused by the
> concept of line spacing and the absence of a line height property.
>

It can be a little confusing.

> When I found the line spacing property I assumed that the _heigh_ of
> the lines always was identical to the size of the font, however this
> apperas not to be so. I am very accustomed to the concept of
> line-height and font-size from CSS, perhaps that's why I find the
> Pango counterparts difficult to grasp.
>

I find the Freetype guide explains the terms used in Pango and  
Freetype pretty well: http://www.freetype.org/freetype2/docs/tutorial/step2.html


> Could someone please elaborate on how I can most easily control the
> height of the lines in a Pango layout?
>
> What I want is a way to control the exact distance between the
> baselines of each line of text in a layout and perhaps the position of
> the baseline relative to each line.
>

I do not know if this can be done in an easy way. As I understand,  
your request is to specify a height, and then no font will be exceed  
that height?
If you use fontconfig you might be able to specify something in your  
font description, I have not found it though.


Best regards.
--
Jesper L. Nielsen
Senior Software Engineer @ 2M-Locatel

_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list@...
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list

Re: Help understanding Pango layout metrics

by ogg.k.ogg.k@googlemail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> What I want is a way to control the exact distance between the
> baselines of each line of text in a layout and perhaps the position of
> the baseline relative to each line.

Iterate through the lines of the layout, and draw each one at the
point of your choice.
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list@...
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list