diff options
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/apple/apple_int.h | 41 | ||||
-rw-r--r-- | core/fxge/apple/fx_mac_imp.cpp | 57 |
2 files changed, 31 insertions, 67 deletions
diff --git a/core/fxge/apple/apple_int.h b/core/fxge/apple/apple_int.h index 0462938d5a..07484a46cd 100644 --- a/core/fxge/apple/apple_int.h +++ b/core/fxge/apple/apple_int.h @@ -18,40 +18,6 @@ #include <Carbon/Carbon.h> #endif -typedef enum eFXIOSFONTCHARSET { - eFXFontCharsetDEFAULT = 0, - eFXFontCharsetANSI = 1, - eFXFontCharsetSYMBOL = 1 << 1, - eFXFontCharsetSHIFTJIS = 1 << 2, - eFXFontCharsetHANGEUL = 1 << 3, - eFXFontCharsetGB2312 = 1 << 4, - eFXFontCharsetCHINESEBIG5 = 1 << 5, - eFXFontCharsetTHAI = 1 << 6, - eFXFontCharsetEASTEUROPE = 1 << 7, - eFXFontCharsetRUSSIAN = 1 << 8, - eFXFontCharsetGREEK = 1 << 9, - eFXFontCharsetTURKISH = 1 << 10, - eFXFontCharsetHEBREW = 1 << 11, - eFXFontCharsetARABIC = 1 << 12, - eFXFontCharsetBALTIC = 1 << 13, -} FX_IOSCHARSET; - -FX_IOSCHARSET FX_GetiOSCharset(int charset); -typedef enum eFXIOSFONTFLAG { - eFXFontFlagBold = 1, - eFXFontFlagItalic = 1 << 1, - eFXFontFlagFixedPitch = 1 << 2, - eFXFontFlagSerif = 1 << 3, - eFXFontFlagScript = 1 << 4, -} FX_IOSFONTFLAG; - -typedef struct IOS_FONTDATA_ { - uint32_t nHashCode; - const char* psName; - uint32_t charsets; - uint32_t styles; -} IOS_FONTDATA; - class CQuartz2D { public: void* createGraphics(CFX_DIBitmap* bitmap); @@ -180,11 +146,6 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { int32_t m_horzSize; int32_t m_vertSize; }; - -uint32_t FX_GetHashCode(const FX_CHAR* pStr); -uint32_t FX_IOSGetMatchFamilyNameHashcode(const FX_CHAR* pFontName); -uint32_t FX_IOSGetFamilyNamesCount(); -const FX_CHAR* FX_IOSGetFamilyName(uint32_t uIndex); -#endif +#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ #endif // CORE_FXGE_APPLE_APPLE_INT_H_ diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp index 489ce816cc..4ddc7db8ad 100644 --- a/core/fxge/apple/fx_mac_imp.cpp +++ b/core/fxge/apple/fx_mac_imp.cpp @@ -8,10 +8,13 @@ #include "core/fxge/include/fx_ge.h" #if _FX_OS_ == _FX_MACOSX_ -static const struct { + +namespace { + +const struct { const FX_CHAR* m_pName; const FX_CHAR* m_pSubstName; -} Base14Substs[] = { +} g_Base14Substs[] = { {"Courier", "Courier New"}, {"Courier-Bold", "Courier New Bold"}, {"Courier-BoldOblique", "Courier New Bold Italic"}, @@ -40,21 +43,18 @@ class CFX_MacFontInfo : public CFX_FolderFontInfo { int& iExact) override; }; -#define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6" -#define JAPAN_MINCHO "Hiragino Mincho Pro W6" -static void GetJapanesePreference(CFX_ByteString& face, - int weight, - int pitch_family) { - if (face.Find("Gothic") >= 0) { - face = JAPAN_GOTHIC; +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) { + if (face->Find("Gothic") >= 0) { + *face = JAPAN_GOTHIC; return; } - if (!(pitch_family & FXFONT_FF_ROMAN) && weight > 400) { - face = JAPAN_GOTHIC; - } else { - face = JAPAN_MINCHO; - } + *face = ((pitch_family & FXFONT_FF_ROMAN) || weight <= 400) ? JAPAN_MINCHO + : JAPAN_GOTHIC; } + void* CFX_MacFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, @@ -62,29 +62,28 @@ void* CFX_MacFontInfo::MapFont(int weight, const FX_CHAR* cstr_face, int& iExact) { CFX_ByteString face = cstr_face; - int iBaseFont; - for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) - if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { - face = Base14Substs[iBaseFont].m_pSubstName; + for (size_t i = 0; i < FX_ArraySize(g_Base14Substs); ++i) { + if (face == CFX_ByteStringC(g_Base14Substs[i].m_pName)) { + face = g_Base14Substs[i].m_pSubstName; iExact = TRUE; + return GetFont(face.c_str()); break; } - if (iBaseFont < 12) { - return GetFont(face.c_str()); } + auto it = m_FontList.find(face); if (it != m_FontList.end()) return it->second; - if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) { + if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) return GetFont("Courier New"); - } - if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { + + if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) return nullptr; - } + switch (charset) { case FXFONT_SHIFTJIS_CHARSET: - GetJapanesePreference(face, weight, pitch_family); + GetJapanesePreference(&face, weight, pitch_family); break; case FXFONT_GB2312_CHARSET: face = "STSong"; @@ -99,6 +98,8 @@ void* CFX_MacFontInfo::MapFont(int weight, return it != m_FontList.end() ? it->second : nullptr; } +} // namespace + std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault( const char** pUnused) { CFX_MacFontInfo* pInfo(new CFX_MacFontInfo); @@ -112,8 +113,10 @@ void CFX_GEModule::InitPlatform() { m_pPlatformData = new CApplePlatform; m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr)); } + void CFX_GEModule::DestroyPlatform() { - delete (CApplePlatform*)m_pPlatformData; + delete reinterpret_cast<CApplePlatform*>(m_pPlatformData); m_pPlatformData = nullptr; } -#endif + +#endif // _FX_OS_ == _FX_MACOSX_ |