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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "core/fxge/fontdata/chromefontdata/chromefontdata.h" | 11 #include "core/fxge/fontdata/chromefontdata/chromefontdata.h" |
12 #include "core/fxge/ge/fx_text_int.h" | 12 #include "core/fxge/ge/fx_text_int.h" |
13 #include "core/include/fxge/fx_freetype.h" | 13 #include "core/include/fxge/fx_freetype.h" |
14 #include "core/include/fxge/fx_ge.h" | 14 #include "core/include/fxge/fx_ge.h" |
15 #include "third_party/base/stl_util.h" | 15 #include "third_party/base/stl_util.h" |
16 | 16 |
17 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) | 17 #define GET_TT_SHORT(w) (uint16_t)(((w)[0] << 8) | (w)[1]) |
18 #define GET_TT_LONG(w) \ | 18 #define GET_TT_LONG(w) \ |
19 (FX_DWORD)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3]) | 19 (FX_DWORD)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3]) |
20 | 20 |
21 #define FX_FONT_STYLE_None 0x00 | 21 #define FX_FONT_STYLE_None 0x00 |
22 #define FX_FONT_STYLE_Bold 0x01 | 22 #define FX_FONT_STYLE_Bold 0x01 |
23 #define FX_FONT_STYLE_Italic 0x02 | 23 #define FX_FONT_STYLE_Italic 0x02 |
24 #define FX_FONT_STYLE_BoldBold 0x04 | 24 #define FX_FONT_STYLE_BoldBold 0x04 |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 }; | 192 }; |
193 | 193 |
194 const struct FX_FontStyle { | 194 const struct FX_FontStyle { |
195 const FX_CHAR* style; | 195 const FX_CHAR* style; |
196 int32_t len; | 196 int32_t len; |
197 } g_FontStyles[] = { | 197 } g_FontStyles[] = { |
198 {"Bold", 4}, {"Italic", 6}, {"BoldItalic", 10}, {"Reg", 3}, {"Regular", 7}, | 198 {"Bold", 4}, {"Italic", 6}, {"BoldItalic", 10}, {"Reg", 3}, {"Regular", 7}, |
199 }; | 199 }; |
200 | 200 |
201 const struct CODEPAGE_MAP { | 201 const struct CODEPAGE_MAP { |
202 FX_WORD codepage; | 202 uint16_t codepage; |
203 uint8_t charset; | 203 uint8_t charset; |
204 } g_Codepage2CharsetTable[] = { | 204 } g_Codepage2CharsetTable[] = { |
205 {0, 1}, {42, 2}, {437, 254}, {850, 255}, {874, 222}, | 205 {0, 1}, {42, 2}, {437, 254}, {850, 255}, {874, 222}, |
206 {932, 128}, {936, 134}, {949, 129}, {950, 136}, {1250, 238}, | 206 {932, 128}, {936, 134}, {949, 129}, {950, 136}, {1250, 238}, |
207 {1251, 204}, {1252, 0}, {1253, 161}, {1254, 162}, {1255, 177}, | 207 {1251, 204}, {1252, 0}, {1253, 161}, {1254, 162}, {1255, 177}, |
208 {1256, 178}, {1257, 186}, {1258, 163}, {1361, 130}, {10000, 77}, | 208 {1256, 178}, {1257, 186}, {1258, 163}, {1361, 130}, {10000, 77}, |
209 {10001, 78}, {10002, 81}, {10003, 79}, {10004, 84}, {10005, 83}, | 209 {10001, 78}, {10002, 81}, {10003, 79}, {10004, 84}, {10005, 83}, |
210 {10006, 85}, {10007, 89}, {10008, 80}, {10021, 87}, {10029, 88}, | 210 {10006, 85}, {10007, 89}, {10008, 80}, {10021, 87}, {10029, 88}, |
211 {10081, 86}, | 211 {10081, 86}, |
212 }; | 212 }; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 if (GET_TT_LONG(p) == tag) { | 274 if (GET_TT_LONG(p) == tag) { |
275 FX_DWORD offset = GET_TT_LONG(p + 8); | 275 FX_DWORD offset = GET_TT_LONG(p + 8); |
276 FX_DWORD size = GET_TT_LONG(p + 12); | 276 FX_DWORD size = GET_TT_LONG(p + 12); |
277 FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET); | 277 FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET); |
278 return FPDF_ReadStringFromFile(pFile, size); | 278 return FPDF_ReadStringFromFile(pFile, size); |
279 } | 279 } |
280 } | 280 } |
281 return CFX_ByteString(); | 281 return CFX_ByteString(); |
282 } | 282 } |
283 | 283 |
284 uint8_t GetCharsetFromCodePage(FX_WORD codepage) { | 284 uint8_t GetCharsetFromCodePage(uint16_t codepage) { |
285 const CODEPAGE_MAP* pEnd = | 285 const CODEPAGE_MAP* pEnd = |
286 g_Codepage2CharsetTable + FX_ArraySize(g_Codepage2CharsetTable); | 286 g_Codepage2CharsetTable + FX_ArraySize(g_Codepage2CharsetTable); |
287 const CODEPAGE_MAP* pCharmap = | 287 const CODEPAGE_MAP* pCharmap = |
288 std::lower_bound(g_Codepage2CharsetTable, pEnd, codepage, | 288 std::lower_bound(g_Codepage2CharsetTable, pEnd, codepage, |
289 [](const CODEPAGE_MAP& charset, FX_WORD page) { | 289 [](const CODEPAGE_MAP& charset, uint16_t page) { |
290 return charset.codepage < page; | 290 return charset.codepage < page; |
291 }); | 291 }); |
292 if (pCharmap < pEnd && codepage == pCharmap->codepage) | 292 if (pCharmap < pEnd && codepage == pCharmap->codepage) |
293 return pCharmap->charset; | 293 return pCharmap->charset; |
294 return 1; | 294 return 1; |
295 } | 295 } |
296 | 296 |
297 CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) { | 297 CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) { |
298 if (fontName.Find("Script") >= 0) { | 298 if (fontName.Find("Script") >= 0) { |
299 if ((nStyle & FX_FONT_STYLE_Bold) == FX_FONT_STYLE_Bold) { | 299 if ((nStyle & FX_FONT_STYLE_Bold) == FX_FONT_STYLE_Bold) { |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 int PDF_GetStandardFontName(CFX_ByteString* name) { | 1614 int PDF_GetStandardFontName(CFX_ByteString* name) { |
1615 AltFontName* found = static_cast<AltFontName*>( | 1615 AltFontName* found = static_cast<AltFontName*>( |
1616 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), | 1616 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), |
1617 sizeof(AltFontName), CompareString)); | 1617 sizeof(AltFontName), CompareString)); |
1618 if (!found) | 1618 if (!found) |
1619 return -1; | 1619 return -1; |
1620 | 1620 |
1621 *name = g_Base14FontNames[found->m_Index]; | 1621 *name = g_Base14FontNames[found->m_Index]; |
1622 return found->m_Index; | 1622 return found->m_Index; |
1623 } | 1623 } |
OLD | NEW |