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

Side by Side Diff: xfa/fgas/font/fgas_gefont.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 | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fgas/font/fgas_stdfontmgr.h » ('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 "xfa/fgas/font/fgas_gefont.h" 7 #include "xfa/fgas/font/fgas_gefont.h"
8 8
9 #include "xfa/fgas/crt/fgas_codepage.h" 9 #include "xfa/fgas/crt/fgas_codepage.h"
10 #include "xfa/fgas/font/fgas_fontutils.h" 10 #include "xfa/fgas/font/fgas_fontutils.h"
11 11
12 IFX_Font* IFX_Font::LoadFont(const FX_WCHAR* pszFontFamily, 12 IFX_Font* IFX_Font::LoadFont(const FX_WCHAR* pszFontFamily,
13 FX_DWORD dwFontStyles, 13 FX_DWORD dwFontStyles,
14 FX_WORD wCodePage, 14 uint16_t wCodePage,
15 IFX_FontMgr* pFontMgr) { 15 IFX_FontMgr* pFontMgr) {
16 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 16 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
17 if (NULL != pFontMgr) { 17 if (NULL != pFontMgr) {
18 return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); 18 return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
19 } 19 }
20 return NULL; 20 return NULL;
21 #else 21 #else
22 CFX_GEFont* pFont = new CFX_GEFont(pFontMgr); 22 CFX_GEFont* pFont = new CFX_GEFont(pFontMgr);
23 if (!pFont->LoadFont(pszFontFamily, dwFontStyles, wCodePage)) { 23 if (!pFont->LoadFont(pszFontFamily, dwFontStyles, wCodePage)) {
24 pFont->Release(); 24 pFont->Release();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 delete this; 183 delete this;
184 } 184 }
185 } 185 }
186 IFX_Font* CFX_GEFont::Retain() { 186 IFX_Font* CFX_GEFont::Retain() {
187 ++m_iRefCount; 187 ++m_iRefCount;
188 return this; 188 return this;
189 } 189 }
190 FX_BOOL CFX_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, 190 FX_BOOL CFX_GEFont::LoadFont(const FX_WCHAR* pszFontFamily,
191 FX_DWORD dwFontStyles, 191 FX_DWORD dwFontStyles,
192 FX_WORD wCodePage) { 192 uint16_t wCodePage) {
193 if (m_pFont) { 193 if (m_pFont) {
194 return FALSE; 194 return FALSE;
195 } 195 }
196 CFX_ByteString csFontFamily; 196 CFX_ByteString csFontFamily;
197 if (pszFontFamily != NULL) { 197 if (pszFontFamily != NULL) {
198 csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); 198 csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily);
199 } 199 }
200 FX_DWORD dwFlags = 0; 200 FX_DWORD dwFlags = 0;
201 if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { 201 if (dwFontStyles & FX_FONTSTYLE_FixedPitch) {
202 dwFlags |= FXFONT_FIXED_PITCH; 202 dwFlags |= FXFONT_FIXED_PITCH;
(...skipping 11 matching lines...) Expand all
214 dwFlags |= FXFONT_ITALIC; 214 dwFlags |= FXFONT_ITALIC;
215 } 215 }
216 if (dwFontStyles & FX_FONTSTYLE_Bold) { 216 if (dwFontStyles & FX_FONTSTYLE_Bold) {
217 dwFlags |= FXFONT_BOLD; 217 dwFlags |= FXFONT_BOLD;
218 } 218 }
219 if (dwFontStyles & FX_FONTSTYLE_ExactMatch) { 219 if (dwFontStyles & FX_FONTSTYLE_ExactMatch) {
220 dwFlags |= FXFONT_EXACTMATCH; 220 dwFlags |= FXFONT_EXACTMATCH;
221 } 221 }
222 int32_t iWeight = 222 int32_t iWeight =
223 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; 223 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
224 FX_WORD wCharSet = FX_GetCharsetFromCodePage(wCodePage); 224 uint16_t wCharSet = FX_GetCharsetFromCodePage(wCodePage);
225 if (wCharSet == 0xFFFF) { 225 if (wCharSet == 0xFFFF) {
226 wCharSet = FXSYS_GetACP(); 226 wCharSet = FXSYS_GetACP();
227 } 227 }
228 m_wCharSet = wCharSet; 228 m_wCharSet = wCharSet;
229 m_pFont = new CFX_Font; 229 m_pFont = new CFX_Font;
230 if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) { 230 if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) {
231 csFontFamily += ",BoldItalic"; 231 csFontFamily += ",BoldItalic";
232 } else if (dwFlags & FXFONT_BOLD) { 232 } else if (dwFlags & FXFONT_BOLD) {
233 csFontFamily += ",Bold"; 233 csFontFamily += ",Bold";
234 } else if (dwFlags & FXFONT_ITALIC) { 234 } else if (dwFlags & FXFONT_ITALIC) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 m_pCharWidthMap = new CFX_WordDiscreteArray(1024); 322 m_pCharWidthMap = new CFX_WordDiscreteArray(1024);
323 } 323 }
324 if (!m_pRectArray) { 324 if (!m_pRectArray) {
325 m_pRectArray = new CFX_RectMassArray(16); 325 m_pRectArray = new CFX_RectMassArray(16);
326 } 326 }
327 if (!m_pBBoxMap) { 327 if (!m_pBBoxMap) {
328 m_pBBoxMap = new CFX_MapPtrToPtr(16); 328 m_pBBoxMap = new CFX_MapPtrToPtr(16);
329 } 329 }
330 return TRUE; 330 return TRUE;
331 } 331 }
332 IFX_Font* CFX_GEFont::Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage) { 332 IFX_Font* CFX_GEFont::Derive(FX_DWORD dwFontStyles, uint16_t wCodePage) {
333 if (GetFontStyles() == dwFontStyles) { 333 if (GetFontStyles() == dwFontStyles) {
334 return Retain(); 334 return Retain();
335 } 335 }
336 return new CFX_GEFont(*this, dwFontStyles); 336 return new CFX_GEFont(*this, dwFontStyles);
337 } 337 }
338 uint8_t CFX_GEFont::GetCharSet() const { 338 uint8_t CFX_GEFont::GetCharSet() const {
339 if (m_wCharSet != 0xFFFF) { 339 if (m_wCharSet != 0xFFFF) {
340 return (uint8_t)m_wCharSet; 340 return (uint8_t)m_wCharSet;
341 } 341 }
342 if (!m_pFont->GetSubstFont()) { 342 if (!m_pFont->GetSubstFont()) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 if (iGlyphIndex > 0) { 482 if (iGlyphIndex > 0) {
483 if (ppFont != NULL) { 483 if (ppFont != NULL) {
484 *ppFont = (IFX_Font*)this; 484 *ppFont = (IFX_Font*)this;
485 } 485 }
486 return iGlyphIndex; 486 return iGlyphIndex;
487 } 487 }
488 const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); 488 const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode);
489 if (pFontUSB == NULL) { 489 if (pFontUSB == NULL) {
490 return 0xFFFF; 490 return 0xFFFF;
491 } 491 }
492 FX_WORD wBitField = pFontUSB->wBitField; 492 uint16_t wBitField = pFontUSB->wBitField;
493 if (wBitField >= 128) { 493 if (wBitField >= 128) {
494 return 0xFFFF; 494 return 0xFFFF;
495 } 495 }
496 IFX_Font* pFont = NULL; 496 IFX_Font* pFont = NULL;
497 m_FontMapper.Lookup((void*)(uintptr_t)wUnicode, (void*&)pFont); 497 m_FontMapper.Lookup((void*)(uintptr_t)wUnicode, (void*&)pFont);
498 if (pFont != NULL && pFont != (IFX_Font*)this) { 498 if (pFont != NULL && pFont != (IFX_Font*)this) {
499 iGlyphIndex = 499 iGlyphIndex =
500 ((CFX_GEFont*)pFont)->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode); 500 ((CFX_GEFont*)pFont)->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode);
501 if (iGlyphIndex != 0xFFFF) { 501 if (iGlyphIndex != 0xFFFF) {
502 int32_t i = m_SubstFonts.Find(pFont); 502 int32_t i = m_SubstFonts.Find(pFont);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 } 563 }
564 if (m_pRectArray != NULL) { 564 if (m_pRectArray != NULL) {
565 m_pRectArray->RemoveAll(); 565 m_pRectArray->RemoveAll();
566 } 566 }
567 } 567 }
568 IFX_Font* CFX_GEFont::GetSubstFont(int32_t iGlyphIndex) const { 568 IFX_Font* CFX_GEFont::GetSubstFont(int32_t iGlyphIndex) const {
569 iGlyphIndex = ((FX_DWORD)iGlyphIndex) >> 24; 569 iGlyphIndex = ((FX_DWORD)iGlyphIndex) >> 24;
570 return iGlyphIndex == 0 ? (IFX_Font*)this 570 return iGlyphIndex == 0 ? (IFX_Font*)this
571 : (IFX_Font*)m_SubstFonts[iGlyphIndex - 1]; 571 : (IFX_Font*)m_SubstFonts[iGlyphIndex - 1];
572 } 572 }
OLDNEW
« no previous file with comments | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fgas/font/fgas_stdfontmgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698