Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: core/src/fxge/ge/fx_ge_linux.cpp

Issue 1306883002: Added a fallback Win32 font information class for win32k lockdown. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fixes from review and reuse more code. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/src/fxge/ge/fx_ge_linux.cpp
diff --git a/core/src/fxge/ge/fx_ge_linux.cpp b/core/src/fxge/ge/fx_ge_linux.cpp
index 065fd124bba0ddffd9af7771451aef5544fc8df6..02e6cfade50ac3381a36e8c4979e02548e76b852 100644
--- a/core/src/fxge/ge/fx_ge_linux.cpp
+++ b/core/src/fxge/ge/fx_ge_linux.cpp
@@ -35,12 +35,6 @@ class CFX_LinuxFontInfo : public CFX_FolderFontInfo {
const FX_CHAR* family,
int& iExact) override;
FX_BOOL ParseFontCfg(const char** pUserPaths);
- void* FindFont(int weight,
- FX_BOOL bItalic,
- int charset,
- int pitch_family,
- const FX_CHAR* family,
- FX_BOOL bMatchName);
};
#define LINUX_GPNAMESIZE 6
static const struct {
@@ -94,16 +88,10 @@ void* CFX_LinuxFontInfo::MapFont(int weight,
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 = 1;
- break;
- }
- if (iBaseFont < 12) {
- return GetFont(face);
+ void* font = GetSubstFont(cstr_face);
+ if (font) {
+ iExact = 1;
+ return font;
}
FX_BOOL bCJK = TRUE;
switch (charset) {
@@ -147,85 +135,8 @@ void* CFX_LinuxFontInfo::MapFont(int weight,
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 int32_t _LinuxGetSimilarValue(int weight,
- FX_BOOL bItalic,
- int pitch_family,
- FX_DWORD style) {
- int32_t 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,
- const FX_CHAR* family,
- FX_BOOL bMatchName) {
- CFX_FontFaceInfo* pFind = NULL;
- FX_DWORD charset_flag = _LinuxGetCharset(charset);
- int32_t iBestSimilar = 0;
- for (const auto& it : m_FontList) {
- const CFX_ByteString& bsName = it.first;
- CFX_FontFaceInfo* pFont = it.second;
- if (!(pFont->m_Charsets & charset_flag) &&
- charset != FXFONT_DEFAULT_CHARSET) {
- continue;
- }
- int32_t iSimilarValue = 0;
- int32_t 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(const char** pUserPaths) {
CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo;
if (!pInfo->ParseFontCfg(pUserPaths)) {

Powered by Google App Engine
This is Rietveld 408576698