diff options
Diffstat (limited to 'core/src/fxge/android')
-rw-r--r-- | core/src/fxge/android/fpf_skiafont.cpp | 20 | ||||
-rw-r--r-- | core/src/fxge/android/fpf_skiafont.h | 20 | ||||
-rw-r--r-- | core/src/fxge/android/fpf_skiafontmgr.cpp | 63 | ||||
-rw-r--r-- | core/src/fxge/android/fpf_skiafontmgr.h | 24 |
4 files changed, 67 insertions, 60 deletions
diff --git a/core/src/fxge/android/fpf_skiafont.cpp b/core/src/fxge/android/fpf_skiafont.cpp index 97eeb2f683..290d989851 100644 --- a/core/src/fxge/android/fpf_skiafont.cpp +++ b/core/src/fxge/android/fpf_skiafont.cpp @@ -53,7 +53,7 @@ CFX_WideString CFPF_SkiaFont::GetPsName() } return CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(m_Face)); } -FX_INT32 CFPF_SkiaFont::GetGlyphIndex(FX_WCHAR wUnicode) +int32_t CFPF_SkiaFont::GetGlyphIndex(FX_WCHAR wUnicode) { if (!m_Face) { return wUnicode; @@ -63,7 +63,7 @@ FX_INT32 CFPF_SkiaFont::GetGlyphIndex(FX_WCHAR wUnicode) } return FXFT_Get_Char_Index(m_Face, wUnicode); } -FX_INT32 CFPF_SkiaFont::GetGlyphWidth(FX_INT32 iGlyphIndex) +int32_t CFPF_SkiaFont::GetGlyphWidth(int32_t iGlyphIndex) { if (!m_Face) { return 0; @@ -73,21 +73,21 @@ FX_INT32 CFPF_SkiaFont::GetGlyphWidth(FX_INT32 iGlyphIndex) } return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriAdvance(m_Face)); } -FX_INT32 CFPF_SkiaFont::GetAscent() const +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)); } -FX_INT32 CFPF_SkiaFont::GetDescent() const +int32_t 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)); } -FX_BOOL CFPF_SkiaFont::GetGlyphBBox(FX_INT32 iGlyphIndex, FX_RECT &rtBBox) +FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox) { if (!m_Face) { return FALSE; @@ -107,8 +107,8 @@ FX_BOOL CFPF_SkiaFont::GetGlyphBBox(FX_INT32 iGlyphIndex, FX_RECT &rtBBox) } 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; + int32_t x_ppem = m_Face->size->metrics.x_ppem; + int32_t 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); @@ -138,14 +138,14 @@ FX_BOOL CFPF_SkiaFont::GetBBox(FX_RECT &rtBBox) 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 +int32_t 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)); } -FX_INT32 CFPF_SkiaFont::GetItalicAngle() const +int32_t CFPF_SkiaFont::GetItalicAngle() const { if (!m_Face) { return 0; @@ -166,7 +166,7 @@ FX_DWORD CFPF_SkiaFont::GetFontData(FX_DWORD dwTable, FX_LPBYTE pBuffer, FX_DWOR } return dwSize; } -FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, FX_BSTR bsFamily, FX_DWORD dwStyle, FX_BYTE uCharset) +FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, FX_BSTR bsFamily, FX_DWORD dwStyle, uint8_t uCharset) { if (!pFontMgr || !pFontDes) { return FALSE; diff --git a/core/src/fxge/android/fpf_skiafont.h b/core/src/fxge/android/fpf_skiafont.h index 135c830c95..72b569fe2e 100644 --- a/core/src/fxge/android/fpf_skiafont.h +++ b/core/src/fxge/android/fpf_skiafont.h @@ -28,30 +28,30 @@ public: { return m_dwStyle; } - virtual FX_BYTE GetCharset() const + virtual uint8_t GetCharset() const { return m_uCharset; } - virtual FX_INT32 GetGlyphIndex(FX_WCHAR wUnicode); - virtual FX_INT32 GetGlyphWidth(FX_INT32 iGlyphIndex); + virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode); + virtual int32_t GetGlyphWidth(int32_t iGlyphIndex); - virtual FX_INT32 GetAscent() const; - virtual FX_INT32 GetDescent() const; + virtual int32_t GetAscent() const; + virtual int32_t GetDescent() const; - virtual FX_BOOL GetGlyphBBox(FX_INT32 iGlyphIndex, FX_RECT &rtBBox); + virtual FX_BOOL GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox); virtual FX_BOOL GetBBox(FX_RECT &rtBBox); - virtual FX_INT32 GetHeight() const; - virtual FX_INT32 GetItalicAngle() const; + virtual int32_t GetHeight() const; + virtual int32_t GetItalicAngle() const; virtual FX_DWORD GetFontData(FX_DWORD dwTable, FX_LPBYTE pBuffer, FX_DWORD dwSize); - FX_BOOL InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, FX_BSTR bsFamily, FX_DWORD dwStyle, FX_BYTE uCharset); + FX_BOOL InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, FX_BSTR bsFamily, FX_DWORD dwStyle, uint8_t uCharset); protected: CFPF_SkiaFontMgr *m_pFontMgr; CFPF_SkiaFontDescriptor *m_pFontDes; FXFT_Face m_Face; FX_DWORD m_dwStyle; - FX_BYTE m_uCharset; + uint8_t m_uCharset; FX_DWORD m_dwRefCount; }; #endif diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp index a9bef8a2b8..6b27f073e5 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.cpp +++ b/core/src/fxge/android/fpf_skiafontmgr.cpp @@ -64,10 +64,10 @@ static const FPF_SKIAFONTMAP g_SkiaFontmap[] = { }; FX_DWORD FPF_SkiaGetSubstFont(FX_DWORD dwHash) { - FX_INT32 iStart = 0; - FX_INT32 iEnd = sizeof(g_SkiaFontmap) / sizeof(FPF_SKIAFONTMAP); + int32_t iStart = 0; + int32_t iEnd = sizeof(g_SkiaFontmap) / sizeof(FPF_SKIAFONTMAP); while (iStart <= iEnd) { - FX_INT32 iMid = (iStart + iEnd) / 2; + int32_t iMid = (iStart + iEnd) / 2; FPF_LPCSKIAFONTMAP pItem = &g_SkiaFontmap[iMid]; if (dwHash < pItem->dwFamily) { iEnd = iMid - 1; @@ -88,10 +88,10 @@ static const FPF_SKIAFONTMAP g_SkiaSansFontMap[] = { }; FX_DWORD FPF_SkiaGetSansFont(FX_DWORD dwHash) { - FX_INT32 iStart = 0; - FX_INT32 iEnd = sizeof(g_SkiaSansFontMap) / sizeof(FPF_SKIAFONTMAP); + int32_t iStart = 0; + int32_t iEnd = sizeof(g_SkiaSansFontMap) / sizeof(FPF_SKIAFONTMAP); while (iStart <= iEnd) { - FX_INT32 iMid = (iStart + iEnd) / 2; + int32_t iMid = (iStart + iEnd) / 2; FPF_LPCSKIAFONTMAP pItem = &g_SkiaSansFontMap[iMid]; if (dwHash < pItem->dwFamily) { iEnd = iMid - 1; @@ -103,7 +103,7 @@ FX_DWORD FPF_SkiaGetSansFont(FX_DWORD dwHash) } return 0; } -static FX_UINT32 FPF_GetHashCode_StringA(FX_LPCSTR pStr, FX_INT32 iLength, FX_BOOL bIgnoreCase = FALSE) +static uint32_t FPF_GetHashCode_StringA(FX_LPCSTR pStr, int32_t iLength, FX_BOOL bIgnoreCase = FALSE) { if (!pStr) { return 0; @@ -112,7 +112,7 @@ static FX_UINT32 FPF_GetHashCode_StringA(FX_LPCSTR pStr, FX_INT32 iLength, FX_BO iLength = FXSYS_strlen(pStr); } FX_LPCSTR pStrEnd = pStr + iLength; - FX_UINT32 uHashCode = 0; + uint32_t uHashCode = 0; if (bIgnoreCase) { while (pStr < pStrEnd) { uHashCode = 31 * uHashCode + FXSYS_tolower(*pStr++); @@ -145,7 +145,7 @@ enum FPF_SKIACHARSET { FPF_SKIACHARSET_PC = 1 << 17, FPF_SKIACHARSET_OEM = 1 << 18, }; -static FX_DWORD FPF_SkiaGetCharset(FX_BYTE uCharset) +static FX_DWORD FPF_SkiaGetCharset(uint8_t uCharset) { switch (uCharset) { case FXFONT_ANSI_CHARSET: @@ -184,9 +184,9 @@ static FX_DWORD FPF_SkiaGetCharset(FX_BYTE uCharset) static FX_DWORD FPF_SKIANormalizeFontName(FX_BSTR bsfamily) { FX_DWORD dwHash = 0; - FX_INT32 iLength = bsfamily.GetLength(); + int32_t iLength = bsfamily.GetLength(); FX_LPCSTR pBuffer = bsfamily.GetCStr(); - for (FX_INT32 i = 0; i < iLength; i++) { + for (int32_t i = 0; i < iLength; i++) { FX_CHAR ch = pBuffer[i]; if (ch == ' ' || ch == '-' || ch == ',') { continue; @@ -195,7 +195,7 @@ static FX_DWORD FPF_SKIANormalizeFontName(FX_BSTR bsfamily) } return dwHash; } -static FX_DWORD FPF_SKIAGetFamilyHash(FX_BSTR bsFamily, FX_DWORD dwStyle, FX_BYTE uCharset) +static FX_DWORD FPF_SKIAGetFamilyHash(FX_BSTR bsFamily, FX_DWORD dwStyle, uint8_t uCharset) { CFX_ByteString bsFont(bsFamily); if (dwStyle & FXFONT_BOLD) { @@ -210,7 +210,7 @@ static FX_DWORD FPF_SKIAGetFamilyHash(FX_BSTR bsFamily, FX_DWORD dwStyle, FX_BYT bsFont += uCharset; return FPF_GetHashCode_StringA(bsFont.c_str(), bsFont.GetLength(), TRUE); } -static FX_BOOL FPF_SkiaIsCJK(FX_BYTE uCharset) +static FX_BOOL FPF_SkiaIsCJK(uint8_t uCharset) { return (uCharset == FXFONT_GB2312_CHARSET) || (uCharset == FXFONT_CHINESEBIG5_CHARSET) || (uCharset == FXFONT_HANGEUL_CHARSET) || (uCharset == FXFONT_SHIFTJIS_CHARSET); @@ -243,7 +243,7 @@ CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() } } m_FamilyFonts.RemoveAll(); - for (FX_INT32 i = m_FontFaces.GetUpperBound(); i >= 0; i--) { + for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) { CFPF_SkiaFontDescriptor *pFont = (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(i); if (pFont) { delete pFont; @@ -279,11 +279,11 @@ void CFPF_SkiaFontMgr::LoadPrivateFont(FX_BSTR bsFileName) void CFPF_SkiaFontMgr::LoadPrivateFont(FX_LPVOID pBuffer, size_t szBuffer) { } -IFPF_Font* CFPF_SkiaFontMgr::CreateFont(FX_BSTR bsFamilyname, FX_BYTE uCharset, FX_DWORD dwStyle, FX_DWORD dwMatch) +IFPF_Font* CFPF_SkiaFontMgr::CreateFont(FX_BSTR bsFamilyname, uint8_t uCharset, FX_DWORD dwStyle, FX_DWORD dwMatch) { FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset); IFPF_Font *pFont = NULL; - if (m_FamilyFonts.Lookup((void*)(FX_UINTPTR)dwHash, (void*&)pFont)) { + if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { if (pFont) { return pFont->Retain(); } @@ -297,16 +297,16 @@ IFPF_Font* CFPF_SkiaFontMgr::CreateFont(FX_BSTR bsFamilyname, FX_BYTE uCharset, } else if (uCharset == FXFONT_ANSI_CHARSET && (dwMatch & FPF_MATCHFONT_REPLACEANSI)) { uCharset = FXFONT_DEFAULT_CHARSET; } - FX_INT32 nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 + FPF_SKIAMATCHWEIGHT_2 * 2; - FX_INT32 nItem = -1; - FX_INT32 nMax = -1; - FX_INT32 nGlyphNum = 0; - for (FX_INT32 i = m_FontFaces.GetUpperBound(); i >= 0; i--) { + int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 + FPF_SKIAMATCHWEIGHT_2 * 2; + int32_t nItem = -1; + int32_t nMax = -1; + int32_t nGlyphNum = 0; + for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) { CFPF_SkiaPathFont *pFontDes = (CFPF_SkiaPathFont*)m_FontFaces.ElementAt(i); if(!(pFontDes->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) { continue; } - FX_INT32 nFind = 0; + int32_t nFind = 0; FX_DWORD dwSysFontName = FPF_SKIANormalizeFontName(pFontDes->m_pFamily); if (dwFaceName == dwSysFontName) { nFind += FPF_SKIAMATCHWEIGHT_NAME1; @@ -352,20 +352,27 @@ IFPF_Font* CFPF_SkiaFontMgr::CreateFont(FX_BSTR bsFamilyname, FX_BYTE uCharset, } if (nItem > -1) { CFPF_SkiaFontDescriptor *pFontDes = (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(nItem); +<<<<<<< HEAD CFPF_SkiaFont *pFont = FX_NEW CFPF_SkiaFont; if (pFont) { if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) { - m_FamilyFonts.SetAt((void*)(FX_UINTPTR)dwHash, (void*)pFont); + m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); return pFont->Retain(); } pFont->Release(); pFont = NULL; +======= + CFPF_SkiaFont *pFont = new CFPF_SkiaFont; + if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) { + m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); + return pFont->Retain(); +>>>>>>> bb17868... Use stdint.h types throughout PDFium. } return pFont; } return NULL; } -FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead *pFileRead, FX_INT32 iFaceIndex) +FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead *pFileRead, int32_t iFaceIndex) { if (!pFileRead) { return NULL; @@ -392,7 +399,7 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead *pFileRead, FX_INT32 iFaceI FXFT_Set_Pixel_Sizes(face, 0, 64); return face; } -FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_BSTR bsFile, FX_INT32 iFaceIndex ) +FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_BSTR bsFile, int32_t iFaceIndex ) { if (bsFile.IsEmpty()) { return NULL; @@ -410,7 +417,7 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_BSTR bsFile, FX_INT32 iFaceIndex ) FXFT_Set_Pixel_Sizes(face, 0, 64); return face; } -FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_LPCBYTE pBuffer, size_t szBuffer, FX_INT32 iFaceIndex ) +FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_LPCBYTE pBuffer, size_t szBuffer, int32_t iFaceIndex ) { if (!pBuffer || szBuffer < 1) { return NULL; @@ -512,7 +519,7 @@ static FX_DWORD FPF_SkiaGetFaceCharset(TT_OS2 *pOS2) { FX_DWORD dwCharset = 0; if (pOS2) { - for (FX_INT32 i = 0; i < 32; i++) { + for (int32_t i = 0; i < 32; i++) { if (pOS2->ulCodePageRange1 & (1 << i)) { dwCharset |= g_FPFSkiaFontCharsets[i]; } @@ -542,7 +549,7 @@ void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor *pFont pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; } if (pOS2->panose[0] == 2) { - FX_BYTE uSerif = pOS2->panose[1]; + uint8_t uSerif = pOS2->panose[1]; if ((uSerif > 1 && uSerif < 10) || uSerif > 13) { pFontDesc->m_dwStyle |= FXFONT_SERIF; } diff --git a/core/src/fxge/android/fpf_skiafontmgr.h b/core/src/fxge/android/fpf_skiafontmgr.h index 3c072fa186..44d427f8af 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.h +++ b/core/src/fxge/android/fpf_skiafontmgr.h @@ -22,7 +22,7 @@ public: FX_Free(m_pFamily); } } - virtual FX_INT32 GetType() const + virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; } @@ -31,16 +31,16 @@ public: if (m_pFamily) { FX_Free(m_pFamily); } - FX_INT32 iSize = FXSYS_strlen(pFamily); + int32_t iSize = FXSYS_strlen(pFamily); m_pFamily = FX_Alloc(FX_CHAR, iSize + 1); FXSYS_memcpy32(m_pFamily, pFamily, iSize * sizeof(FX_CHAR)); m_pFamily[iSize] = 0; } FX_LPSTR m_pFamily; FX_DWORD m_dwStyle; - FX_INT32 m_iFaceIndex; + int32_t m_iFaceIndex; FX_DWORD m_dwCharsets; - FX_INT32 m_iGlyphNum; + int32_t m_iGlyphNum; }; class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { @@ -52,7 +52,7 @@ public: FX_Free(m_pPath); } } - virtual FX_INT32 GetType() const + virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Path; } @@ -61,7 +61,7 @@ public: if (m_pPath) { FX_Free(m_pPath); } - FX_INT32 iSize = FXSYS_strlen(pPath); + int32_t iSize = FXSYS_strlen(pPath); m_pPath = FX_Alloc(FX_CHAR, iSize + 1); FXSYS_memcpy32(m_pPath, pPath, iSize * sizeof(FX_CHAR)); m_pPath[iSize] = 0; @@ -72,7 +72,7 @@ class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { public: CFPF_SkiaFileFont() : m_pFile(NULL) {} - virtual FX_INT32 GetType() const + virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_File; } @@ -82,7 +82,7 @@ class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor { public: CFPF_SkiaBufferFont() : m_pBuffer(NULL), m_szBuffer(0) {} - virtual FX_INT32 GetType() const + virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Buffer; } @@ -100,10 +100,10 @@ public: virtual void LoadPrivateFont(FX_BSTR bsFileName); virtual void LoadPrivateFont(FX_LPVOID pBuffer, size_t szBuffer); - virtual IFPF_Font* CreateFont(FX_BSTR bsFamilyname, FX_BYTE uCharset, FX_DWORD dwStyle, FX_DWORD dwMatch = 0); - FXFT_Face GetFontFace(IFX_FileRead *pFileRead, FX_INT32 iFaceIndex = 0); - FXFT_Face GetFontFace(FX_BSTR bsFile, FX_INT32 iFaceIndex = 0); - FXFT_Face GetFontFace(FX_LPCBYTE pBuffer, size_t szBuffer, FX_INT32 iFaceIndex = 0); + virtual IFPF_Font* CreateFont(FX_BSTR bsFamilyname, uint8_t uCharset, FX_DWORD dwStyle, FX_DWORD dwMatch = 0); + FXFT_Face GetFontFace(IFX_FileRead *pFileRead, int32_t iFaceIndex = 0); + FXFT_Face GetFontFace(FX_BSTR bsFile, int32_t iFaceIndex = 0); + FXFT_Face GetFontFace(FX_LPCBYTE pBuffer, size_t szBuffer, int32_t iFaceIndex = 0); protected: void ScanPath(FX_BSTR path); void ScanFile(FX_BSTR file); |