diff options
Diffstat (limited to 'core/fxge/android/cfpf_skiafontmgr.cpp')
-rw-r--r-- | core/fxge/android/cfpf_skiafontmgr.cpp | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp index 32fe498882..b091ae9fd7 100644 --- a/core/fxge/android/cfpf_skiafontmgr.cpp +++ b/core/fxge/android/cfpf_skiafontmgr.cpp @@ -19,7 +19,6 @@ #include "core/fxcrt/fx_stream.h" #include "core/fxcrt/fx_system.h" #include "core/fxge/android/cfpf_skiafont.h" -#include "core/fxge/android/cfpf_skiafontdescriptor.h" #include "core/fxge/android/cfpf_skiapathfont.h" #include "core/fxge/fx_freetype.h" @@ -277,29 +276,29 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname, } int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 + FPF_SKIAMATCHWEIGHT_2 * 2; - CFPF_SkiaFontDescriptor* pBestFontDes = nullptr; + CFPF_SkiaPathFont* pBestFont = nullptr; int32_t nMax = -1; int32_t nGlyphNum = 0; for (auto it = m_FontFaces.rbegin(); it != m_FontFaces.rend(); ++it) { - CFPF_SkiaPathFont* pFontDes = static_cast<CFPF_SkiaPathFont*>(*it); - if (!(pFontDes->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) + CFPF_SkiaPathFont* pFont = *it; + if (!(pFont->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) continue; int32_t nFind = 0; - uint32_t dwSysFontName = FPF_SKIANormalizeFontName(pFontDes->m_pFamily); + uint32_t dwSysFontName = FPF_SKIANormalizeFontName(pFont->m_pFamily); if (dwFaceName == dwSysFontName) nFind += FPF_SKIAMATCHWEIGHT_NAME1; bool bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1); - if (FontStyleIsBold(dwStyle) == FontStyleIsBold(pFontDes->m_dwStyle)) + if (FontStyleIsBold(dwStyle) == FontStyleIsBold(pFont->m_dwStyle)) nFind += FPF_SKIAMATCHWEIGHT_1; - if (FontStyleIsItalic(dwStyle) == FontStyleIsItalic(pFontDes->m_dwStyle)) + if (FontStyleIsItalic(dwStyle) == FontStyleIsItalic(pFont->m_dwStyle)) nFind += FPF_SKIAMATCHWEIGHT_1; if (FontStyleIsFixedPitch(dwStyle) == - FontStyleIsFixedPitch(pFontDes->m_dwStyle)) { + FontStyleIsFixedPitch(pFont->m_dwStyle)) { nFind += FPF_SKIAMATCHWEIGHT_2; } - if (FontStyleIsSerif(dwStyle) == FontStyleIsSerif(pFontDes->m_dwStyle)) + if (FontStyleIsSerif(dwStyle) == FontStyleIsSerif(pFont->m_dwStyle)) nFind += FPF_SKIAMATCHWEIGHT_1; - if (FontStyleIsScript(dwStyle) == FontStyleIsScript(pFontDes->m_dwStyle)) + if (FontStyleIsScript(dwStyle) == FontStyleIsScript(pFont->m_dwStyle)) nFind += FPF_SKIAMATCHWEIGHT_2; if (dwSubst == dwSysFontName || dwSubstSans == dwSysFontName) { nFind += FPF_SKIAMATCHWEIGHT_NAME2; @@ -308,25 +307,25 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname, if (uCharset == FX_CHARSET_Default || bMaybeSymbol) { if (nFind > nMax && bMatchedName) { nMax = nFind; - pBestFontDes = *it; + pBestFont = *it; } } else if (FPF_SkiaIsCJK(uCharset)) { - if (bMatchedName || pFontDes->m_iGlyphNum > nGlyphNum) { - pBestFontDes = *it; - nGlyphNum = pFontDes->m_iGlyphNum; + if (bMatchedName || pFont->m_iGlyphNum > nGlyphNum) { + pBestFont = *it; + nGlyphNum = pFont->m_iGlyphNum; } } else if (nFind > nMax) { nMax = nFind; - pBestFontDes = *it; + pBestFont = *it; } if (nExpectVal <= nFind) { - pBestFontDes = *it; + pBestFont = *it; break; } } - if (pBestFontDes) { + if (pBestFont) { CFPF_SkiaFont* pFont = new CFPF_SkiaFont; - if (pFont->InitFont(this, pBestFontDes, bsFamilyname, dwStyle, uCharset)) { + if (pFont->InitFont(this, pBestFont, bsFamilyname, dwStyle, uCharset)) { m_FamilyFonts[dwHash] = pFont; return pFont->Retain(); } @@ -382,37 +381,36 @@ void CFPF_SkiaFontMgr::ScanFile(const ByteString& file) { FXFT_Face face = GetFontFace(file.AsStringView(), 0); if (!face) return; - CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont; - pFontDesc->SetPath(file.c_str()); - ReportFace(face, pFontDesc); - m_FontFaces.push_back(pFontDesc); + CFPF_SkiaPathFont* pFont = new CFPF_SkiaPathFont; + pFont->SetPath(file.c_str()); + ReportFace(face, pFont); + m_FontFaces.push_back(pFont); FXFT_Done_Face(face); } -void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face, - CFPF_SkiaFontDescriptor* pFontDesc) { - if (!face || !pFontDesc) +void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face, CFPF_SkiaPathFont* pFont) { + if (!face || !pFont) return; - pFontDesc->SetFamily(FXFT_Get_Face_Family_Name(face)); + pFont->SetFamily(FXFT_Get_Face_Family_Name(face)); if (FXFT_Is_Face_Bold(face)) - pFontDesc->m_dwStyle |= FXFONT_BOLD; + pFont->m_dwStyle |= FXFONT_BOLD; if (FXFT_Is_Face_Italic(face)) - pFontDesc->m_dwStyle |= FXFONT_ITALIC; + pFont->m_dwStyle |= FXFONT_ITALIC; if (FT_IS_FIXED_WIDTH(face)) - pFontDesc->m_dwStyle |= FXFONT_FIXED_PITCH; + pFont->m_dwStyle |= FXFONT_FIXED_PITCH; TT_OS2* pOS2 = static_cast<TT_OS2*>(FT_Get_Sfnt_Table(face, ft_sfnt_os2)); if (pOS2) { if (pOS2->ulCodePageRange1 & (1 << 31)) - pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; + pFont->m_dwStyle |= FXFONT_SYMBOLIC; if (pOS2->panose[0] == 2) { uint8_t uSerif = pOS2->panose[1]; if ((uSerif > 1 && uSerif < 10) || uSerif > 13) - pFontDesc->m_dwStyle |= FXFONT_SERIF; + pFont->m_dwStyle |= FXFONT_SERIF; } } if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) - pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; - pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); - pFontDesc->m_iFaceIndex = face->face_index; - pFontDesc->m_iGlyphNum = face->num_glyphs; + pFont->m_dwStyle |= FXFONT_SYMBOLIC; + pFont->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); + pFont->m_iFaceIndex = face->face_index; + pFont->m_iGlyphNum = face->num_glyphs; } |