diff options
author | Lei Zhang <thestig@chromium.org> | 2018-08-17 23:50:02 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-17 23:50:02 +0000 |
commit | 3f9a65a6bc254008625d6641ff9c54a40a64fb70 (patch) | |
tree | 48a869674f5df70c8cd80f3f6ed0dd2e8fea7a47 /core/fxge/android/cfpf_skiafontmgr.cpp | |
parent | a9d56105a725d223f87bd979ffbf61a8a2377c08 (diff) | |
download | pdfium-3f9a65a6bc254008625d6641ff9c54a40a64fb70.tar.xz |
Encapsulate CFPF_SkiaPathFont members.
Use ByteString instead of char* for string data.
Change-Id: I28dee8f3544b8b85ea46f2e8bc84249f32e368a0
Reviewed-on: https://pdfium-review.googlesource.com/40570
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxge/android/cfpf_skiafontmgr.cpp')
-rw-r--r-- | core/fxge/android/cfpf_skiafontmgr.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp index 6edc334a9d..08b6fc5835 100644 --- a/core/fxge/android/cfpf_skiafontmgr.cpp +++ b/core/fxge/android/cfpf_skiafontmgr.cpp @@ -280,24 +280,24 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname, int32_t nGlyphNum = 0; for (auto it = m_FontFaces.rbegin(); it != m_FontFaces.rend(); ++it) { const CFPF_SkiaPathFont* pFont = it->get(); - if (!(pFont->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) + if (!(pFont->charsets() & FPF_SkiaGetCharset(uCharset))) continue; int32_t nFind = 0; - uint32_t dwSysFontName = FPF_SKIANormalizeFontName(pFont->m_pFamily); + uint32_t dwSysFontName = FPF_SKIANormalizeFontName(pFont->family()); if (dwFaceName == dwSysFontName) nFind += FPF_SKIAMATCHWEIGHT_NAME1; bool bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1); - if (FontStyleIsBold(dwStyle) == FontStyleIsBold(pFont->m_dwStyle)) + if (FontStyleIsBold(dwStyle) == FontStyleIsBold(pFont->style())) nFind += FPF_SKIAMATCHWEIGHT_1; - if (FontStyleIsItalic(dwStyle) == FontStyleIsItalic(pFont->m_dwStyle)) + if (FontStyleIsItalic(dwStyle) == FontStyleIsItalic(pFont->style())) nFind += FPF_SKIAMATCHWEIGHT_1; if (FontStyleIsFixedPitch(dwStyle) == - FontStyleIsFixedPitch(pFont->m_dwStyle)) { + FontStyleIsFixedPitch(pFont->style())) { nFind += FPF_SKIAMATCHWEIGHT_2; } - if (FontStyleIsSerif(dwStyle) == FontStyleIsSerif(pFont->m_dwStyle)) + if (FontStyleIsSerif(dwStyle) == FontStyleIsSerif(pFont->style())) nFind += FPF_SKIAMATCHWEIGHT_1; - if (FontStyleIsScript(dwStyle) == FontStyleIsScript(pFont->m_dwStyle)) + if (FontStyleIsScript(dwStyle) == FontStyleIsScript(pFont->style())) nFind += FPF_SKIAMATCHWEIGHT_2; if (dwSubst == dwSysFontName || dwSubstSans == dwSysFontName) { nFind += FPF_SKIAMATCHWEIGHT_NAME2; @@ -309,9 +309,9 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname, pBestFont = it->get(); } } else if (FPF_SkiaIsCJK(uCharset)) { - if (bMatchedName || pFont->m_iGlyphNum > nGlyphNum) { + if (bMatchedName || pFont->glyph_num() > nGlyphNum) { pBestFont = it->get(); - nGlyphNum = pFont->m_iGlyphNum; + nGlyphNum = pFont->glyph_num(); } } else if (nFind > nMax) { nMax = nFind; @@ -388,29 +388,27 @@ void CFPF_SkiaFontMgr::ScanFile(const ByteString& file) { std::unique_ptr<CFPF_SkiaPathFont> CFPF_SkiaFontMgr::ReportFace( FXFT_Face face, const ByteString& file) { - auto pFont = pdfium::MakeUnique<CFPF_SkiaPathFont>(); - pFont->SetPath(file.c_str()); - pFont->SetFamily(FXFT_Get_Face_Family_Name(face)); + uint32_t dwStyle = 0; if (FXFT_Is_Face_Bold(face)) - pFont->m_dwStyle |= FXFONT_BOLD; + dwStyle |= FXFONT_BOLD; if (FXFT_Is_Face_Italic(face)) - pFont->m_dwStyle |= FXFONT_ITALIC; + dwStyle |= FXFONT_ITALIC; if (FT_IS_FIXED_WIDTH(face)) - pFont->m_dwStyle |= FXFONT_FIXED_PITCH; + 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)) - pFont->m_dwStyle |= FXFONT_SYMBOLIC; + dwStyle |= FXFONT_SYMBOLIC; if (pOS2->panose[0] == 2) { uint8_t uSerif = pOS2->panose[1]; if ((uSerif > 1 && uSerif < 10) || uSerif > 13) - pFont->m_dwStyle |= FXFONT_SERIF; + dwStyle |= FXFONT_SERIF; } } if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) - pFont->m_dwStyle |= FXFONT_SYMBOLIC; - pFont->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); - pFont->m_iFaceIndex = face->face_index; - pFont->m_iGlyphNum = face->num_glyphs; - return pFont; + dwStyle |= FXFONT_SYMBOLIC; + + return pdfium::MakeUnique<CFPF_SkiaPathFont>( + file, FXFT_Get_Face_Family_Name(face), dwStyle, face->face_index, + FPF_SkiaGetFaceCharset(pOS2), face->num_glyphs); } |