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

Side by Side Diff: fpdfsdk/pdfwindow/PWL_FontMap.cpp

Issue 1821043003: Remove FX_WORD in favor of uint16_t. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use stdint.h directly, bitfield minefield. Created 4 years, 9 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 | « fpdfsdk/pdfwindow/PWL_EditCtrl.cpp ('k') | fpdfsdk/pdfwindow/PWL_IconList.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 "fpdfsdk/include/pdfwindow/PWL_FontMap.h" 7 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
10 #include "core/fpdfapi/include/cpdf_modulemgr.h" 10 #include "core/fpdfapi/include/cpdf_modulemgr.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex) { 72 CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
73 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) { 73 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
74 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) { 74 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
75 return pData->sFontName; 75 return pData->sFontName;
76 } 76 }
77 } 77 }
78 78
79 return ""; 79 return "";
80 } 80 }
81 81
82 FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word) { 82 FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, uint16_t word) {
83 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) { 83 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
84 if (m_aData.GetAt(nFontIndex)) { 84 if (m_aData.GetAt(nFontIndex)) {
85 return CharCodeFromUnicode(nFontIndex, word) >= 0; 85 return CharCodeFromUnicode(nFontIndex, word) >= 0;
86 } 86 }
87 } 87 }
88 88
89 return FALSE; 89 return FALSE;
90 } 90 }
91 91
92 int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word, 92 int32_t CPWL_FontMap::GetWordFontIndex(uint16_t word,
93 int32_t nCharset, 93 int32_t nCharset,
94 int32_t nFontIndex) { 94 int32_t nFontIndex) {
95 if (nFontIndex > 0) { 95 if (nFontIndex > 0) {
96 if (KnowWord(nFontIndex, word)) 96 if (KnowWord(nFontIndex, word))
97 return nFontIndex; 97 return nFontIndex;
98 } else { 98 } else {
99 if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) { 99 if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) {
100 if (nCharset == DEFAULT_CHARSET || pData->nCharset == SYMBOL_CHARSET || 100 if (nCharset == DEFAULT_CHARSET || pData->nCharset == SYMBOL_CHARSET ||
101 nCharset == pData->nCharset) { 101 nCharset == pData->nCharset) {
102 if (KnowWord(0, word)) 102 if (KnowWord(0, word))
103 return 0; 103 return 0;
104 } 104 }
105 } 105 }
106 } 106 }
107 107
108 int32_t nNewFontIndex = 108 int32_t nNewFontIndex =
109 GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE); 109 GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE);
110 if (nNewFontIndex >= 0) { 110 if (nNewFontIndex >= 0) {
111 if (KnowWord(nNewFontIndex, word)) 111 if (KnowWord(nNewFontIndex, word))
112 return nNewFontIndex; 112 return nNewFontIndex;
113 } 113 }
114 nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE); 114 nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE);
115 if (nNewFontIndex >= 0) { 115 if (nNewFontIndex >= 0) {
116 if (KnowWord(nNewFontIndex, word)) 116 if (KnowWord(nNewFontIndex, word))
117 return nNewFontIndex; 117 return nNewFontIndex;
118 } 118 }
119 return -1; 119 return -1;
120 } 120 }
121 121
122 int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word) { 122 int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) {
123 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) { 123 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
124 if (pData->pFont) { 124 if (pData->pFont) {
125 if (pData->pFont->IsUnicodeCompatible()) { 125 if (pData->pFont->IsUnicodeCompatible()) {
126 int nCharCode = pData->pFont->CharCodeFromUnicode(word); 126 int nCharCode = pData->pFont->CharCodeFromUnicode(word);
127 pData->pFont->GlyphFromCharCode(nCharCode); 127 pData->pFont->GlyphFromCharCode(nCharCode);
128 return nCharCode; 128 return nCharCode;
129 } 129 }
130 if (word < 0xFF) 130 if (word < 0xFF)
131 return word; 131 return word;
132 } 132 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 if (!pFont) { 213 if (!pFont) {
214 CFX_ByteString sTemp = sFontName; 214 CFX_ByteString sTemp = sFontName;
215 pFont = AddFontToDocument(GetDocument(), sTemp, nCharset); 215 pFont = AddFontToDocument(GetDocument(), sTemp, nCharset);
216 sAlias = EncodeFontAlias(sTemp, nCharset); 216 sAlias = EncodeFontAlias(sTemp, nCharset);
217 } 217 }
218 AddedFont(pFont, sAlias); 218 AddedFont(pFont, sAlias);
219 return AddFontData(pFont, sAlias, nCharset); 219 return AddFontData(pFont, sAlias, nCharset);
220 } 220 }
221 221
222 int32_t CPWL_FontMap::GetPWLFontIndex(FX_WORD word, int32_t nCharset) { 222 int32_t CPWL_FontMap::GetPWLFontIndex(uint16_t word, int32_t nCharset) {
223 int32_t nFind = -1; 223 int32_t nFind = -1;
224 224
225 for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++) { 225 for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++) {
226 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) { 226 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) {
227 if (pData->nCharset == nCharset) { 227 if (pData->nCharset == nCharset) {
228 nFind = i; 228 nFind = i;
229 break; 229 break;
230 } 230 }
231 } 231 }
232 } 232 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset) { 427 CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset) {
428 int i = 0; 428 int i = 0;
429 while (defaultTTFMap[i].charset != -1) { 429 while (defaultTTFMap[i].charset != -1) {
430 if (nCharset == defaultTTFMap[i].charset) 430 if (nCharset == defaultTTFMap[i].charset)
431 return defaultTTFMap[i].fontname; 431 return defaultTTFMap[i].fontname;
432 ++i; 432 ++i;
433 } 433 }
434 return ""; 434 return "";
435 } 435 }
436 436
437 int32_t CPWL_FontMap::CharSetFromUnicode(FX_WORD word, int32_t nOldCharset) { 437 int32_t CPWL_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) {
438 if (m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet())) 438 if (m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet()))
439 return m_pSystemHandler->GetCharSet(); 439 return m_pSystemHandler->GetCharSet();
440 // to avoid CJK Font to show ASCII 440 // to avoid CJK Font to show ASCII
441 if (word < 0x7F) 441 if (word < 0x7F)
442 return ANSI_CHARSET; 442 return ANSI_CHARSET;
443 // follow the old charset 443 // follow the old charset
444 if (nOldCharset != DEFAULT_CHARSET) 444 if (nOldCharset != DEFAULT_CHARSET)
445 return nOldCharset; 445 return nOldCharset;
446 446
447 // find new charset 447 // find new charset
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 491
492 CPWL_DocFontMap::CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler, 492 CPWL_DocFontMap::CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler,
493 CPDF_Document* pAttachedDoc) 493 CPDF_Document* pAttachedDoc)
494 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} 494 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {}
495 495
496 CPWL_DocFontMap::~CPWL_DocFontMap() {} 496 CPWL_DocFontMap::~CPWL_DocFontMap() {}
497 497
498 CPDF_Document* CPWL_DocFontMap::GetDocument() { 498 CPDF_Document* CPWL_DocFontMap::GetDocument() {
499 return m_pAttachedDoc; 499 return m_pAttachedDoc;
500 } 500 }
OLDNEW
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_EditCtrl.cpp ('k') | fpdfsdk/pdfwindow/PWL_IconList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698