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

Side by Side Diff: core/src/fxge/ge/fx_ge_fontmap.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: Fixed linux font regressions. Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « core/include/fxge/fx_font.h ('k') | core/src/fxge/ge/fx_ge_linux.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "../../../include/fxge/fx_ge.h" 9 #include "../../../include/fxge/fx_ge.h"
10 #include "../../../include/fxge/fx_freetype.h" 10 #include "../../../include/fxge/fx_freetype.h"
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 } 1400 }
1401 if (style.Find(FX_BSTRC("Italic")) > -1 || 1401 if (style.Find(FX_BSTRC("Italic")) > -1 ||
1402 style.Find(FX_BSTRC("Oblique")) > -1) { 1402 style.Find(FX_BSTRC("Oblique")) > -1) {
1403 pInfo->m_Styles |= FXFONT_ITALIC; 1403 pInfo->m_Styles |= FXFONT_ITALIC;
1404 } 1404 }
1405 if (facename.Find(FX_BSTRC("Serif")) > -1) { 1405 if (facename.Find(FX_BSTRC("Serif")) > -1) {
1406 pInfo->m_Styles |= FXFONT_SERIF; 1406 pInfo->m_Styles |= FXFONT_SERIF;
1407 } 1407 }
1408 m_FontList[facename] = pInfo; 1408 m_FontList[facename] = pInfo;
1409 } 1409 }
1410 static const struct {
1411 const FX_CHAR* m_pName;
1412 const FX_CHAR* m_pSubstName;
1413 } Base14Substs[] = {
1414 {"Courier", "Courier New"},
1415 {"Courier-Bold", "Courier New Bold"},
1416 {"Courier-BoldOblique", "Courier New Bold Italic"},
1417 {"Courier-Oblique", "Courier New Italic"},
1418 {"Helvetica", "Arial"},
1419 {"Helvetica-Bold", "Arial Bold"},
1420 {"Helvetica-BoldOblique", "Arial Bold Italic"},
1421 {"Helvetica-Oblique", "Arial Italic"},
1422 {"Times-Roman", "Times New Roman"},
1423 {"Times-Bold", "Times New Roman Bold"},
1424 {"Times-BoldItalic", "Times New Roman Bold Italic"},
1425 {"Times-Italic", "Times New Roman Italic"},
1426 };
1427 void* CFX_FolderFontInfo::GetSubstFont(const CFX_ByteString& face) {
1428 for (size_t iBaseFont = 0; iBaseFont < FX_ArraySize(Base14Substs);
1429 iBaseFont++) {
1430 if (face == Base14Substs[iBaseFont].m_pName) {
1431 return GetFont(Base14Substs[iBaseFont].m_pSubstName);
1432 }
1433 }
1434 return nullptr;
1435 }
1436 static FX_DWORD _GetCharset(int charset) {
1437 switch (charset) {
1438 case FXFONT_SHIFTJIS_CHARSET:
1439 return CHARSET_FLAG_SHIFTJIS;
1440 case FXFONT_GB2312_CHARSET:
1441 return CHARSET_FLAG_GB;
1442 case FXFONT_CHINESEBIG5_CHARSET:
1443 return CHARSET_FLAG_BIG5;
1444 case FXFONT_HANGEUL_CHARSET:
1445 return CHARSET_FLAG_KOREAN;
1446 case FXFONT_SYMBOL_CHARSET:
1447 return CHARSET_FLAG_SYMBOL;
1448 case FXFONT_ANSI_CHARSET:
1449 return CHARSET_FLAG_ANSI;
1450 default:
1451 break;
1452 }
1453 return 0;
1454 }
1455 static int32_t _GetSimilarValue(int weight,
1456 FX_BOOL bItalic,
1457 int pitch_family,
1458 FX_DWORD style) {
1459 int32_t iSimilarValue = 0;
1460 if ((style & FXFONT_BOLD) == (weight > 400)) {
1461 iSimilarValue += 16;
1462 }
1463 if ((style & FXFONT_ITALIC) == bItalic) {
1464 iSimilarValue += 16;
1465 }
1466 if ((style & FXFONT_SERIF) == (pitch_family & FXFONT_FF_ROMAN)) {
1467 iSimilarValue += 16;
1468 }
1469 if ((style & FXFONT_SCRIPT) == (pitch_family & FXFONT_FF_SCRIPT)) {
1470 iSimilarValue += 8;
1471 }
1472 if ((style & FXFONT_FIXED_PITCH) == (pitch_family & FXFONT_FF_FIXEDPITCH)) {
1473 iSimilarValue += 8;
1474 }
1475 return iSimilarValue;
1476 }
1477 void* CFX_FolderFontInfo::FindFont(int weight,
1478 FX_BOOL bItalic,
1479 int charset,
1480 int pitch_family,
1481 const FX_CHAR* family,
1482 FX_BOOL bMatchName) {
1483 CFX_FontFaceInfo* pFind = nullptr;
1484 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
1485 return GetFont("Courier New");
1486 }
1487 FX_DWORD charset_flag = _GetCharset(charset);
1488 int32_t iBestSimilar = 0;
1489 for (const auto& it : m_FontList) {
1490 const CFX_ByteString& bsName = it.first;
1491 CFX_FontFaceInfo* pFont = it.second;
1492 if (!(pFont->m_Charsets & charset_flag) &&
1493 charset != FXFONT_DEFAULT_CHARSET) {
1494 continue;
1495 }
1496 int32_t index = bsName.Find(family);
1497 if (bMatchName && index < 0) {
1498 continue;
1499 }
1500 int32_t iSimilarValue =
1501 _GetSimilarValue(weight, bItalic, pitch_family, pFont->m_Styles);
1502 if (iSimilarValue > iBestSimilar) {
1503 iBestSimilar = iSimilarValue;
1504 pFind = pFont;
1505 }
1506 }
1507 return pFind;
1508 }
1410 void* CFX_FolderFontInfo::MapFont(int weight, 1509 void* CFX_FolderFontInfo::MapFont(int weight,
1411 FX_BOOL bItalic, 1510 FX_BOOL bItalic,
1412 int charset, 1511 int charset,
1413 int pitch_family, 1512 int pitch_family,
1414 const FX_CHAR* family, 1513 const FX_CHAR* family,
1415 int& iExact) { 1514 int& iExact) {
1416 return NULL; 1515 return NULL;
1417 } 1516 }
1418 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) { 1517 void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) {
1419 auto it = m_FontList.find(face); 1518 auto it = m_FontList.find(face);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 if (hFont == NULL) { 1563 if (hFont == NULL) {
1465 return FALSE; 1564 return FALSE;
1466 } 1565 }
1467 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; 1566 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont;
1468 name = pFont->m_FaceName; 1567 name = pFont->m_FaceName;
1469 return TRUE; 1568 return TRUE;
1470 } 1569 }
1471 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { 1570 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) {
1472 return FALSE; 1571 return FALSE;
1473 } 1572 }
OLDNEW
« no previous file with comments | « core/include/fxge/fx_font.h ('k') | core/src/fxge/ge/fx_ge_linux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698