summaryrefslogtreecommitdiff
path: root/core/src/fxge/ge
diff options
context:
space:
mode:
authorJohn Abd-El-Malek <jam@chromium.org>2014-12-12 16:42:18 -0800
committerJohn Abd-El-Malek <jam@chromium.org>2014-12-12 16:42:18 -0800
commit217ecf3b39f8d5c01260684848a8886c8ed2bf89 (patch)
tree1ab05e729480f2d8fab6882285c2e169c8ba007e /core/src/fxge/ge
parent239955073722582152d9ab190794317dd775a1c1 (diff)
downloadpdfium-217ecf3b39f8d5c01260684848a8886c8ed2bf89.tar.xz
Simplify PDFium by removing code that's not used in the open source repo.
-remove parameter from FPDF_InitLibrary -remove a bunch of ifdefs that are unused R=tsepez@chromium.org Review URL: https://codereview.chromium.org/801913002
Diffstat (limited to 'core/src/fxge/ge')
-rw-r--r--core/src/fxge/ge/fx_ge_font.cpp11
-rw-r--r--core/src/fxge/ge/fx_ge_fontmap.cpp4
-rw-r--r--core/src/fxge/ge/fx_ge_linux.cpp259
-rw-r--r--core/src/fxge/ge/fx_ge_text.cpp10
4 files changed, 5 insertions, 279 deletions
diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp
index 817f3712d9..f9e1fe61df 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -32,18 +32,14 @@ CFX_Font::~CFX_Font()
delete m_pSubstFont;
m_pSubstFont = NULL;
}
-#ifdef FOXIT_CHROME_BUILD
if (m_pFontDataAllocation) {
FX_Free(m_pFontDataAllocation);
m_pFontDataAllocation = NULL;
}
-#endif
if (m_Face) {
-#ifdef FOXIT_CHROME_BUILD
if (FXFT_Get_Face_External_Stream(m_Face)) {
FXFT_Clear_Face_External_Stream(m_Face);
}
-#endif
if(m_bEmbedded) {
DeleteFace();
} else {
@@ -58,7 +54,7 @@ CFX_Font::~CFX_Font()
FX_Free(m_pGsubData);
m_pGsubData = NULL;
}
-#if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ && (!defined(_FPDFAPI_MINI_)))
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
ReleasePlatformResource();
#endif
}
@@ -183,7 +179,6 @@ static FXFT_Face FT_LoadFont(FX_LPBYTE pData, int size)
}
FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size)
{
-#ifdef FOXIT_CHROME_BUILD
m_pFontDataAllocation = FX_Alloc(FX_BYTE, size);
if (!m_pFontDataAllocation) {
return FALSE;
@@ -191,10 +186,6 @@ FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size)
FXSYS_memcpy32(m_pFontDataAllocation, data, size);
m_Face = FT_LoadFont((FX_LPBYTE)m_pFontDataAllocation, size);
m_pFontData = (FX_LPBYTE)m_pFontDataAllocation;
-#else
- m_Face = FT_LoadFont((FX_LPBYTE)data, size);
- m_pFontData = (FX_LPBYTE)data;
-#endif
m_bEmbedded = TRUE;
m_dwSize = size;
return m_Face != NULL;
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index a5fa6443a8..36f28f330c 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -1308,13 +1308,12 @@ CFontFileFaceInfo::~CFontFileFaceInfo()
m_Face = NULL;
}
extern FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FXFT_Stream* stream);
-#if defined(_FPDFAPI_MINI_) || _FX_OS_ == _FX_ANDROID_
+#if _FX_OS_ == _FX_ANDROID_
IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()
{
return NULL;
}
#endif
-#if !defined(_FPDFAPI_MINI_)
CFX_FolderFontInfo::CFX_FolderFontInfo()
{
}
@@ -1547,4 +1546,3 @@ FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset)
{
return FALSE;
}
-#endif
diff --git a/core/src/fxge/ge/fx_ge_linux.cpp b/core/src/fxge/ge/fx_ge_linux.cpp
deleted file mode 100644
index 735ecac0c8..0000000000
--- a/core/src/fxge/ge/fx_ge_linux.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-// 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 "../agg/include/fx_agg_driver.h"
-#include "text_int.h"
-#if !defined(_FPDFAPI_MINI_) && _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_
-#if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ && (!defined(_FPDFAPI_MINI_)))
-void CFX_AggDeviceDriver::InitPlatform()
-{
-}
-void CFX_AggDeviceDriver::DestroyPlatform()
-{
-}
-void CFX_FaceCache::InitPlatform()
-{
-}
-FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,
- CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device,
- FX_FLOAT font_size, FX_DWORD argb)
-{
- return FALSE;
-}
-CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext(CFX_Font* pFont, FX_DWORD glyph_index, const CFX_AffineMatrix* pMatrix,
- int dest_width, int anti_alias)
-{
- return NULL;
-}
-void CFX_Font::ReleasePlatformResource()
-{
-}
-#endif
-static const struct {
- FX_LPCSTR m_pName;
- FX_LPCSTR 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_LinuxFontInfo : public CFX_FolderFontInfo
-{
-public:
- virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL& bExact);
- FX_BOOL ParseFontCfg();
- void* FindFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL bMatchName);
-};
-#define LINUX_GPNAMESIZE 6
-static const struct {
- FX_LPCSTR NameArr[LINUX_GPNAMESIZE];
-}
-LinuxGpFontList[] = {
- {{"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", "VL Gothic regular"}},
- {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", NULL, "VL Gothic regular"}},
- {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothic regular"}},
- {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothic regular"}},
-};
-static const FX_LPCSTR g_LinuxGbFontList[] = {
- "AR PL UMing CN Light",
- "WenQuanYi Micro Hei",
- "AR PL UKai CN",
-};
-static const FX_LPCSTR g_LinuxB5FontList[] = {
- "AR PL UMing TW Light",
- "WenQuanYi Micro Hei",
- "AR PL UKai TW",
-};
-static const FX_LPCSTR g_LinuxHGFontList[] = {
- "UnDotum",
-};
-static FX_INT32 GetJapanesePreference(FX_LPCSTR facearr, int weight, int picth_family)
-{
- CFX_ByteString face = facearr;
- if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
- if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
- return 0;
- } else {
- return 1;
- }
- } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
- if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) {
- return 2;
- } else {
- return 3;
- }
- }
- if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
- return 0;
- }
- return 2;
-}
-void* CFX_LinuxFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR cstr_face, FX_BOOL& bExact)
-{
- 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;
- bExact = TRUE;
- break;
- }
- if (iBaseFont < 12) {
- return GetFont(face);
- }
- FX_LPVOID p = NULL;
- FX_BOOL bCJK = TRUE;
- switch (charset) {
- case FXFONT_SHIFTJIS_CHARSET: {
- FX_INT32 index = GetJapanesePreference(cstr_face, weight, pitch_family);
- if (index < 0) {
- break;
- }
- for (FX_INT32 i = 0; i < LINUX_GPNAMESIZE; i++)
- if (m_FontList.Lookup(LinuxGpFontList[index].NameArr[i], p)) {
- return p;
- }
- }
- break;
- case FXFONT_GB2312_CHARSET: {
- static FX_INT32 s_gbCount = sizeof(g_LinuxGbFontList) / sizeof(FX_LPCSTR);
- for (FX_INT32 i = 0; i < s_gbCount; i++)
- if (m_FontList.Lookup(g_LinuxGbFontList[i], p)) {
- return p;
- }
- }
- break;
- case FXFONT_CHINESEBIG5_CHARSET: {
- static FX_INT32 s_b5Count = sizeof(g_LinuxB5FontList) / sizeof(FX_LPCSTR);
- for (FX_INT32 i = 0; i < s_b5Count; i++)
- if (m_FontList.Lookup(g_LinuxB5FontList[i], p)) {
- return p;
- }
- }
- break;
- case FXFONT_HANGEUL_CHARSET: {
- static FX_INT32 s_hgCount = sizeof(g_LinuxHGFontList) / sizeof(FX_LPCSTR);
- for (FX_INT32 i = 0; i < s_hgCount; i++)
- if (m_FontList.Lookup(g_LinuxHGFontList[i], p)) {
- return p;
- }
- }
- break;
- default:
- bCJK = FALSE;
- break;
- }
- if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
- return GetFont("Courier New");
- }
- return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK);
-}
-static FX_DWORD _LinuxGetCharset(int charset)
-{
- switch(charset) {
- case FXFONT_SHIFTJIS_CHARSET:
- return CHARSET_FLAG_SHIFTJIS;
- case FXFONT_GB2312_CHARSET:
- return CHARSET_FLAG_GB;
- case FXFONT_CHINESEBIG5_CHARSET:
- return CHARSET_FLAG_BIG5;
- case FXFONT_HANGEUL_CHARSET:
- return CHARSET_FLAG_KOREAN;
- case FXFONT_SYMBOL_CHARSET:
- return CHARSET_FLAG_SYMBOL;
- case FXFONT_ANSI_CHARSET:
- return CHARSET_FLAG_ANSI;
- default:
- break;
- }
- return 0;
-}
-static FX_INT32 _LinuxGetSimilarValue(int weight, FX_BOOL bItalic, int pitch_family, FX_DWORD style)
-{
- FX_INT32 iSimilarValue = 0;
- if ((style & FXFONT_BOLD) == (weight > 400)) {
- iSimilarValue += 16;
- }
- if ((style & FXFONT_ITALIC) == bItalic) {
- iSimilarValue += 16;
- }
- if ((style & FXFONT_SERIF) == (pitch_family & FXFONT_FF_ROMAN)) {
- iSimilarValue += 16;
- }
- if ((style & FXFONT_SCRIPT) == (pitch_family & FXFONT_FF_SCRIPT)) {
- iSimilarValue += 8;
- }
- if ((style & FXFONT_FIXED_PITCH) == (pitch_family & FXFONT_FF_FIXEDPITCH)) {
- iSimilarValue += 8;
- }
- return iSimilarValue;
-}
-void* CFX_LinuxFontInfo::FindFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL bMatchName)
-{
- CFontFaceInfo* pFind = NULL;
- FX_DWORD charset_flag = _LinuxGetCharset(charset);
- FX_INT32 iBestSimilar = 0;
- FX_POSITION pos = m_FontList.GetStartPosition();
- while (pos) {
- CFX_ByteString bsName;
- CFontFaceInfo* pFont = NULL;
- m_FontList.GetNextAssoc(pos, bsName, (FX_LPVOID&)pFont);
- if (!(pFont->m_Charsets & charset_flag) && charset != FXFONT_DEFAULT_CHARSET) {
- continue;
- }
- FX_INT32 iSimilarValue = 0;
- FX_INT32 index = bsName.Find(family);
- if (bMatchName && index < 0) {
- continue;
- }
- if (!bMatchName && index > 0) {
- iSimilarValue += 64;
- }
- iSimilarValue = _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFont->m_Styles);
- if (iSimilarValue > iBestSimilar) {
- iBestSimilar = iSimilarValue;
- pFind = pFont;
- }
- }
- return pFind;
-}
-IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()
-{
- CFX_LinuxFontInfo* pInfo = FX_NEW CFX_LinuxFontInfo;
- if (!pInfo) {
- return NULL;
- }
- if (!pInfo->ParseFontCfg()) {
- pInfo->AddPath("/usr/share/fonts");
- pInfo->AddPath("/usr/share/X11/fonts/Type1");
- pInfo->AddPath("/usr/share/X11/fonts/TTF");
- pInfo->AddPath("/usr/local/share/fonts");
- }
- return pInfo;
-}
-FX_BOOL CFX_LinuxFontInfo::ParseFontCfg()
-{
- return FALSE;
-}
-void CFX_GEModule::InitPlatform()
-{
- m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());
-}
-void CFX_GEModule::DestroyPlatform()
-{
-}
-#endif
diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp
index 440ecdd696..eb9b7d0a13 100644
--- a/core/src/fxge/ge/fx_ge_text.cpp
+++ b/core/src/fxge/ge/fx_ge_text.cpp
@@ -1070,7 +1070,7 @@ CFX_FaceCache::~CFX_FaceCache()
}
m_PathMap.RemoveAll();
}
-#if ((_FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_)|| defined(_FPDFAPI_MINI_))
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
void CFX_FaceCache::InitPlatform()
{
}
@@ -1105,7 +1105,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
return NULL;
}
_CFX_UniqueKeyGen keygen;
-#if ((_FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_)|| defined(_FPDFAPI_MINI_))
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
if (pFont->GetSubstFont())
keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000),
(int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias,
@@ -1133,7 +1133,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
}
#endif
CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
-#if ((_FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_)|| defined(_FPDFAPI_MINI_))
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontStyle, dest_width, anti_alias);
#else
if (text_flags & FXTEXT_NO_NATIVETEXT) {
@@ -1186,11 +1186,7 @@ CFX_SizeGlyphCache::~CFX_SizeGlyphCache()
}
m_GlyphMap.RemoveAll();
}
-#if defined(_FPDFAPI_MINI_)
-#define CONTRAST_RAMP_STEP 16
-#else
#define CONTRAST_RAMP_STEP 1
-#endif
void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight)
{
FXFT_MM_Var pMasters = NULL;