Revert "Make CFX_FontMgr member variables private."
[pdfium.git] / core / src / fxge / ge / fx_ge_text.cpp
index b96b352..6938bb9 100644 (file)
@@ -182,18 +182,20 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
   int nativetext_flags = text_flags;
   if (m_DeviceClass != FXDC_DISPLAY) {
     if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) {
+      bool should_call_draw_device_text = true;
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
-      if (!(text_flags & FXFONT_CIDFONT) &&
-          pFont->GetPsName().Find(CFX_WideString::FromLocal("+ZJHL")) == -1)
-#ifdef FOXIT_CHROME_BUILD
-        if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex10"))
-#endif
+      if ((text_flags & FXFONT_CIDFONT) ||
+          (pFont->GetPsName().Find(CFX_WideString::FromLocal("+ZJHL")) != -1) ||
+          (pFont->GetPsName() == CFX_WideString::FromLocal("CNAAJI+cmex10"))) {
+        should_call_draw_device_text = false;
+      }
 #endif
-          if (m_pDeviceDriver->DrawDeviceText(
-                  nChars, pCharPos, pFont, pCache, pText2Device, font_size,
-                  fill_color, alpha_flag, pIccTransform)) {
-            return TRUE;
-          }
+      if (should_call_draw_device_text &&
+          m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache,
+                                          pText2Device, font_size, fill_color,
+                                          alpha_flag, pIccTransform)) {
+        return TRUE;
+      }
     }
     int alpha = FXGETFLAG_COLORTYPE(alpha_flag)
                     ? FXGETFLAG_ALPHA_FILL(alpha_flag)
@@ -202,17 +204,19 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
       return FALSE;
     }
   } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) {
+    bool should_call_draw_device_text = true;
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
-    if (!(text_flags & FXFONT_CIDFONT))
-#ifdef FOXIT_CHROME_BUILD
-      if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex10"))
-#endif
+    if ((text_flags & FXFONT_CIDFONT) ||
+        (pFont->GetPsName() == CFX_WideString::FromLocal("CNAAJI+cmex10"))) {
+      should_call_draw_device_text = false;
+    }
 #endif
-        if (m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache,
-                                            pText2Device, font_size, fill_color,
-                                            alpha_flag, pIccTransform)) {
-          return TRUE;
-        }
+    if (should_call_draw_device_text &&
+        m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache,
+                                        pText2Device, font_size, fill_color,
+                                        alpha_flag, pIccTransform)) {
+      return TRUE;
+    }
   }
   CFX_AffineMatrix char2device, deviceCtm, text2Device;
   if (pText2Device) {
@@ -1228,15 +1232,11 @@ CFX_FaceCache::CFX_FaceCache(FXFT_Face face) {
   m_Face = face;
 }
 CFX_FaceCache::~CFX_FaceCache() {
-  FX_POSITION pos = m_SizeMap.GetStartPosition();
-  CFX_ByteString Key;
-  CFX_SizeGlyphCache* pSizeCache = NULL;
-  while (pos) {
-    m_SizeMap.GetNextAssoc(pos, Key, (void*&)pSizeCache);
-    delete pSizeCache;
+  for (const auto& pair : m_SizeMap) {
+    delete pair.second;
   }
-  m_SizeMap.RemoveAll();
-  pos = m_PathMap.GetStartPosition();
+  m_SizeMap.clear();
+  FX_POSITION pos = m_PathMap.GetStartPosition();
   void* key1;
   CFX_PathData* pPath;
   while (pos) {
@@ -1256,10 +1256,13 @@ CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(
     FX_BOOL bFontStyle,
     int dest_width,
     int anti_alias) {
-  CFX_SizeGlyphCache* pSizeCache = NULL;
-  if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) {
+  CFX_SizeGlyphCache* pSizeCache;
+  auto it = m_SizeMap.find(FaceGlyphsKey);
+  if (it == m_SizeMap.end()) {
     pSizeCache = new CFX_SizeGlyphCache;
-    m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
+    m_SizeMap[FaceGlyphsKey] = pSizeCache;
+  } else {
+    pSizeCache = it->second;
   }
   CFX_GlyphBitmap* pGlyphBitmap = NULL;
   if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index,
@@ -1331,8 +1334,9 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(
                              bFontStyle, dest_width, anti_alias);
   }
   CFX_GlyphBitmap* pGlyphBitmap;
-  CFX_SizeGlyphCache* pSizeCache = NULL;
-  if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) {
+  auto it = m_SizeMap.find(FaceGlyphsKey);
+  if (it != m_SizeMap.end()) {
+    CFX_SizeGlyphCache* pSizeCache = it->second;
     if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index,
                                       (void*&)pGlyphBitmap)) {
       return pGlyphBitmap;
@@ -1347,8 +1351,8 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(
     pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix,
                                           dest_width, anti_alias);
     if (pGlyphBitmap) {
-      pSizeCache = new CFX_SizeGlyphCache;
-      m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
+      CFX_SizeGlyphCache* pSizeCache = new CFX_SizeGlyphCache;
+      m_SizeMap[FaceGlyphsKey] = pSizeCache;
       pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap);
       return pGlyphBitmap;
     }