FX_BOOL CFPF_SkiaFont::GetBBox(FX_RECT &rtBBox) { if (!m_Face) { return FALSE; } rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_xMin(m_Face)); rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_yMin(m_Face)); rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_xMax(m_Face)); rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_yMax(m_Face)); return TRUE; }
FX_INT32 CFPF_SkiaFont::GetHeight() const { if (!m_Face) { return 0; } return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Height(m_Face)); }
int CFX_Font::GetULPos() const { if (!m_Face) return 0; return EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_UnderLinePosition(m_Face)); }
int CFX_Font::GetULthickness() const { if (!m_Face) return 0; return EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_UnderLineThickness(m_Face)); }
int CFX_Font::GetMaxAdvanceWidth() const { if (!m_Face) return 0; return EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_MaxAdvanceWidth(m_Face)); }
int CFX_Font::GetHeight() const { if (!m_Face) return 0; return EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Height(m_Face)); }
FX_BOOL CFX_Font::GetGlyphBBox(FX_DWORD glyph_index, FX_RECT &bbox) { if (m_Face == NULL) { return FALSE; } if (FXFT_Is_Face_Tricky(m_Face)) { int error = FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72); if (error) { return FALSE; } error = FXFT_Load_Glyph(m_Face, glyph_index, FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); if (error) { return FALSE; } FXFT_BBox cbox; FT_Glyph glyph; error = FXFT_Get_Glyph(((FXFT_Face)m_Face)->glyph, &glyph); if (error) { return FALSE; } FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); int pixel_size_x = ((FXFT_Face)m_Face)->size->metrics.x_ppem, pixel_size_y = ((FXFT_Face)m_Face)->size->metrics.y_ppem; if (pixel_size_x == 0 || pixel_size_y == 0) { bbox.left = cbox.xMin; bbox.right = cbox.xMax; bbox.top = cbox.yMax; bbox.bottom = cbox.yMin; } else { bbox.left = cbox.xMin * 1000 / pixel_size_x; bbox.right = cbox.xMax * 1000 / pixel_size_x; bbox.top = cbox.yMax * 1000 / pixel_size_y; bbox.bottom = cbox.yMin * 1000 / pixel_size_y; } if (bbox.top > FXFT_Get_Face_Ascender(m_Face)) { bbox.top = FXFT_Get_Face_Ascender(m_Face); } if (bbox.bottom < FXFT_Get_Face_Descender(m_Face)) { bbox.bottom = FXFT_Get_Face_Descender(m_Face); } FT_Done_Glyph(glyph); return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; } if (FXFT_Load_Glyph(m_Face, glyph_index, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { return FALSE; } int em = FXFT_Get_Face_UnitsPerEM(m_Face); if (em == 0) { bbox.left = FXFT_Get_Glyph_HoriBearingX(m_Face); bbox.bottom = FXFT_Get_Glyph_HoriBearingY(m_Face); bbox.top = bbox.bottom - FXFT_Get_Glyph_Height(m_Face); bbox.right = bbox.left + FXFT_Get_Glyph_Width(m_Face); } else { bbox.left = FXFT_Get_Glyph_HoriBearingX(m_Face) * 1000 / em; bbox.top = (FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face)) * 1000 / em; bbox.right = (FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face)) * 1000 / em; bbox.bottom = (FXFT_Get_Glyph_HoriBearingY(m_Face)) * 1000 / em; } return TRUE; }
FX_INT32 CFPF_SkiaFont::GetDescent() const { if (!m_Face) { return 0; } return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Descender(m_Face)); }
int32_t CFPF_SkiaFont::GetAscent() const { if (!m_Face) { return 0; } return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Ascender(m_Face)); }
int CFX_Font::GetULthickness() { if (m_Face == NULL) { return 0; } int thickness = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_UnderLineThickness(m_Face)); return thickness; }
int CFX_Font::GetULPos() { if (m_Face == NULL) { return 0; } int pos = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_UnderLinePosition(m_Face)); return pos; }
int CFX_Font::GetHeight() { if (m_Face == NULL) { return 0; } int height = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Height(m_Face)); return height; }
int CFX_Font::GetMaxAdvanceWidth() { if (m_Face == NULL) { return 0; } int width = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_MaxAdvanceWidth(m_Face)); return width; }
int CFX_Font::GetDescent() const { if (m_Face == NULL) { return 0; } int descent = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Descender(m_Face)); return descent; }
FX_INT32 CFPF_SkiaFont::GetGlyphWidth(FX_INT32 iGlyphIndex) { if (!m_Face) { return 0; } if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { return 0; } return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriAdvance(m_Face)); }
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; }
int CFX_Font::GetGlyphWidth(FX_DWORD glyph_index) { if (!m_Face) { return 0; } if (m_pSubstFont && (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM)) { AdjustMMParams(glyph_index, 0, 0); } int err = FXFT_Load_Glyph(m_Face, glyph_index, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); if (err) { return 0; } int width = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriAdvance(m_Face)); return width; }
FX_BOOL CFX_Font::GetBBox(FX_RECT& bbox) { if (!m_Face) { return FALSE; } int em = FXFT_Get_Face_UnitsPerEM(m_Face); if (em == 0) { bbox.left = FXFT_Get_Face_xMin(m_Face); bbox.bottom = FXFT_Get_Face_yMax(m_Face); bbox.top = FXFT_Get_Face_yMin(m_Face); bbox.right = FXFT_Get_Face_xMax(m_Face); } else { bbox.left = FXFT_Get_Face_xMin(m_Face) * 1000 / em; bbox.top = FXFT_Get_Face_yMin(m_Face) * 1000 / em; bbox.right = FXFT_Get_Face_xMax(m_Face) * 1000 / em; bbox.bottom = FXFT_Get_Face_yMax(m_Face) * 1000 / em; } return TRUE; }
int CFX_Font::GetDescent() const { if (!m_Face) return 0; return EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Descender(m_Face)); }