void CPDF_Font::CheckFontMetrics() { if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 && m_FontBBox.right == 0) { FXFT_Face face = m_Font.GetFace(); if (face) { m_FontBBox.left = TT2PDF(FXFT_Get_Face_xMin(face), face); m_FontBBox.bottom = TT2PDF(FXFT_Get_Face_yMin(face), face); m_FontBBox.right = TT2PDF(FXFT_Get_Face_xMax(face), face); m_FontBBox.top = TT2PDF(FXFT_Get_Face_yMax(face), face); m_Ascent = TT2PDF(FXFT_Get_Face_Ascender(face), face); m_Descent = TT2PDF(FXFT_Get_Face_Descender(face), face); } else { bool bFirst = true; for (int i = 0; i < 256; i++) { FX_RECT rect = GetCharBBox(i); if (rect.left == rect.right) { continue; } if (bFirst) { m_FontBBox = rect; bFirst = false; } else { if (m_FontBBox.top < rect.top) { m_FontBBox.top = rect.top; } if (m_FontBBox.right < rect.right) { m_FontBBox.right = rect.right; } if (m_FontBBox.left > rect.left) { m_FontBBox.left = rect.left; } if (m_FontBBox.bottom > rect.bottom) { m_FontBBox.bottom = rect.bottom; } } } } } if (m_Ascent == 0 && m_Descent == 0) { FX_RECT rect = GetCharBBox('A'); m_Ascent = rect.bottom == rect.top ? m_FontBBox.top : rect.top; rect = GetCharBBox('g'); m_Descent = rect.bottom == rect.top ? m_FontBBox.bottom : rect.bottom; } }
FX_BOOL CFX_GEFont::GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, FX_BOOL bCharCode) { return GetCharBBox(wUnicode, bbox, TRUE, bCharCode); }