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 "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
9 #include "../fpdf_page/pageint.h" | 9 #include "../fpdf_page/pageint.h" |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, | 171 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, |
172 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, | 172 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, |
173 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, | 173 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, |
174 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, | 174 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, |
175 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, | 175 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, |
176 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, | 176 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, |
177 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, | 177 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, |
178 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9, | 178 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9, |
179 }; | 179 }; |
180 typedef struct { | 180 typedef struct { |
181 FX_BYTE» » m_Charset; | 181 uint8_t» » m_Charset; |
182 const FX_WCHAR* m_pUnicodes; | 182 const FX_WCHAR* m_pUnicodes; |
183 } FX_CharsetUnicodes; | 183 } FX_CharsetUnicodes; |
184 const FX_CharsetUnicodes g_FX_CharsetUnicodes[] = { | 184 const FX_CharsetUnicodes g_FX_CharsetUnicodes[] = { |
185 { FXFONT_THAI_CHARSET, g_FX_CP874Unicodes }, | 185 { FXFONT_THAI_CHARSET, g_FX_CP874Unicodes }, |
186 { FXFONT_EASTEUROPE_CHARSET, g_FX_CP1250Unicodes }, | 186 { FXFONT_EASTEUROPE_CHARSET, g_FX_CP1250Unicodes }, |
187 { FXFONT_RUSSIAN_CHARSET, g_FX_CP1251Unicodes }, | 187 { FXFONT_RUSSIAN_CHARSET, g_FX_CP1251Unicodes }, |
188 { FXFONT_GREEK_CHARSET, g_FX_CP1253Unicodes }, | 188 { FXFONT_GREEK_CHARSET, g_FX_CP1253Unicodes }, |
189 { FXFONT_TURKISH_CHARSET, g_FX_CP1254Unicodes }, | 189 { FXFONT_TURKISH_CHARSET, g_FX_CP1254Unicodes }, |
190 { FXFONT_HEBREW_CHARSET, g_FX_CP1255Unicodes }, | 190 { FXFONT_HEBREW_CHARSET, g_FX_CP1255Unicodes }, |
191 { FXFONT_ARABIC_CHARSET, g_FX_CP1256Unicodes }, | 191 { FXFONT_ARABIC_CHARSET, g_FX_CP1256Unicodes }, |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 pFontDesc->SetAtInteger("StemV", pLogFont->lfWeight / 5); | 422 pFontDesc->SetAtInteger("StemV", pLogFont->lfWeight / 5); |
423 AddIndirectObject(pFontDesc); | 423 AddIndirectObject(pFontDesc); |
424 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); | 424 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); |
425 hFont = SelectObject(hDC, hFont); | 425 hFont = SelectObject(hDC, hFont); |
426 DeleteObject(hFont); | 426 DeleteObject(hFont); |
427 DeleteDC(hDC); | 427 DeleteDC(hDC); |
428 return LoadFont(pBaseDict); | 428 return LoadFont(pBaseDict); |
429 } | 429 } |
430 #endif | 430 #endif |
431 #if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_) | 431 #if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_) |
432 FX_UINT32 FX_GetLangHashCode( FX_LPCSTR pStr) | 432 uint32_t FX_GetLangHashCode( FX_LPCSTR pStr) |
433 { | 433 { |
434 FXSYS_assert( pStr != NULL); | 434 FXSYS_assert( pStr != NULL); |
435 FX_INT32 iLength = FXSYS_strlen(pStr); | 435 int32_t iLength = FXSYS_strlen(pStr); |
436 FX_LPCSTR pStrEnd = pStr + iLength; | 436 FX_LPCSTR pStrEnd = pStr + iLength; |
437 FX_UINT32 uHashCode = 0; | 437 uint32_t uHashCode = 0; |
438 while ( pStr < pStrEnd) { | 438 while ( pStr < pStrEnd) { |
439 uHashCode = 31 * uHashCode + tolower(*pStr++); | 439 uHashCode = 31 * uHashCode + tolower(*pStr++); |
440 } | 440 } |
441 return uHashCode; | 441 return uHashCode; |
442 } | 442 } |
443 struct FX_LANG2CS { | 443 struct FX_LANG2CS { |
444 FX_DWORD uLang; | 444 FX_DWORD uLang; |
445 int uCharset; | 445 int uCharset; |
446 }*FX_LPLANG2CS; | 446 }*FX_LPLANG2CS; |
447 static const FX_LANG2CS gs_FXLang2CharsetTable[] = { | 447 static const FX_LANG2CS gs_FXLang2CharsetTable[] = { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 {3734, 204}, | 505 {3734, 204}, |
506 {3741, 178}, | 506 {3741, 178}, |
507 {3749, 162}, | 507 {3749, 162}, |
508 {3763, 163}, | 508 {3763, 163}, |
509 {3886, 134}, | 509 {3886, 134}, |
510 {105943, 0}, | 510 {105943, 0}, |
511 {106375, 1}, | 511 {106375, 1}, |
512 {3923451837, 134}, | 512 {3923451837, 134}, |
513 {3923451838, 136}, | 513 {3923451838, 136}, |
514 }; | 514 }; |
515 static FX_WORD FX_GetCsFromLangCode(FX_UINT32 uCode) | 515 static FX_WORD FX_GetCsFromLangCode(uint32_t uCode) |
516 { | 516 { |
517 FX_INT32 iStart = 0; | 517 int32_t iStart = 0; |
518 FX_INT32 iEnd = sizeof(gs_FXLang2CharsetTable) / sizeof(FX_LANG2CS) - 1; | 518 int32_t iEnd = sizeof(gs_FXLang2CharsetTable) / sizeof(FX_LANG2CS) - 1; |
519 while (iStart <= iEnd) { | 519 while (iStart <= iEnd) { |
520 FX_INT32 iMid = (iStart + iEnd) / 2; | 520 int32_t iMid = (iStart + iEnd) / 2; |
521 const FX_LANG2CS &charset = gs_FXLang2CharsetTable[iMid]; | 521 const FX_LANG2CS &charset = gs_FXLang2CharsetTable[iMid]; |
522 if (uCode == charset.uLang) { | 522 if (uCode == charset.uLang) { |
523 return charset.uCharset; | 523 return charset.uCharset; |
524 } else if (uCode < charset.uLang) { | 524 } else if (uCode < charset.uLang) { |
525 iEnd = iMid - 1; | 525 iEnd = iMid - 1; |
526 } else { | 526 } else { |
527 iStart = iMid + 1; | 527 iStart = iMid + 1; |
528 } | 528 } |
529 }; | 529 }; |
530 return 0; | 530 return 0; |
531 } | 531 } |
532 static FX_WORD FX_GetCharsetFromLang(FX_LPCSTR pLang, FX_INT32 iLength) | 532 static FX_WORD FX_GetCharsetFromLang(FX_LPCSTR pLang, int32_t iLength) |
533 { | 533 { |
534 FXSYS_assert(pLang); | 534 FXSYS_assert(pLang); |
535 if (iLength < 0) { | 535 if (iLength < 0) { |
536 iLength = FXSYS_strlen(pLang); | 536 iLength = FXSYS_strlen(pLang); |
537 } | 537 } |
538 FX_UINT32 uHash = FX_GetLangHashCode(pLang); | 538 uint32_t uHash = FX_GetLangHashCode(pLang); |
539 return FX_GetCsFromLangCode(uHash); | 539 return FX_GetCsFromLangCode(uHash); |
540 } | 540 } |
541 static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString &dest) | 541 static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString &dest) |
542 { | 542 { |
543 SInt32 len = CFStringGetLength(src); | 543 SInt32 len = CFStringGetLength(src); |
544 CFRange range = CFRangeMake(0, len); | 544 CFRange range = CFRangeMake(0, len); |
545 CFIndex used = 0; | 545 CFIndex used = 0; |
546 UInt8* pBuffer = (UInt8*)calloc(len+1, sizeof(UInt8)); | 546 UInt8* pBuffer = (UInt8*)calloc(len+1, sizeof(UInt8)); |
547 CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len,
&used); | 547 CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len,
&used); |
548 dest = (FX_LPSTR)pBuffer; | 548 dest = (FX_LPSTR)pBuffer; |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 pFontDesc->SetAtInteger("Ascent", pFont->GetAscent()); | 1021 pFontDesc->SetAtInteger("Ascent", pFont->GetAscent()); |
1022 pFontDesc->SetAtInteger("Descent", pFont->GetDescent()); | 1022 pFontDesc->SetAtInteger("Descent", pFont->GetDescent()); |
1023 FX_RECT bbox; | 1023 FX_RECT bbox; |
1024 pFont->GetBBox(bbox); | 1024 pFont->GetBBox(bbox); |
1025 CPDF_Array* pBBox = new CPDF_Array; | 1025 CPDF_Array* pBBox = new CPDF_Array; |
1026 pBBox->AddInteger(bbox.left); | 1026 pBBox->AddInteger(bbox.left); |
1027 pBBox->AddInteger(bbox.bottom); | 1027 pBBox->AddInteger(bbox.bottom); |
1028 pBBox->AddInteger(bbox.right); | 1028 pBBox->AddInteger(bbox.right); |
1029 pBBox->AddInteger(bbox.top); | 1029 pBBox->AddInteger(bbox.top); |
1030 pFontDesc->SetAt("FontBBox", pBBox); | 1030 pFontDesc->SetAt("FontBBox", pBBox); |
1031 FX_INT32 nStemV = 0; | 1031 int32_t nStemV = 0; |
1032 if (pFont->m_pSubstFont) { | 1032 if (pFont->m_pSubstFont) { |
1033 nStemV = pFont->m_pSubstFont->m_Weight / 5; | 1033 nStemV = pFont->m_pSubstFont->m_Weight / 5; |
1034 } else { | 1034 } else { |
1035 static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'}; | 1035 static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'}; |
1036 const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]); | 1036 const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]); |
1037 FX_DWORD glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); | 1037 FX_DWORD glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); |
1038 nStemV = pFont->GetGlyphWidth(glyph); | 1038 nStemV = pFont->GetGlyphWidth(glyph); |
1039 for (size_t i = 1; i < count; i++) { | 1039 for (size_t i = 1; i < count; i++) { |
1040 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]); | 1040 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]); |
1041 int width = pFont->GetGlyphWidth(glyph); | 1041 int width = pFont->GetGlyphWidth(glyph); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, FX_BSTR name) | 1174 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, FX_BSTR name) |
1175 { | 1175 { |
1176 if (pPageDict->KeyExist(name)) { | 1176 if (pPageDict->KeyExist(name)) { |
1177 return; | 1177 return; |
1178 } | 1178 } |
1179 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); | 1179 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); |
1180 if (pObj) { | 1180 if (pObj) { |
1181 pPageDict->SetAt(name, pObj->Clone()); | 1181 pPageDict->SetAt(name, pObj->Clone()); |
1182 } | 1182 } |
1183 } | 1183 } |
OLD | NEW |