diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-09-18 14:23:18 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-18 18:40:16 +0000 |
commit | 275e260a6cd4a8e506ba974feb85ebcd926c1739 (patch) | |
tree | 2029b9158ec044764ceff122fe5fb5d0a3f123d1 /core/fxge | |
parent | 450fbeaaabf1ab340c1018de2e58f1950657517e (diff) | |
download | pdfium-275e260a6cd4a8e506ba974feb85ebcd926c1739.tar.xz |
Convert string class names
Automated using git grep & sed.
Replace StringC classes with StringView classes.
Remove the CFX_ prefix and put string classes in fxcrt namespace.
Change AsStringC() to AsStringView().
Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*,
Foo).
Couple of tests needed to have their names regularlized.
BUG=pdfium:894
Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d
Reviewed-on: https://pdfium-review.googlesource.com/14151
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxge')
30 files changed, 211 insertions, 219 deletions
diff --git a/core/fxge/android/cfpf_skiafont.cpp b/core/fxge/android/cfpf_skiafont.cpp index e00aa840e4..1ca0f576be 100644 --- a/core/fxge/android/cfpf_skiafont.cpp +++ b/core/fxge/android/cfpf_skiafont.cpp @@ -41,15 +41,15 @@ CFPF_SkiaFont* CFPF_SkiaFont::Retain() { return this; } -CFX_ByteString CFPF_SkiaFont::GetFamilyName() { +ByteString CFPF_SkiaFont::GetFamilyName() { if (!m_Face) - return CFX_ByteString(); - return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); + return ByteString(); + return ByteString(FXFT_Get_Face_Family_Name(m_Face)); } -CFX_ByteString CFPF_SkiaFont::GetPsName() { +ByteString CFPF_SkiaFont::GetPsName() { if (!m_Face) - return CFX_ByteString(); + return ByteString(); return FXFT_Get_Postscript_Name(m_Face); } @@ -181,7 +181,7 @@ uint32_t CFPF_SkiaFont::GetFontData(uint32_t dwTable, bool CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr, CFPF_SkiaFontDescriptor* pFontDes, - const CFX_ByteStringC& bsFamily, + const ByteStringView& bsFamily, uint32_t dwStyle, uint8_t uCharset) { if (!pFontMgr || !pFontDes) diff --git a/core/fxge/android/cfpf_skiafont.h b/core/fxge/android/cfpf_skiafont.h index 5686e9e31f..c842d5abb9 100644 --- a/core/fxge/android/cfpf_skiafont.h +++ b/core/fxge/android/cfpf_skiafont.h @@ -22,8 +22,8 @@ class CFPF_SkiaFont { void Release(); CFPF_SkiaFont* Retain(); - CFX_ByteString GetFamilyName(); - CFX_ByteString GetPsName(); + ByteString GetFamilyName(); + ByteString GetPsName(); uint32_t GetFontStyle() const { return m_dwStyle; } uint8_t GetCharset() const { return m_uCharset; } int32_t GetGlyphIndex(wchar_t wUnicode); @@ -38,7 +38,7 @@ class CFPF_SkiaFont { bool InitFont(CFPF_SkiaFontMgr* pFontMgr, CFPF_SkiaFontDescriptor* pFontDes, - const CFX_ByteStringC& bsFamily, + const ByteStringView& bsFamily, uint32_t dwStyle, uint8_t uCharset); diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp index 16a6df5f8f..a50b9ead63 100644 --- a/core/fxge/android/cfpf_skiafontmgr.cpp +++ b/core/fxge/android/cfpf_skiafontmgr.cpp @@ -158,7 +158,7 @@ uint32_t FPF_SkiaGetCharset(uint8_t uCharset) { return FPF_SKIACHARSET_Default; } -uint32_t FPF_SKIANormalizeFontName(const CFX_ByteStringC& bsfamily) { +uint32_t FPF_SKIANormalizeFontName(const ByteStringView& bsfamily) { uint32_t dwHash = 0; int32_t iLength = bsfamily.GetLength(); const char* pBuffer = bsfamily.unterminated_c_str(); @@ -171,10 +171,10 @@ uint32_t FPF_SKIANormalizeFontName(const CFX_ByteStringC& bsfamily) { return dwHash; } -uint32_t FPF_SKIAGetFamilyHash(const CFX_ByteStringC& bsFamily, +uint32_t FPF_SKIAGetFamilyHash(const ByteStringView& bsFamily, uint32_t dwStyle, uint8_t uCharset) { - CFX_ByteString bsFont(bsFamily); + ByteString bsFont(bsFamily); if (dwStyle & FXFONT_BOLD) bsFont += "Bold"; if (dwStyle & FXFONT_ITALIC) @@ -191,14 +191,14 @@ bool FPF_SkiaIsCJK(uint8_t uCharset) { (uCharset == FX_CHARSET_Hangul) || (uCharset == FX_CHARSET_ShiftJIS); } -bool FPF_SkiaMaybeSymbol(const CFX_ByteStringC& bsFacename) { - CFX_ByteString bsName(bsFacename); +bool FPF_SkiaMaybeSymbol(const ByteStringView& bsFacename) { + ByteString bsName(bsFacename); bsName.MakeLower(); return bsName.Contains("symbol"); } -bool FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename) { - CFX_ByteString bsName(bsFacename); +bool FPF_SkiaMaybeArabic(const ByteStringView& bsFacename) { + ByteString bsName(bsFacename); bsName.MakeLower(); return bsName.Contains("arabic"); } @@ -280,7 +280,7 @@ void CFPF_SkiaFontMgr::LoadSystemFonts() { m_bLoaded = true; } -CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, +CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname, uint8_t uCharset, uint32_t dwStyle, uint32_t dwMatch) { @@ -387,7 +387,7 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace( return face; } -FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile, +FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const ByteStringView& bsFile, int32_t iFaceIndex) { if (bsFile.IsEmpty()) return nullptr; @@ -421,23 +421,23 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer, return face; } -void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteString& path) { +void CFPF_SkiaFontMgr::ScanPath(const ByteString& path) { DIR* handle = FX_OpenFolder(path.c_str()); if (!handle) return; - CFX_ByteString filename; + ByteString filename; bool bFolder = false; while (FX_GetNextFile(handle, &filename, &bFolder)) { if (bFolder) { if (filename == "." || filename == "..") continue; } else { - CFX_ByteString ext = filename.Right(4); + ByteString ext = filename.Right(4); ext.MakeLower(); if (ext != ".ttf" && ext != ".ttc" && ext != ".otf") continue; } - CFX_ByteString fullpath(path); + ByteString fullpath(path); fullpath += "/"; fullpath += filename; if (bFolder) @@ -448,8 +448,8 @@ void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteString& path) { FX_CloseFolder(handle); } -void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteString& file) { - FXFT_Face face = GetFontFace(file.AsStringC()); +void CFPF_SkiaFontMgr::ScanFile(const ByteString& file) { + FXFT_Face face = GetFontFace(file.AsStringView()); if (!face) return; CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont; diff --git a/core/fxge/android/cfpf_skiafontmgr.h b/core/fxge/android/cfpf_skiafontmgr.h index 4d0ea0e0d2..78d01717b9 100644 --- a/core/fxge/android/cfpf_skiafontmgr.h +++ b/core/fxge/android/cfpf_skiafontmgr.h @@ -25,7 +25,7 @@ class CFPF_SkiaFontMgr { ~CFPF_SkiaFontMgr(); void LoadSystemFonts(); - CFPF_SkiaFont* CreateFont(const CFX_ByteStringC& bsFamilyname, + CFPF_SkiaFont* CreateFont(const ByteStringView& bsFamilyname, uint8_t uCharset, uint32_t dwStyle, uint32_t dwMatch = 0); @@ -33,14 +33,14 @@ class CFPF_SkiaFontMgr { bool InitFTLibrary(); FXFT_Face GetFontFace(const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead, int32_t iFaceIndex = 0); - FXFT_Face GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex = 0); + FXFT_Face GetFontFace(const ByteStringView& bsFile, int32_t iFaceIndex = 0); FXFT_Face GetFontFace(const uint8_t* pBuffer, size_t szBuffer, int32_t iFaceIndex = 0); private: - void ScanPath(const CFX_ByteString& path); - void ScanFile(const CFX_ByteString& file); + void ScanPath(const ByteString& path); + void ScanFile(const ByteString& file); void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor* pFontDesc); bool m_bLoaded; diff --git a/core/fxge/android/cfx_androidfontinfo.cpp b/core/fxge/android/cfx_androidfontinfo.cpp index 1183cdeaaa..c6c3e61866 100644 --- a/core/fxge/android/cfx_androidfontinfo.cpp +++ b/core/fxge/android/cfx_androidfontinfo.cpp @@ -63,7 +63,7 @@ uint32_t CFX_AndroidFontInfo::GetFontData(void* hFont, return static_cast<CFPF_SkiaFont*>(hFont)->GetFontData(table, buffer, size); } -bool CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString* name) { +bool CFX_AndroidFontInfo::GetFaceName(void* hFont, ByteString* name) { if (!hFont) return false; diff --git a/core/fxge/android/cfx_androidfontinfo.h b/core/fxge/android/cfx_androidfontinfo.h index 17bbf89a3e..3fde349fb3 100644 --- a/core/fxge/android/cfx_androidfontinfo.h +++ b/core/fxge/android/cfx_androidfontinfo.h @@ -35,7 +35,7 @@ class CFX_AndroidFontInfo : public IFX_SystemFontInfo { uint32_t table, uint8_t* buffer, uint32_t size) override; - bool GetFaceName(void* hFont, CFX_ByteString* name) override; + bool GetFaceName(void* hFont, ByteString* name) override; bool GetFontCharset(void* hFont, int* charset) override; void DeleteFont(void* hFont) override; diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp index 2eee8e2e62..637984797a 100644 --- a/core/fxge/apple/fx_mac_imp.cpp +++ b/core/fxge/apple/fx_mac_imp.cpp @@ -51,7 +51,7 @@ class CFX_MacFontInfo : public CFX_FolderFontInfo { const char JAPAN_GOTHIC[] = "Hiragino Kaku Gothic Pro W6"; const char JAPAN_MINCHO[] = "Hiragino Mincho Pro W6"; -void GetJapanesePreference(CFX_ByteString* face, int weight, int pitch_family) { +void GetJapanesePreference(ByteString* face, int weight, int pitch_family) { if (face->Contains("Gothic")) { *face = JAPAN_GOTHIC; return; @@ -66,9 +66,9 @@ void* CFX_MacFontInfo::MapFont(int weight, int pitch_family, const char* cstr_face, int& iExact) { - CFX_ByteString face = cstr_face; + ByteString face = cstr_face; for (size_t i = 0; i < FX_ArraySize(g_Base14Substs); ++i) { - if (face == CFX_ByteStringC(g_Base14Substs[i].m_pName)) { + if (face == ByteStringView(g_Base14Substs[i].m_pName)) { face = g_Base14Substs[i].m_pSubstName; iExact = true; return GetFont(face.c_str()); @@ -83,7 +83,7 @@ void* CFX_MacFontInfo::MapFont(int weight, // fonts in |m_FontList| with |face| in the name, and examine the fonts to // see which best matches the requested characteristics. if (!face.Contains("Bold") && !face.Contains("Italic")) { - CFX_ByteString new_face = face; + ByteString new_face = face; if (weight > 400) new_face += " Bold"; if (bItalic) diff --git a/core/fxge/cfx_facecache.cpp b/core/fxge/cfx_facecache.cpp index eac28074fc..74b38ef61d 100644 --- a/core/fxge/cfx_facecache.cpp +++ b/core/fxge/cfx_facecache.cpp @@ -299,7 +299,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(const CFX_Font* pFont, } } #endif - CFX_ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); + ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_ || \ defined _SKIA_SUPPORT_PATHS_ return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, @@ -344,7 +344,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(const CFX_Font* pFont, keygen.Generate(6, nMatrixA, nMatrixB, nMatrixC, nMatrixD, dest_width, anti_alias); } - CFX_ByteString FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen); + ByteString FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen); text_flags |= FXTEXT_NO_NATIVETEXT; return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey2, glyph_index, bFontStyle, dest_width, anti_alias); @@ -375,7 +375,7 @@ void CFX_FaceCache::InitPlatform() {} CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( const CFX_Font* pFont, const CFX_Matrix* pMatrix, - const CFX_ByteString& FaceGlyphsKey, + const ByteString& FaceGlyphsKey, uint32_t glyph_index, bool bFontStyle, int dest_width, diff --git a/core/fxge/cfx_facecache.h b/core/fxge/cfx_facecache.h index 076ba1f330..58b08edde5 100644 --- a/core/fxge/cfx_facecache.h +++ b/core/fxge/cfx_facecache.h @@ -52,7 +52,7 @@ class CFX_FaceCache { int anti_alias); CFX_GlyphBitmap* LookUpGlyphBitmap(const CFX_Font* pFont, const CFX_Matrix* pMatrix, - const CFX_ByteString& FaceGlyphsKey, + const ByteString& FaceGlyphsKey, uint32_t glyph_index, bool bFontStyle, int dest_width, @@ -61,7 +61,7 @@ class CFX_FaceCache { void DestroyPlatform(); FXFT_Face const m_Face; - std::map<CFX_ByteString, std::unique_ptr<CFX_SizeGlyphCache>> m_SizeMap; + std::map<ByteString, std::unique_ptr<CFX_SizeGlyphCache>> m_SizeMap; std::map<uint32_t, std::unique_ptr<CFX_PathData>> m_PathMap; #if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_ sk_sp<SkTypeface> m_pTypeface; diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp index f4f57e4b05..0dc61c998f 100644 --- a/core/fxge/cfx_folderfontinfo.cpp +++ b/core/fxge/cfx_folderfontinfo.cpp @@ -36,18 +36,18 @@ const struct { {"Times-Italic", "Times New Roman Italic"}, }; -CFX_ByteString FPDF_ReadStringFromFile(FILE* pFile, uint32_t size) { - CFX_ByteString buffer; +ByteString FPDF_ReadStringFromFile(FILE* pFile, uint32_t size) { + ByteString buffer; if (!fread(buffer.GetBuffer(size), size, 1, pFile)) - return CFX_ByteString(); + return ByteString(); buffer.ReleaseBuffer(size); return buffer; } -CFX_ByteString FPDF_LoadTableFromTT(FILE* pFile, - const uint8_t* pTables, - uint32_t nTables, - uint32_t tag) { +ByteString FPDF_LoadTableFromTT(FILE* pFile, + const uint8_t* pTables, + uint32_t nTables, + uint32_t tag) { for (uint32_t i = 0; i < nTables; i++) { const uint8_t* p = pTables + i * 16; if (GET_TT_LONG(p) == tag) { @@ -57,7 +57,7 @@ CFX_ByteString FPDF_LoadTableFromTT(FILE* pFile, return FPDF_ReadStringFromFile(pFile, size); } } - return CFX_ByteString(); + return ByteString(); } uint32_t GetCharset(int charset) { @@ -106,7 +106,7 @@ CFX_FolderFontInfo::CFX_FolderFontInfo() {} CFX_FolderFontInfo::~CFX_FolderFontInfo() {} -void CFX_FolderFontInfo::AddPath(const CFX_ByteString& path) { +void CFX_FolderFontInfo::AddPath(const ByteString& path) { m_PathList.push_back(path); } @@ -117,25 +117,25 @@ bool CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { return true; } -void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) { +void CFX_FolderFontInfo::ScanPath(const ByteString& path) { FX_FileHandle* handle = FX_OpenFolder(path.c_str()); if (!handle) return; - CFX_ByteString filename; + ByteString filename; bool bFolder; while (FX_GetNextFile(handle, &filename, &bFolder)) { if (bFolder) { if (filename == "." || filename == "..") continue; } else { - CFX_ByteString ext = filename.Right(4); + ByteString ext = filename.Right(4); ext.MakeUpper(); if (ext != ".TTF" && ext != ".OTF" && ext != ".TTC") continue; } - CFX_ByteString fullpath = path; + ByteString fullpath = path; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ fullpath += "\\"; #else @@ -148,7 +148,7 @@ void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) { FX_CloseFolder(handle); } -void CFX_FolderFontInfo::ScanFile(const CFX_ByteString& path) { +void CFX_FolderFontInfo::ScanFile(const ByteString& path) { FILE* pFile = fopen(path.c_str(), "rb"); if (!pFile) return; @@ -190,7 +190,7 @@ void CFX_FolderFontInfo::ScanFile(const CFX_ByteString& path) { fclose(pFile); } -void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path, +void CFX_FolderFontInfo::ReportFace(const ByteString& path, FILE* pFile, uint32_t filesize, uint32_t offset) { @@ -200,21 +200,20 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path, return; uint32_t nTables = GET_TT_SHORT(buffer + 4); - CFX_ByteString tables = FPDF_ReadStringFromFile(pFile, nTables * 16); + ByteString tables = FPDF_ReadStringFromFile(pFile, nTables * 16); if (tables.IsEmpty()) return; - CFX_ByteString names = + ByteString names = FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x6e616d65); if (names.IsEmpty()) return; - CFX_ByteString facename = - GetNameFromTT(names.raw_str(), names.GetLength(), 1); + ByteString facename = GetNameFromTT(names.raw_str(), names.GetLength(), 1); if (facename.IsEmpty()) return; - CFX_ByteString style = GetNameFromTT(names.raw_str(), names.GetLength(), 2); + ByteString style = GetNameFromTT(names.raw_str(), names.GetLength(), 2); if (style != "Regular") facename += " " + style; @@ -223,7 +222,7 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path, auto pInfo = pdfium::MakeUnique<CFX_FontFaceInfo>(path, facename, tables, offset, filesize); - CFX_ByteString os2 = + ByteString os2 = FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x4f532f32); if (os2.GetLength() >= 86) { const uint8_t* p = os2.raw_str() + 78; @@ -262,7 +261,7 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path, m_FontList[facename] = std::move(pInfo); } -void* CFX_FolderFontInfo::GetSubstFont(const CFX_ByteString& face) { +void* CFX_FolderFontInfo::GetSubstFont(const ByteString& face) { for (size_t iBaseFont = 0; iBaseFont < FX_ArraySize(Base14Substs); iBaseFont++) { if (face == Base14Substs[iBaseFont].m_pName) @@ -284,7 +283,7 @@ void* CFX_FolderFontInfo::FindFont(int weight, uint32_t charset_flag = GetCharset(charset); int32_t iBestSimilar = 0; for (const auto& it : m_FontList) { - const CFX_ByteString& bsName = it.first; + const ByteString& bsName = it.first; CFX_FontFaceInfo* pFont = it.second.get(); if (!(pFont->m_Charsets & charset_flag) && charset != FX_CHARSET_Default) continue; @@ -367,7 +366,7 @@ uint32_t CFX_FolderFontInfo::GetFontData(void* hFont, void CFX_FolderFontInfo::DeleteFont(void* hFont) {} -bool CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString* name) { +bool CFX_FolderFontInfo::GetFaceName(void* hFont, ByteString* name) { if (!hFont) return false; *name = static_cast<CFX_FontFaceInfo*>(hFont)->m_FaceName; diff --git a/core/fxge/cfx_folderfontinfo.h b/core/fxge/cfx_folderfontinfo.h index 82ed902b22..e7c3f21a9f 100644 --- a/core/fxge/cfx_folderfontinfo.h +++ b/core/fxge/cfx_folderfontinfo.h @@ -21,7 +21,7 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo { CFX_FolderFontInfo(); ~CFX_FolderFontInfo() override; - void AddPath(const CFX_ByteString& path); + void AddPath(const ByteString& path); // IFX_SytemFontInfo: bool EnumFontList(CFX_FontMapper* pMapper) override; @@ -43,17 +43,17 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo { uint8_t* buffer, uint32_t size) override; void DeleteFont(void* hFont) override; - bool GetFaceName(void* hFont, CFX_ByteString* name) override; + bool GetFaceName(void* hFont, ByteString* name) override; bool GetFontCharset(void* hFont, int* charset) override; protected: - void ScanPath(const CFX_ByteString& path); - void ScanFile(const CFX_ByteString& path); - void ReportFace(const CFX_ByteString& path, + void ScanPath(const ByteString& path); + void ScanFile(const ByteString& path); + void ReportFace(const ByteString& path, FILE* pFile, uint32_t filesize, uint32_t offset); - void* GetSubstFont(const CFX_ByteString& face); + void* GetSubstFont(const ByteString& face); void* FindFont(int weight, bool bItalic, int charset, @@ -61,8 +61,8 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo { const char* family, bool bMatchName); - std::map<CFX_ByteString, std::unique_ptr<CFX_FontFaceInfo>> m_FontList; - std::vector<CFX_ByteString> m_PathList; + std::map<ByteString, std::unique_ptr<CFX_FontFaceInfo>> m_FontList; + std::vector<ByteString> m_PathList; CFX_UnownedPtr<CFX_FontMapper> m_pMapper; }; diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp index 7a51df1b85..017b120dd4 100644 --- a/core/fxge/cfx_font.cpp +++ b/core/fxge/cfx_font.cpp @@ -291,7 +291,7 @@ void CFX_Font::DeleteFace() { m_Face = nullptr; } -void CFX_Font::LoadSubst(const CFX_ByteString& face_name, +void CFX_Font::LoadSubst(const ByteString& face_name, bool bTrueType, uint32_t flags, int weight, @@ -446,7 +446,7 @@ bool CFX_Font::IsItalic() const { if (FXFT_Is_Face_Italic(m_Face) == FXFT_STYLE_FLAG_ITALIC) return true; - CFX_ByteString str(FXFT_Get_Face_Style_Name(m_Face)); + ByteString str(FXFT_Get_Face_Style_Name(m_Face)); str.MakeLower(); return str.Contains("italic"); } @@ -459,31 +459,31 @@ bool CFX_Font::IsFixedWidth() const { return m_Face && FXFT_Is_Face_fixedwidth(m_Face) != 0; } -CFX_ByteString CFX_Font::GetPsName() const { +ByteString CFX_Font::GetPsName() const { if (!m_Face) - return CFX_ByteString(); + return ByteString(); - CFX_ByteString psName = FXFT_Get_Postscript_Name(m_Face); + ByteString psName = FXFT_Get_Postscript_Name(m_Face); if (psName.IsEmpty()) psName = "Untitled"; return psName; } -CFX_ByteString CFX_Font::GetFamilyName() const { +ByteString CFX_Font::GetFamilyName() const { if (!m_Face && !m_pSubstFont) - return CFX_ByteString(); + return ByteString(); if (m_Face) - return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); + return ByteString(FXFT_Get_Face_Family_Name(m_Face)); return m_pSubstFont->m_Family; } -CFX_ByteString CFX_Font::GetFaceName() const { +ByteString CFX_Font::GetFaceName() const { if (!m_Face && !m_pSubstFont) - return CFX_ByteString(); + return ByteString(); if (m_Face) { - CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face)); - CFX_ByteString facename = GetFamilyName(); + ByteString style = ByteString(FXFT_Get_Face_Style_Name(m_Face)); + ByteString facename = GetFamilyName(); if (facename.IsEmpty()) facename = "Untitled"; if (!style.IsEmpty() && style != "Regular") diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp index bff9fad5c3..4e26c62eeb 100644 --- a/core/fxge/cfx_fontmapper.cpp +++ b/core/fxge/cfx_fontmapper.cpp @@ -170,7 +170,7 @@ const struct CODEPAGE_MAP { }; int CompareFontFamilyString(const void* key, const void* element) { - CFX_ByteString str_key((const char*)key); + ByteString str_key((const char*)key); const AltFontFamily* family = reinterpret_cast<const AltFontFamily*>(element); if (str_key.Contains(family->m_pFontName)) return 0; @@ -182,8 +182,8 @@ int CompareString(const void* key, const void* element) { reinterpret_cast<const AltFontName*>(element)->m_pName); } -CFX_ByteString TT_NormalizeName(const char* family) { - CFX_ByteString norm(family); +ByteString TT_NormalizeName(const char* family) { + ByteString norm(family); norm.Remove(' '); norm.Remove('-'); norm.Remove(','); @@ -207,7 +207,7 @@ uint8_t GetCharsetFromCodePage(uint16_t codepage) { return FX_CHARSET_Default; } -CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) { +ByteString GetFontFamily(ByteString fontName, int nStyle) { if (fontName.Contains("Script")) { if ((nStyle & FX_FONT_STYLE_Bold) == FX_FONT_STYLE_Bold) fontName = "ScriptMTBold"; @@ -222,23 +222,23 @@ CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) { AltFontFamily* found = reinterpret_cast<AltFontFamily*>(bsearch( fontName.c_str(), g_AltFontFamilies, FX_ArraySize(g_AltFontFamilies), sizeof(AltFontFamily), CompareFontFamilyString)); - return found ? CFX_ByteString(found->m_pFontFamily) : fontName; + return found ? ByteString(found->m_pFontFamily) : fontName; } -CFX_ByteString ParseStyle(const char* pStyle, int iLen, int iIndex) { +ByteString ParseStyle(const char* pStyle, int iLen, int iIndex) { std::ostringstream buf; if (!iLen || iLen <= iIndex) - return CFX_ByteString(buf); + return ByteString(buf); while (iIndex < iLen) { if (pStyle[iIndex] == ',') break; buf << pStyle[iIndex]; ++iIndex; } - return CFX_ByteString(buf); + return ByteString(buf); } -int32_t GetStyleType(const CFX_ByteString& bsStyle, bool bReverse) { +int32_t GetStyleType(const ByteString& bsStyle, bool bReverse) { int32_t iLen = bsStyle.GetLength(); if (!iLen) return -1; @@ -260,7 +260,7 @@ int32_t GetStyleType(const CFX_ByteString& bsStyle, bool bReverse) { return -1; } -bool CheckSupportThirdPartFont(CFX_ByteString name, int& PitchFamily) { +bool CheckSupportThirdPartFont(ByteString name, int& PitchFamily) { if (name == "MyriadPro") { PitchFamily &= ~FXFONT_FF_ROMAN; return true; @@ -305,23 +305,23 @@ void CFX_FontMapper::SetSystemFontInfo( m_pFontInfo = std::move(pFontInfo); } -CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) { +ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) { if (!m_pFontInfo) - return CFX_ByteString(); + return ByteString(); uint32_t size = m_pFontInfo->GetFontData(hFont, kTableNAME, nullptr, 0); if (!size) - return CFX_ByteString(); + return ByteString(); std::vector<uint8_t> buffer(size); uint8_t* buffer_ptr = buffer.data(); uint32_t bytes_read = m_pFontInfo->GetFontData(hFont, kTableNAME, buffer_ptr, size); return bytes_read == size ? GetNameFromTT(buffer_ptr, bytes_read, 6) - : CFX_ByteString(); + : ByteString(); } -void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { +void CFX_FontMapper::AddInstalledFont(const ByteString& name, int charset) { if (!m_pFontInfo) return; @@ -343,7 +343,7 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { return; } - CFX_ByteString new_name = GetPSNameFromTT(hFont); + ByteString new_name = GetPSNameFromTT(hFont); if (!new_name.IsEmpty()) m_LocalizedTTFonts.push_back(std::make_pair(new_name, name)); m_pFontInfo->DeleteFont(hFont); @@ -360,22 +360,20 @@ void CFX_FontMapper::LoadInstalledFonts() { m_bListLoaded = true; } -CFX_ByteString CFX_FontMapper::MatchInstalledFonts( - const CFX_ByteString& norm_name) { +ByteString CFX_FontMapper::MatchInstalledFonts(const ByteString& norm_name) { LoadInstalledFonts(); int i; for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) { - CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str()); + ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str()); if (norm1 == norm_name) return m_InstalledTTFonts[i]; } for (i = pdfium::CollectionSize<int>(m_LocalizedTTFonts) - 1; i >= 0; i--) { - CFX_ByteString norm1 = - TT_NormalizeName(m_LocalizedTTFonts[i].first.c_str()); + ByteString norm1 = TT_NormalizeName(m_LocalizedTTFonts[i].first.c_str()); if (norm1 == norm_name) return m_LocalizedTTFonts[i].second; } - return CFX_ByteString(); + return ByteString(); } FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, @@ -418,7 +416,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, return m_MMFaces[0]; } -FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, +FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name, bool bTrueType, uint32_t flags, int weight, @@ -429,7 +427,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, weight = FXFONT_FW_NORMAL; italic_angle = 0; } - CFX_ByteString SubstName = name; + ByteString SubstName = name; SubstName.Remove(' '); if (bTrueType && name.GetLength() > 0 && name[0] == '@') SubstName = name.Right(name.GetLength() - 1); @@ -445,8 +443,8 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, return UseInternalSubst(pSubstFont, 13, italic_angle, weight, 0); } int iBaseFont = 0; - CFX_ByteString family; - CFX_ByteString style; + ByteString family; + ByteString style; bool bHasComma = false; bool bHasHyphen = false; auto pos = SubstName.Find(",", 0); @@ -459,7 +457,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, family = SubstName; } for (; iBaseFont < 12; iBaseFont++) { - if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) + if (family == ByteStringView(g_Base14FontNames[iBaseFont])) break; } int PitchFamily = 0; @@ -505,7 +503,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, const char* pStyle = style.c_str(); int i = 0; bool bFirstItem = true; - CFX_ByteString buf; + ByteString buf; while (i < nLen) { buf = ParseStyle(pStyle, nLen, i); int32_t nRet = GetStyleType(buf, false); @@ -568,7 +566,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, PitchFamily); } family = GetFontFamily(family, nStyle); - CFX_ByteString match = MatchInstalledFonts(TT_NormalizeName(family.c_str())); + ByteString match = MatchInstalledFonts(TT_NormalizeName(family.c_str())); if (match.IsEmpty() && family != SubstName && (!bHasComma && (!bHasHyphen || (bHasHyphen && !bStyleAvail)))) { match = MatchInstalledFonts(TT_NormalizeName(SubstName.c_str())); @@ -742,7 +740,7 @@ FXFT_Face CFX_FontMapper::FindSubstFontByUnicode(uint32_t dwUnicode, if (ttc_size) { face = GetCachedTTCFace(hFont, 0x74746366, ttc_size, font_size); } else { - CFX_ByteString SubstName; + ByteString SubstName; m_pFontInfo->GetFaceName(hFont, &SubstName); face = GetCachedFace(hFont, SubstName, weight, bItalic, font_size); } @@ -791,7 +789,7 @@ FXFT_Face CFX_FontMapper::GetCachedTTCFace(void* hFont, } FXFT_Face CFX_FontMapper::GetCachedFace(void* hFont, - CFX_ByteString SubstName, + ByteString SubstName, int weight, bool bItalic, uint32_t font_size) { @@ -808,7 +806,7 @@ FXFT_Face CFX_FontMapper::GetCachedFace(void* hFont, return face; } -int PDF_GetStandardFontName(CFX_ByteString* name) { +int PDF_GetStandardFontName(ByteString* name) { AltFontName* found = static_cast<AltFontName*>( bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), sizeof(AltFontName), CompareString)); diff --git a/core/fxge/cfx_fontmapper.h b/core/fxge/cfx_fontmapper.h index 1b262bf0f4..3f28c73150 100644 --- a/core/fxge/cfx_fontmapper.h +++ b/core/fxge/cfx_fontmapper.h @@ -23,10 +23,10 @@ class CFX_FontMapper { void SetSystemFontInfo(std::unique_ptr<IFX_SystemFontInfo> pFontInfo); IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo.get(); } - void AddInstalledFont(const CFX_ByteString& name, int charset); + void AddInstalledFont(const ByteString& name, int charset); void LoadInstalledFonts(); - FXFT_Face FindSubstFont(const CFX_ByteString& face_name, + FXFT_Face FindSubstFont(const ByteString& face_name, bool bTrueType, uint32_t flags, int weight, @@ -41,19 +41,17 @@ class CFX_FontMapper { #endif // PDF_ENABLE_XFA bool IsBuiltinFace(const FXFT_Face face) const; int GetFaceSize() const; - CFX_ByteString GetFaceName(int index) const { - return m_FaceArray[index].name; - } + ByteString GetFaceName(int index) const { return m_FaceArray[index].name; } - std::vector<CFX_ByteString> m_InstalledTTFonts; - std::vector<std::pair<CFX_ByteString, CFX_ByteString>> m_LocalizedTTFonts; + std::vector<ByteString> m_InstalledTTFonts; + std::vector<std::pair<ByteString, ByteString>> m_LocalizedTTFonts; private: static const size_t MM_FACE_COUNT = 2; static const size_t FOXIT_FACE_COUNT = 14; - CFX_ByteString GetPSNameFromTT(void* hFont); - CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); + ByteString GetPSNameFromTT(void* hFont); + ByteString MatchInstalledFonts(const ByteString& norm_name); FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, int iBaseFont, int italic_angle, @@ -64,19 +62,19 @@ class CFX_FontMapper { uint32_t ttc_size, uint32_t font_size); FXFT_Face GetCachedFace(void* hFont, - CFX_ByteString SubstName, + ByteString SubstName, int weight, bool bItalic, uint32_t font_size); struct FaceData { - CFX_ByteString name; + ByteString name; uint32_t charset; }; bool m_bListLoaded; FXFT_Face m_MMFaces[MM_FACE_COUNT]; - CFX_ByteString m_LastFamily; + ByteString m_LastFamily; std::vector<FaceData> m_FaceArray; std::unique_ptr<IFX_SystemFontInfo> m_pFontInfo; FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT]; diff --git a/core/fxge/cfx_fontmgr.cpp b/core/fxge/cfx_fontmgr.cpp index c8beb515f0..f68598e4b6 100644 --- a/core/fxge/cfx_fontmgr.cpp +++ b/core/fxge/cfx_fontmgr.cpp @@ -46,18 +46,18 @@ const BuiltinFont g_MMFonts[2] = { {g_FoxitSansMMFontData, 66919}, }; -CFX_ByteString KeyNameFromFace(const CFX_ByteString& face_name, - int weight, - bool bItalic) { - CFX_ByteString key(face_name); +ByteString KeyNameFromFace(const ByteString& face_name, + int weight, + bool bItalic) { + ByteString key(face_name); key += ','; - key += CFX_ByteString::FormatInteger(weight); + key += ByteString::FormatInteger(weight); key += bItalic ? 'I' : 'N'; return key; } -CFX_ByteString KeyNameFromSize(int ttc_size, uint32_t checksum) { - CFX_ByteString key; +ByteString KeyNameFromSize(int ttc_size, uint32_t checksum) { + ByteString key; key.Format("%d:%d", ttc_size, checksum); return key; } @@ -110,7 +110,7 @@ void CFX_FontMgr::SetSystemFontInfo( m_pBuiltinMapper->SetSystemFontInfo(std::move(pFontInfo)); } -FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, +FXFT_Face CFX_FontMgr::FindSubstFont(const ByteString& face_name, bool bTrueType, uint32_t flags, int weight, @@ -122,7 +122,7 @@ FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, italic_angle, CharsetCP, pSubstFont); } -FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, +FXFT_Face CFX_FontMgr::GetCachedFace(const ByteString& face_name, int weight, bool bItalic, uint8_t*& pFontData) { @@ -136,7 +136,7 @@ FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, return pFontDesc->m_SingleFace; } -FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, +FXFT_Face CFX_FontMgr::AddCachedFace(const ByteString& face_name, int weight, bool bItalic, uint8_t* pData, diff --git a/core/fxge/cfx_fontmgr.h b/core/fxge/cfx_fontmgr.h index 7ccad807df..eddb1efd56 100644 --- a/core/fxge/cfx_fontmgr.h +++ b/core/fxge/cfx_fontmgr.h @@ -24,11 +24,11 @@ class CFX_FontMgr { void InitFTLibrary(); - FXFT_Face GetCachedFace(const CFX_ByteString& face_name, + FXFT_Face GetCachedFace(const ByteString& face_name, int weight, bool bItalic, uint8_t*& pFontData); - FXFT_Face AddCachedFace(const CFX_ByteString& face_name, + FXFT_Face AddCachedFace(const ByteString& face_name, int weight, bool bItalic, uint8_t* pData, @@ -47,7 +47,7 @@ class CFX_FontMgr { FXFT_Face GetFixedFace(const uint8_t* pData, uint32_t size, int face_index); void ReleaseFace(FXFT_Face face); void SetSystemFontInfo(std::unique_ptr<IFX_SystemFontInfo> pFontInfo); - FXFT_Face FindSubstFont(const CFX_ByteString& face_name, + FXFT_Face FindSubstFont(const ByteString& face_name, bool bTrueType, uint32_t flags, int weight, @@ -61,7 +61,7 @@ class CFX_FontMgr { private: std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper; - std::map<CFX_ByteString, std::unique_ptr<CTTFontDesc>> m_FaceMap; + std::map<ByteString, std::unique_ptr<CTTFontDesc>> m_FaceMap; FXFT_Library m_FTLibrary; bool m_FTLibrarySupportsHinting; }; diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index 959c909b5e..5e9f5ae0c9 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp @@ -336,7 +336,7 @@ bool ShouldDrawDeviceText(const CFX_Font* pFont, uint32_t text_flags) { if (text_flags & FXFONT_CIDFONT) return false; - const CFX_ByteString bsPsName = pFont->GetPsName(); + const ByteString bsPsName = pFont->GetPsName(); if (bsPsName.Contains("+ZJHL")) return false; diff --git a/core/fxge/cfx_substfont.h b/core/fxge/cfx_substfont.h index 01196d442a..5225bd38f3 100644 --- a/core/fxge/cfx_substfont.h +++ b/core/fxge/cfx_substfont.h @@ -16,7 +16,7 @@ class CFX_SubstFont { public: CFX_SubstFont(); - CFX_ByteString m_Family; + ByteString m_Family; int m_Charset; uint32_t m_SubstFlags; int m_Weight; diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h index 57fdb54821..021efee7d9 100644 --- a/core/fxge/fx_font.h +++ b/core/fxge/fx_font.h @@ -87,7 +87,7 @@ class CFX_Font { CFX_Font(); ~CFX_Font(); - void LoadSubst(const CFX_ByteString& face_name, + void LoadSubst(const ByteString& face_name, bool bTrueType, uint32_t flags, int weight, @@ -130,9 +130,9 @@ class CFX_Font { bool IsBold() const; bool IsFixedWidth() const; bool IsVertical() const { return m_bVertical; } - CFX_ByteString GetPsName() const; - CFX_ByteString GetFamilyName() const; - CFX_ByteString GetFaceName() const; + ByteString GetPsName() const; + ByteString GetFamilyName() const; + ByteString GetFaceName() const; bool IsTTFont() const; bool GetBBox(FX_RECT& bbox); bool IsEmbedded() const { return m_bEmbedded; } @@ -183,15 +183,15 @@ class CFX_Font { class CFX_FontFaceInfo { public: - CFX_FontFaceInfo(CFX_ByteString filePath, - CFX_ByteString faceName, - CFX_ByteString fontTables, + CFX_FontFaceInfo(ByteString filePath, + ByteString faceName, + ByteString fontTables, uint32_t fontOffset, uint32_t fileSize); - const CFX_ByteString m_FilePath; - const CFX_ByteString m_FaceName; - const CFX_ByteString m_FontTables; + const ByteString m_FilePath; + const ByteString m_FaceName; + const ByteString m_FontTables; const uint32_t m_FontOffset; const uint32_t m_FileSize; uint32_t m_Styles; @@ -229,10 +229,10 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs, float retinaScaleX, float retinaScaleY); -CFX_ByteString GetNameFromTT(const uint8_t* name_table, - uint32_t name_table_size, - uint32_t name); +ByteString GetNameFromTT(const uint8_t* name_table, + uint32_t name_table_size, + uint32_t name); -int PDF_GetStandardFontName(CFX_ByteString* name); +int PDF_GetStandardFontName(ByteString* name); #endif // CORE_FXGE_FX_FONT_H_ diff --git a/core/fxge/fx_ge_fontmap.cpp b/core/fxge/fx_ge_fontmap.cpp index 7ac4fada5c..0f2703875d 100644 --- a/core/fxge/fx_ge_fontmap.cpp +++ b/core/fxge/fx_ge_fontmap.cpp @@ -9,28 +9,28 @@ #include "core/fxge/cfx_fontmapper.h" #include "core/fxge/ifx_systemfontinfo.h" -static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr, - uint32_t string_ptr_length, - uint16_t offset, - uint16_t length) { +static ByteString GetStringFromTable(const uint8_t* string_ptr, + uint32_t string_ptr_length, + uint16_t offset, + uint16_t length) { if (string_ptr_length < static_cast<uint32_t>(offset + length)) { - return CFX_ByteString(); + return ByteString(); } - return CFX_ByteString(string_ptr + offset, length); + return ByteString(string_ptr + offset, length); } -CFX_ByteString GetNameFromTT(const uint8_t* name_table, - uint32_t name_table_size, - uint32_t name_id) { +ByteString GetNameFromTT(const uint8_t* name_table, + uint32_t name_table_size, + uint32_t name_id) { if (!name_table || name_table_size < 6) { - return CFX_ByteString(); + return ByteString(); } uint32_t name_count = GET_TT_SHORT(name_table + 2); uint32_t string_offset = GET_TT_SHORT(name_table + 4); // We will ignore the possibility of overlap of structures and // string table as if it's all corrupt there's not a lot we can do. if (name_table_size < string_offset) { - return CFX_ByteString(); + return ByteString(); } const uint8_t* string_ptr = name_table + string_offset; @@ -38,7 +38,7 @@ CFX_ByteString GetNameFromTT(const uint8_t* name_table, name_table += 6; name_table_size -= 6; if (name_table_size < name_count * 12) { - return CFX_ByteString(); + return ByteString(); } for (uint32_t i = 0; i < name_count; i++, name_table += 12) { @@ -49,7 +49,7 @@ CFX_ByteString GetNameFromTT(const uint8_t* name_table, GET_TT_SHORT(name_table + 8)); } } - return CFX_ByteString(); + return ByteString(); } #ifdef PDF_ENABLE_XFA void* IFX_SystemFontInfo::MapFontByUnicode(uint32_t dwUnicode, @@ -79,9 +79,9 @@ std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault( } #endif -CFX_FontFaceInfo::CFX_FontFaceInfo(CFX_ByteString filePath, - CFX_ByteString faceName, - CFX_ByteString fontTables, +CFX_FontFaceInfo::CFX_FontFaceInfo(ByteString filePath, + ByteString faceName, + ByteString fontTables, uint32_t fontOffset, uint32_t fileSize) : m_FilePath(filePath), diff --git a/core/fxge/fx_ge_linux.cpp b/core/fxge/fx_ge_linux.cpp index d17ddf2d3d..650510f63e 100644 --- a/core/fxge/fx_ge_linux.cpp +++ b/core/fxge/fx_ge_linux.cpp @@ -44,7 +44,7 @@ const char* const g_LinuxHGFontList[] = { size_t GetJapanesePreference(const char* facearr, int weight, int pitch_family) { - CFX_ByteString face = facearr; + ByteString face = facearr; if (face.Contains("Gothic") || face.Contains("\x83\x53\x83\x56\x83\x62\x83\x4e")) { if (face.Contains("PGothic") || diff --git a/core/fxge/ifx_systemfontinfo.h b/core/fxge/ifx_systemfontinfo.h index ca7ca2c455..cb85f7fde4 100644 --- a/core/fxge/ifx_systemfontinfo.h +++ b/core/fxge/ifx_systemfontinfo.h @@ -42,7 +42,7 @@ class IFX_SystemFontInfo { uint32_t table, uint8_t* buffer, uint32_t size) = 0; - virtual bool GetFaceName(void* hFont, CFX_ByteString* name) = 0; + virtual bool GetFaceName(void* hFont, ByteString* name) = 0; virtual bool GetFontCharset(void* hFont, int* charset) = 0; virtual int GetFaceIndex(void* hFont); virtual void DeleteFont(void* hFont) = 0; diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index c02058d1dd..5586d9f921 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -669,9 +669,9 @@ bool CFX_PSRenderer::DrawText(int nChars, last_fontnum = ps_fontnum; } buf << pCharPos[i].m_Origin.x << " " << pCharPos[i].m_Origin.y << " m"; - CFX_ByteString hex; + ByteString hex; hex.Format("<%02X>", ps_glyphindex); - buf << hex.AsStringC() << "Tj\n"; + buf << hex.AsStringView() << "Tj\n"; } buf << "Q\n"; m_pStream->WriteBlock(buf.str().c_str(), buf.tellp()); diff --git a/core/fxge/win32/cfx_windowsdib.h b/core/fxge/win32/cfx_windowsdib.h index 3ecbb5835d..28f152acfa 100644 --- a/core/fxge/win32/cfx_windowsdib.h +++ b/core/fxge/win32/cfx_windowsdib.h @@ -33,8 +33,7 @@ class CFX_WindowsDIB : public CFX_DIBitmap { ~CFX_WindowsDIB() override; - static CFX_ByteString GetBitmapInfo( - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap); + static ByteString GetBitmapInfo(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap); static HBITMAP GetDDBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, HDC hDC); diff --git a/core/fxge/win32/cpsoutput.cpp b/core/fxge/win32/cpsoutput.cpp index 1af6dbdced..83f2fc09c6 100644 --- a/core/fxge/win32/cpsoutput.cpp +++ b/core/fxge/win32/cpsoutput.cpp @@ -31,6 +31,6 @@ bool CPSOutput::WriteBlock(const void* str, size_t len) { return true; } -bool CPSOutput::WriteString(const CFX_ByteStringC& str) { +bool CPSOutput::WriteString(const ByteStringView& str) { return WriteBlock(str.unterminated_c_str(), str.GetLength()); } diff --git a/core/fxge/win32/cpsoutput.h b/core/fxge/win32/cpsoutput.h index 42ad109a80..d140de95f4 100644 --- a/core/fxge/win32/cpsoutput.h +++ b/core/fxge/win32/cpsoutput.h @@ -19,7 +19,7 @@ class CPSOutput : public IFX_WriteStream { // IFX_Writestream bool WriteBlock(const void* str, size_t len) override; - bool WriteString(const CFX_ByteStringC& str) override; + bool WriteString(const ByteStringView& str) override; private: HDC m_hDC; diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 9c8da591c6..bb7bf6fea1 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -73,7 +73,7 @@ const FontNameMap g_JpFontNameMap[] = { {"MS Gothic", "Jun101-Light"}, }; -bool GetSubFontName(CFX_ByteString* name) { +bool GetSubFontName(ByteString* name) { for (size_t i = 0; i < FX_ArraySize(g_JpFontNameMap); ++i) { if (!FXSYS_stricmp(name->c_str(), g_JpFontNameMap[i].m_pSrcFontName)) { *name = g_JpFontNameMap[i].m_pSubFontName; @@ -349,23 +349,21 @@ class CFX_Win32FontInfo final : public IFX_SystemFontInfo { uint32_t table, uint8_t* buffer, uint32_t size) override; - bool GetFaceName(void* hFont, CFX_ByteString* name) override; + bool GetFaceName(void* hFont, ByteString* name) override; bool GetFontCharset(void* hFont, int* charset) override; void DeleteFont(void* hFont) override; bool IsOpenTypeFromDiv(const LOGFONTA* plf); bool IsSupportFontFormDiv(const LOGFONTA* plf); void AddInstalledFont(const LOGFONTA* plf, uint32_t FontType); - void GetGBPreference(CFX_ByteString& face, int weight, int picth_family); - void GetJapanesePreference(CFX_ByteString& face, - int weight, - int picth_family); - CFX_ByteString FindFont(const CFX_ByteString& name); + void GetGBPreference(ByteString& face, int weight, int picth_family); + void GetJapanesePreference(ByteString& face, int weight, int picth_family); + ByteString FindFont(const ByteString& name); HDC m_hDC; CFX_UnownedPtr<CFX_FontMapper> m_pMapper; - CFX_ByteString m_LastFamily; - CFX_ByteString m_KaiTi, m_FangSong; + ByteString m_LastFamily; + ByteString m_KaiTi, m_FangSong; }; int CALLBACK FontEnumProc(const LOGFONTA* plf, @@ -429,7 +427,7 @@ bool CFX_Win32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf) { void CFX_Win32FontInfo::AddInstalledFont(const LOGFONTA* plf, uint32_t FontType) { - CFX_ByteString name(plf->lfFaceName); + ByteString name(plf->lfFaceName); if (name.GetLength() > 0 && name[0] == '@') return; @@ -458,21 +456,21 @@ bool CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper) { return true; } -CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) { +ByteString CFX_Win32FontInfo::FindFont(const ByteString& name) { if (!m_pMapper) return name; for (size_t i = 0; i < m_pMapper->m_InstalledTTFonts.size(); ++i) { - CFX_ByteString thisname = m_pMapper->m_InstalledTTFonts[i]; + ByteString thisname = m_pMapper->m_InstalledTTFonts[i]; if (thisname.Left(name.GetLength()) == name) return m_pMapper->m_InstalledTTFonts[i]; } for (size_t i = 0; i < m_pMapper->m_LocalizedTTFonts.size(); ++i) { - CFX_ByteString thisname = m_pMapper->m_LocalizedTTFonts[i].first; + ByteString thisname = m_pMapper->m_LocalizedTTFonts[i].first; if (thisname.Left(name.GetLength()) == name) return m_pMapper->m_LocalizedTTFonts[i].second; } - return CFX_ByteString(); + return ByteString(); } void* CFX_Win32FallbackFontInfo::MapFont(int weight, @@ -500,7 +498,7 @@ void* CFX_Win32FallbackFontInfo::MapFont(int weight, return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); } -void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face, +void CFX_Win32FontInfo::GetGBPreference(ByteString& face, int weight, int picth_family) { if (face.Contains("KaiTi") || face.Contains("\xbf\xac")) { @@ -530,7 +528,7 @@ void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face, } } -void CFX_Win32FontInfo::GetJapanesePreference(CFX_ByteString& face, +void CFX_Win32FontInfo::GetJapanesePreference(ByteString& face, int weight, int picth_family) { if (face.Contains("Gothic") || @@ -573,10 +571,10 @@ void* CFX_Win32FontInfo::MapFont(int weight, int pitch_family, const char* cstr_face, int& iExact) { - CFX_ByteString face = cstr_face; + ByteString face = cstr_face; int iBaseFont; for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) - if (face == CFX_ByteStringC(g_Base14Substs[iBaseFont].m_pName)) { + if (face == ByteStringView(g_Base14Substs[iBaseFont].m_pName)) { face = g_Base14Substs[iBaseFont].m_pWinName; weight = g_Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL; bItalic = g_Base14Substs[iBaseFont].m_bItalic; @@ -607,15 +605,15 @@ void* CFX_Win32FontInfo::MapFont(int weight, if (face.EqualNoCase(facebuf)) return hFont; - CFX_WideString wsFace = CFX_WideString::FromLocal(facebuf); + WideString wsFace = WideString::FromLocal(facebuf); for (size_t i = 0; i < FX_ArraySize(g_VariantNames); ++i) { if (face != g_VariantNames[i].m_pFaceName) continue; const unsigned short* pName = reinterpret_cast<const unsigned short*>( g_VariantNames[i].m_pVariantName); - FX_STRSIZE len = CFX_WideString::WStringLength(pName); - CFX_WideString wsName = CFX_WideString::FromUTF16LE(pName, len); + FX_STRSIZE len = WideString::WStringLength(pName); + WideString wsName = WideString::FromUTF16LE(pName, len); if (wsFace == wsName) return hFont; } @@ -665,7 +663,7 @@ uint32_t CFX_Win32FontInfo::GetFontData(void* hFont, return size; } -bool CFX_Win32FontInfo::GetFaceName(void* hFont, CFX_ByteString* name) { +bool CFX_Win32FontInfo::GetFaceName(void* hFont, ByteString* name) { char facebuf[100]; HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); int ret = ::GetTextFaceA(m_hDC, 100, facebuf); @@ -702,7 +700,7 @@ std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault( CHAR windows_path[MAX_PATH] = {}; DWORD path_len = ::GetWindowsDirectoryA(windows_path, MAX_PATH); if (path_len > 0 && path_len < MAX_PATH) { - CFX_ByteString fonts_path(windows_path); + ByteString fonts_path(windows_path); fonts_path += "\\Fonts"; pInfoFallback->AddPath(fonts_path); } @@ -799,7 +797,7 @@ bool CGdiDeviceDriver::GDI_SetDIBits( int width = pSrcRect->Width(), height = pSrcRect->Height(); LPBYTE pBuffer = pBitmap->GetBuffer(); - CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); + ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); ((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1; FX_RECT dst_rect(0, 0, width, height); dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); @@ -817,7 +815,7 @@ bool CGdiDeviceDriver::GDI_SetDIBits( } int width = pSrcRect->Width(), height = pSrcRect->Height(); LPBYTE pBuffer = pBitmap->GetBuffer(); - CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); + ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, pBitmap->GetHeight() - pSrcRect->bottom, 0, pBitmap->GetHeight(), pBuffer, @@ -840,7 +838,7 @@ bool CGdiDeviceDriver::GDI_StretchDIBits( if (pBitmap->IsCmykImage() && !pBitmap->ConvertFormat(FXDIB_Rgb)) return false; - CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); + ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); if ((int64_t)abs(dest_width) * abs(dest_height) < (int64_t)pBitmap1->GetWidth() * pBitmap1->GetHeight() * 4 || (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { @@ -854,7 +852,7 @@ bool CGdiDeviceDriver::GDI_StretchDIBits( (int64_t)abs(dest_width) * abs(dest_height))) { pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height, 0, nullptr); } - CFX_ByteString toStrechBitmapInfo = + ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap); ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeight(), diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp index d1e5688ee1..c00543b169 100644 --- a/core/fxge/win32/fx_win32_dib.cpp +++ b/core/fxge/win32/fx_win32_dib.cpp @@ -11,9 +11,9 @@ #include "core/fxge/win32/cfx_windowsdib.h" #include "core/fxge/win32/win32_int.h" -CFX_ByteString CFX_WindowsDIB::GetBitmapInfo( +ByteString CFX_WindowsDIB::GetBitmapInfo( const CFX_RetainPtr<CFX_DIBitmap>& pBitmap) { - CFX_ByteString result; + ByteString result; int len = sizeof(BITMAPINFOHEADER); if (pBitmap->GetBPP() == 1 || pBitmap->GetBPP() == 8) { len += sizeof(DWORD) * (int)(1 << pBitmap->GetBPP()); @@ -102,7 +102,7 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, HDC hDC) { - CFX_ByteString info = GetBitmapInfo(pBitmap); + ByteString info = GetBitmapInfo(pBitmap); return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); @@ -139,7 +139,7 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile( DeleteDC(hDC); return nullptr; } - CFX_ByteString info = GetBitmapInfo(pDIBitmap); + ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); DeleteDC(hDC); @@ -149,7 +149,7 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile( } CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile(const char* filename) { - return LoadFromFile(CFX_WideString::FromLocal(filename).c_str()); + return LoadFromFile(WideString::FromLocal(filename).c_str()); } CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadDIBitmap( @@ -175,7 +175,7 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadDIBitmap( DeleteDC(hDC); return nullptr; } - CFX_ByteString info = GetBitmapInfo(pDIBitmap); + ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); DeleteDC(hDC); diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index 04788d6138..8161c5d333 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -682,7 +682,7 @@ CGdiplusExt::CGdiplusExt() { m_pGdiRemoveFontMemResourseEx = nullptr; } void CGdiplusExt::Load() { - CFX_ByteString strPlusPath = ""; + ByteString strPlusPath = ""; char buf[MAX_PATH]; GetSystemDirectoryA(buf, MAX_PATH); strPlusPath += buf; diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index ecd7be57c7..fa2c8b7ef3 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -232,7 +232,7 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars, lf.lfItalic = pFont->IsItalic(); lf.lfCharSet = DEFAULT_CHARSET; - const CFX_WideString wsName = pFont->GetFaceName().UTF8Decode(); + const WideString wsName = pFont->GetFaceName().UTF8Decode(); size_t iNameLen = std::min(wsName.GetLength(), static_cast<size_t>(LF_FACESIZE - 1)); memcpy(lf.lfFaceName, wsName.c_str(), sizeof(lf.lfFaceName[0]) * iNameLen); @@ -288,7 +288,7 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars, SetBkMode(m_hDC, TRANSPARENT); // Text - CFX_WideString wsText; + WideString wsText; std::vector<INT> spacing(nChars); float fPreviousOriginX = 0; for (int i = 0; i < nChars; ++i) { @@ -609,7 +609,7 @@ bool CTextOnlyPrinterDriver::DrawDeviceText(int nChars, // errors below. Value chosen based on the title of https://crbug.com/18383 const double kScaleFactor = 10; - CFX_WideString wsText; + WideString wsText; int totalLength = nChars; // Detect new lines and add clrf characters (since this is Windows only). @@ -638,7 +638,7 @@ bool CTextOnlyPrinterDriver::DrawDeviceText(int nChars, wsText += charpos.m_Unicode; } size_t len = totalLength; - CFX_ByteString text = CFX_ByteString::FromUnicode(wsText); + ByteString text = ByteString::FromUnicode(wsText); while (len > 0) { char buffer[1026]; size_t send_len = std::min(len, static_cast<size_t>(1024)); |