Fix fix of mac build breakage at 2a2a6aa
[pdfium.git] / core / src / fxge / apple / fx_mac_imp.cpp
index 9a1218b..465dd96 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#include "../../../include/fxge/fx_ge.h"\r
-#include "apple_int.h"\r
-#if _FX_OS_ == _FX_MACOSX_\r
-static const struct {\r
-    FX_LPCSTR  m_pName;\r
-    FX_LPCSTR  m_pSubstName;\r
-}\r
-Base14Substs[] = {\r
-    {"Courier", "Courier New"},\r
-    {"Courier-Bold", "Courier New Bold"},\r
-    {"Courier-BoldOblique", "Courier New Bold Italic"},\r
-    {"Courier-Oblique", "Courier New Italic"},\r
-    {"Helvetica", "Arial"},\r
-    {"Helvetica-Bold", "Arial Bold"},\r
-    {"Helvetica-BoldOblique", "Arial Bold Italic"},\r
-    {"Helvetica-Oblique", "Arial Italic"},\r
-    {"Times-Roman", "Times New Roman"},\r
-    {"Times-Bold", "Times New Roman Bold"},\r
-    {"Times-BoldItalic", "Times New Roman Bold Italic"},\r
-    {"Times-Italic", "Times New Roman Italic"},\r
-};\r
-#if !defined(_FPDFAPI_MINI_)\r
-class CFX_MacFontInfo : public CFX_FolderFontInfo\r
-{\r
-public:\r
-    virtual void*              MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL& bExact);\r
-};\r
-#define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6"\r
-#define JAPAN_MINCHO "Hiragino Mincho Pro W6"\r
-static void GetJapanesePreference(CFX_ByteString& face, int weight, int picth_family)\r
-{\r
-    if (face.Find("Gothic") >= 0) {\r
-        face = JAPAN_GOTHIC;\r
-        return;\r
-    }\r
-    if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {\r
-        face = JAPAN_GOTHIC;\r
-    } else {\r
-        face = JAPAN_MINCHO;\r
-    }\r
-}\r
-void* CFX_MacFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR cstr_face, FX_BOOL& bExact)\r
-{\r
-    CFX_ByteString face = cstr_face;\r
-    int iBaseFont;\r
-    for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++)\r
-        if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {\r
-            face = Base14Substs[iBaseFont].m_pSubstName;\r
-            bExact = TRUE;\r
-            break;\r
-        }\r
-    if (iBaseFont < 12) {\r
-        return GetFont(face);\r
-    }\r
-    FX_LPVOID p;\r
-    if (m_FontList.Lookup(face, p)) {\r
-        return p;\r
-    }\r
-    if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {\r
-        return GetFont("Courier New");\r
-    }\r
-    if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) {\r
-        return NULL;\r
-    }\r
-    switch (charset) {\r
-        case FXFONT_SHIFTJIS_CHARSET:\r
-            GetJapanesePreference(face, weight, pitch_family);\r
-            break;\r
-        case FXFONT_GB2312_CHARSET:\r
-            face = "STSong";\r
-            break;\r
-        case FXFONT_HANGEUL_CHARSET:\r
-            face = "AppleMyungjo";\r
-            break;\r
-        case FXFONT_CHINESEBIG5_CHARSET:\r
-            face = "LiSong Pro Light";\r
-    }\r
-    if (m_FontList.Lookup(face, p)) {\r
-        return p;\r
-    }\r
-    return NULL;\r
-}\r
-#endif\r
-IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()\r
-{\r
-#if !defined(_FPDFAPI_MINI_)\r
-    CFX_MacFontInfo* pInfo = FX_NEW CFX_MacFontInfo;\r
-    if (!pInfo) {\r
-        return NULL;\r
-    }\r
-    pInfo->AddPath("~/Library/Fonts");\r
-    pInfo->AddPath("/Library/Fonts");\r
-    pInfo->AddPath("/System/Library/Fonts");\r
-    return pInfo;\r
-#else\r
-    return NULL;\r
-#endif\r
-}\r
-void CFX_GEModule::InitPlatform()\r
-{\r
-    m_pPlatformData = FX_NEW CApplePlatform;\r
-    m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());\r
-}\r
-void CFX_GEModule::DestroyPlatform()\r
-{\r
-    if (m_pPlatformData) {\r
-        delete (CApplePlatform *) m_pPlatformData;\r
-    }\r
-    m_pPlatformData = NULL;\r
-}\r
-#endif\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "../../../include/fxge/fx_ge.h"
+#include "apple_int.h"
+#if _FX_OS_ == _FX_MACOSX_
+static const struct {
+  const FX_CHAR* m_pName;
+  const FX_CHAR* m_pSubstName;
+} Base14Substs[] = {
+    {"Courier", "Courier New"},
+    {"Courier-Bold", "Courier New Bold"},
+    {"Courier-BoldOblique", "Courier New Bold Italic"},
+    {"Courier-Oblique", "Courier New Italic"},
+    {"Helvetica", "Arial"},
+    {"Helvetica-Bold", "Arial Bold"},
+    {"Helvetica-BoldOblique", "Arial Bold Italic"},
+    {"Helvetica-Oblique", "Arial Italic"},
+    {"Times-Roman", "Times New Roman"},
+    {"Times-Bold", "Times New Roman Bold"},
+    {"Times-BoldItalic", "Times New Roman Bold Italic"},
+    {"Times-Italic", "Times New Roman Italic"},
+};
+class CFX_MacFontInfo : public CFX_FolderFontInfo {
+ public:
+  virtual void* MapFont(int weight,
+                        FX_BOOL bItalic,
+                        int charset,
+                        int pitch_family,
+                        const FX_CHAR* family,
+                        int& iExact);
+};
+#define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6"
+#define JAPAN_MINCHO "Hiragino Mincho Pro W6"
+static void GetJapanesePreference(CFX_ByteString& face,
+                                  int weight,
+                                  int picth_family) {
+  if (face.Find("Gothic") >= 0) {
+    face = JAPAN_GOTHIC;
+    return;
+  }
+  if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
+    face = JAPAN_GOTHIC;
+  } else {
+    face = JAPAN_MINCHO;
+  }
+}
+void* CFX_MacFontInfo::MapFont(int weight,
+                               FX_BOOL bItalic,
+                               int charset,
+                               int pitch_family,
+                               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;
+      iExact = TRUE;
+      break;
+    }
+  if (iBaseFont < 12) {
+    return GetFont(face);
+  }
+  auto it = m_FontList.find(face);
+  if (it != m_FontList.end())
+    return it->second;
+
+  if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
+    return GetFont("Courier New");
+  }
+  if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) {
+    return NULL;
+  }
+  switch (charset) {
+    case FXFONT_SHIFTJIS_CHARSET:
+      GetJapanesePreference(face, weight, pitch_family);
+      break;
+    case FXFONT_GB2312_CHARSET:
+      face = "STSong";
+      break;
+    case FXFONT_HANGEUL_CHARSET:
+      face = "AppleMyungjo";
+      break;
+    case FXFONT_CHINESEBIG5_CHARSET:
+      face = "LiSong Pro Light";
+  }
+  it = m_FontList.Lookup(face);
+  if (it != m_FontList.end())
+    return it->second;
+
+  return NULL;
+}
+IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) {
+  CFX_MacFontInfo* pInfo = new CFX_MacFontInfo;
+  pInfo->AddPath("~/Library/Fonts");
+  pInfo->AddPath("/Library/Fonts");
+  pInfo->AddPath("/System/Library/Fonts");
+  return pInfo;
+}
+void CFX_GEModule::InitPlatform() {
+  m_pPlatformData = new CApplePlatform;
+  m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr));
+}
+void CFX_GEModule::DestroyPlatform() {
+  delete (CApplePlatform*)m_pPlatformData;
+  m_pPlatformData = NULL;
+}
+#endif