Logo Search packages:      
Sourcecode: pango-graphite version File versions  Download package

void gr::FreetypeFont::getGlyphMetrics ( gid16  glyphID,
gr::Rect &  boundingBox,
gr::Point &  advances 
) [virtual, inherited]

Returns the metrics of a glyph in the font as given by FreeType. Note that the coordinates returned are floating point values, using special floating-point rectangle and point classes.

boundingBox reference to gr::Rect to hold bounding box of glyph
advances refererence to gr::Point to hold the horizontal / vertical advances

Definition at line 150 of file FreetypeFont.cpp.

  // used the cached metrics if available, otherwise load the glyph
  GlyphMetricMap::const_iterator gm_itr = m_glyphMetrics.find(glyphID);
  if (gm_itr != m_glyphMetrics.end())
    // We've cahced the results from last time.
    boundingBox = gm_itr->second.first;
    advances    = gm_itr->second.second;
    // We need to look up the glyph.
    FT_Load_Glyph(m_ftFace, glyphID, m_ft_load_flags);
    const FT_Glyph_Metrics &gm = m_ftFace->glyph->metrics;

    // Fill out the bounding box an advances.
    boundingBox.top = boundingBox.bottom = fix26_6(gm.horiBearingY);;
    boundingBox.bottom -= fix26_6(gm.height);
    boundingBox.left = boundingBox.right = fix26_6(gm.horiBearingX);
    boundingBox.right += fix26_6(gm.width);
    advances.x = fix26_6(gm.horiAdvance);
    advances.y = 0;
    // Now add an entry to our metrics map.
    m_glyphMetrics[glyphID] = std::make_pair(boundingBox, advances);

Generated by  Doxygen 1.6.0   Back to index