I am translating a bunch of Windows programs that critically need to work out
pixel dimensions of a string (with no newlines in it).
On Windows I first call getfont:
void getfont ( char * fontfacename , int sizeinpts , int weight , HFONT * hfret
)
{
LOGFONT lf = usewindowsapifunctions ( fontfacename , sizeinpts , weight );
*hfret = CreateFontIndirect ( &lf ) ;
}
and then for all strings to be measured call this:
int getpixeldims ( HFONT hf , char * stringtomeasure ,
int * widthret , int * heightret )
{
HDC hdc = GetDC ( 0 ); // device context of screen
HGIOBJ prev = SelectObject ( hdc , hf ); // add font to context
SIZE s;
int len = strlen ( stringtomeasure );
GetTextExtentPoint ( hdc , stringtomeasure , len , &s ); // measures
SelectObject ( hdc , prev );
ReleaseDC ( 0 , hdc );
*widthret = s.cx;
*heightret = s.cy;
}
I think I need Pango for this, but I have no idea how to use it. I have the
Pango reference manual and have read the tutorials by Tony Graham, but have not
found any examples to learn from.
Help would be most appreciated.
Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com.
http://mail.promotions.yahoo.com/newdomains/aa/_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list