Hi o all, I’m a very new user in the “pango I’ve got a problem trying to get the
extension of a text usig Pango - I’ve made this function but the text of
dimension returned is not correct, is small than the right (pixel) size. void CPangoCairoWrapper::GetTextExtension(int *width,
int *height) { PangoAttribute
*pa; PangoAttrList
*pal; pal
= pango_layout_get_attributes(m_pa_pLayout); if(!pal) { pal
= pango_attr_list_new(); pango_layout_set_attributes(m_pa_pLayout,pal); pango_attr_list_unref(pal); }; pa
= pango_attr_size_new(m_sFontSize * PANGO_SCALE); pa
= pango_attr_weight_new(m_pangoWeight); pango_attr_list_change(pal,
pa); pango_layout_set_attributes(m_pa_pLayout,
pal); pango_layout_get_pixel_size(m_pa_pLayout,
width, height); }; where m_ … are member variable appropriately
set. I mean PangoFontDescription *m_pa_pFontDescr; PangoLayout *m_pa_pLayout; short m_sFontSize; PangoWeight m_pangoWeight; Where m_pa_pLayout =
pango_cairo_create_layout(m_ca_pCairo); m_pa_pFontDescr = pango_font_description_new (); m_strFont = "Sans" m_sFontSize = 15; m_pangoWeight = PANGO_WEIGHT_BOLD; I’ve got also set font description and other
things pango_layout_set_text(m_pa_pLayout, “TEST”,
-1); pango_font_description_set_weight(m_pa_pFontDescr,
PANGO_WEIGHT_BOLD); pango_font_description_set_family(m_pa_pFontDescr,”Sans”); pango_font_description_set_size(m_pa_pFontDescr,
m_sFontSize*PANGO_SCALE); Could you tell me where is the error or if is a
other, correct way, to get the text extension using pango – Thanks in advance Best regards Andrea Ricchetti |