FX_BOOL CFPF_SkiaFont::GetGlyphBBox(FX_INT32 iGlyphIndex, FX_RECT &rtBBox) { if (!m_Face) { return FALSE; } if (FXFT_Is_Face_Tricky(m_Face)) { if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72)) { return FALSE; } if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { FXFT_Set_Pixel_Sizes(m_Face, 0, 64); return FALSE; } FXFT_Glyph glyph; if (FXFT_Get_Glyph(m_Face->glyph, &glyph)) { FXFT_Set_Pixel_Sizes(m_Face, 0, 64); return FALSE; } FXFT_BBox cbox; FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); FX_INT32 x_ppem = m_Face->size->metrics.x_ppem; FX_INT32 y_ppem = m_Face->size->metrics.y_ppem; rtBBox.left = FPF_EM_ADJUST(x_ppem, cbox.xMin); rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax); rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax); rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin); rtBBox.top = FX_MIN(rtBBox.top, GetAscent()); rtBBox.bottom = FX_MAX(rtBBox.bottom, GetDescent()); FXFT_Done_Glyph(glyph); return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; } if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { return FALSE; } rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingX(m_Face)); rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingY(m_Face)); rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face)); rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face)); return TRUE; }
void CText::SizeText(const std::string &text, FontType font, float size, Math::Point pos, TextAlign align, Math::Point &start, Math::Point &end) { start = end = pos; float sw = GetStringWidth(text, font, size); end.x += sw; if (align == TEXT_ALIGN_CENTER) { start.x -= sw/2.0f; end.x -= sw/2.0f; } else if (align == TEXT_ALIGN_RIGHT) { start.x -= sw; end.x -= sw; } start.y -= GetDescent(font, size); end.y += GetAscent(font, size); }
void CText::SizeText(const std::string &text, std::vector<FontMetaChar>::iterator format, std::vector<FontMetaChar>::iterator endFormat, float size, Math::Point pos, TextAlign align, Math::Point &start, Math::Point &end) { start = end = pos; float sw = GetStringWidth(text, format, endFormat, size); end.x += sw; if (align == TEXT_ALIGN_CENTER) { start.x -= sw/2.0f; end.x -= sw/2.0f; } else if (align == TEXT_ALIGN_RIGHT) { start.x -= sw; end.x -= sw; } start.y -= GetDescent(FONT_COLOBOT, size); end.y += GetAscent(FONT_COLOBOT, size); }
int CyaFont::GetHeight() { return( (int) ( GetAscent() + GetDescent() )); }