| OLD | NEW |
| 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 "core/include/fxge/fx_freetype.h" | 9 #include "core/include/fxge/fx_freetype.h" |
| 10 #include "core/include/fxge/fx_ge.h" | 10 #include "core/include/fxge/fx_ge.h" |
| 11 #include "core/src/fxge/fontdata/chromefontdata/chromefontdata.h" | 11 #include "core/src/fxge/fontdata/chromefontdata/chromefontdata.h" |
| 12 #include "text_int.h" | 12 #include "core/src/fxge/ge/text_int.h" |
| 13 #include "third_party/base/stl_util.h" | 13 #include "third_party/base/stl_util.h" |
| 14 | 14 |
| 15 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) | 15 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) |
| 16 #define GET_TT_LONG(w) \ | 16 #define GET_TT_LONG(w) \ |
| 17 (FX_DWORD)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3]) | 17 (FX_DWORD)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3]) |
| 18 | 18 |
| 19 #define FX_FONT_STYLE_None 0x00 | 19 #define FX_FONT_STYLE_None 0x00 |
| 20 #define FX_FONT_STYLE_Bold 0x01 | 20 #define FX_FONT_STYLE_Bold 0x01 |
| 21 #define FX_FONT_STYLE_Italic 0x02 | 21 #define FX_FONT_STYLE_Italic 0x02 |
| 22 #define FX_FONT_STYLE_BoldBold 0x04 | 22 #define FX_FONT_STYLE_BoldBold 0x04 |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 if (tables.IsEmpty()) { | 1419 if (tables.IsEmpty()) { |
| 1420 return; | 1420 return; |
| 1421 } | 1421 } |
| 1422 CFX_ByteString names = | 1422 CFX_ByteString names = |
| 1423 FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); | 1423 FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); |
| 1424 CFX_ByteString facename = GetNameFromTT(names, 1); | 1424 CFX_ByteString facename = GetNameFromTT(names, 1); |
| 1425 CFX_ByteString style = GetNameFromTT(names, 2); | 1425 CFX_ByteString style = GetNameFromTT(names, 2); |
| 1426 if (style != "Regular") { | 1426 if (style != "Regular") { |
| 1427 facename += " " + style; | 1427 facename += " " + style; |
| 1428 } | 1428 } |
| 1429 if (m_FontList.find(facename) != m_FontList.end()) { | 1429 if (pdfium::ContainsKey(m_FontList, facename)) |
| 1430 return; | 1430 return; |
| 1431 } | 1431 |
| 1432 CFX_FontFaceInfo* pInfo = | 1432 CFX_FontFaceInfo* pInfo = |
| 1433 new CFX_FontFaceInfo(path, facename, tables, offset, filesize); | 1433 new CFX_FontFaceInfo(path, facename, tables, offset, filesize); |
| 1434 CFX_ByteString os2 = FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); | 1434 CFX_ByteString os2 = FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); |
| 1435 if (os2.GetLength() >= 86) { | 1435 if (os2.GetLength() >= 86) { |
| 1436 const uint8_t* p = (const uint8_t*)os2 + 78; | 1436 const uint8_t* p = (const uint8_t*)os2 + 78; |
| 1437 FX_DWORD codepages = GET_TT_LONG(p); | 1437 FX_DWORD codepages = GET_TT_LONG(p); |
| 1438 if (codepages & (1 << 17)) { | 1438 if (codepages & (1 << 17)) { |
| 1439 m_pMapper->AddInstalledFont(facename, FXFONT_SHIFTJIS_CHARSET); | 1439 m_pMapper->AddInstalledFont(facename, FXFONT_SHIFTJIS_CHARSET); |
| 1440 pInfo->m_Charsets |= CHARSET_FLAG_SHIFTJIS; | 1440 pInfo->m_Charsets |= CHARSET_FLAG_SHIFTJIS; |
| 1441 } | 1441 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 int PDF_GetStandardFontName(CFX_ByteString* name) { | 1593 int PDF_GetStandardFontName(CFX_ByteString* name) { |
| 1594 AltFontName* found = static_cast<AltFontName*>( | 1594 AltFontName* found = static_cast<AltFontName*>( |
| 1595 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), | 1595 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), |
| 1596 sizeof(AltFontName), CompareString)); | 1596 sizeof(AltFontName), CompareString)); |
| 1597 if (!found) | 1597 if (!found) |
| 1598 return -1; | 1598 return -1; |
| 1599 | 1599 |
| 1600 *name = g_Base14FontNames[found->m_Index]; | 1600 *name = g_Base14FontNames[found->m_Index]; |
| 1601 return found->m_Index; | 1601 return found->m_Index; |
| 1602 } | 1602 } |
| OLD | NEW |