Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 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_stdfontmgr.h" | 7 #include "xfa/fgas/font/fgas_stdfontmgr.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_stream.h" | 9 #include "core/fxcrt/include/fx_stream.h" |
| 10 #include "core/fxge/include/fx_ge.h" | 10 #include "core/fxge/include/fx_ge.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) | 21 CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) |
| 22 : m_pEnumerator(pEnumerator), | 22 : m_pEnumerator(pEnumerator), |
| 23 m_FontFaces(), | 23 m_FontFaces(), |
| 24 m_CPFonts(8), | 24 m_CPFonts(8), |
| 25 m_FamilyFonts(16), | 25 m_FamilyFonts(16), |
| 26 m_UnicodeFonts(16), | 26 m_UnicodeFonts(16), |
| 27 m_BufferFonts(4), | 27 m_BufferFonts(4), |
| 28 m_StreamFonts(4), | 28 m_StreamFonts(4), |
| 29 m_DeriveFonts(4) { | 29 m_DeriveFonts(4) { |
| 30 if (m_pEnumerator) { | 30 if (m_pEnumerator) { |
| 31 m_pEnumerator(m_FontFaces, NULL, 0xFEFF); | 31 m_pEnumerator(m_FontFaces, nullptr, 0xFEFF); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { | 35 CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { |
| 36 m_FontFaces.RemoveAll(); | 36 m_FontFaces.RemoveAll(); |
| 37 m_CPFonts.RemoveAll(); | 37 m_CPFonts.RemoveAll(); |
| 38 m_FamilyFonts.RemoveAll(); | 38 m_FamilyFonts.RemoveAll(); |
| 39 m_UnicodeFonts.RemoveAll(); | 39 m_UnicodeFonts.RemoveAll(); |
| 40 m_BufferFonts.RemoveAll(); | 40 m_BufferFonts.RemoveAll(); |
| 41 m_StreamFonts.RemoveAll(); | 41 m_StreamFonts.RemoveAll(); |
| 42 m_DeriveFonts.RemoveAll(); | 42 m_DeriveFonts.RemoveAll(); |
| 43 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) | 43 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) |
| 44 m_Fonts[i]->Release(); | 44 m_Fonts[i]->Release(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void CFGAS_StdFontMgrImp::Release() { | 47 void CFGAS_StdFontMgrImp::Release() { |
| 48 delete this; | 48 delete this; |
| 49 } | 49 } |
| 50 | 50 |
| 51 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage( | 51 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage( |
| 52 uint16_t wCodePage, | 52 uint16_t wCodePage, |
| 53 uint32_t dwFontStyles, | 53 uint32_t dwFontStyles, |
| 54 const FX_WCHAR* pszFontFamily) { | 54 const FX_WCHAR* pszFontFamily) { |
| 55 uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); | 55 uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); |
| 56 CFGAS_GEFont* pFont = NULL; | 56 CFGAS_GEFont* pFont = nullptr; |
| 57 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 57 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
| 58 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; | 58 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; |
| 59 } | 59 } |
| 60 FX_FONTDESCRIPTOR const* pFD; | 60 FX_FONTDESCRIPTOR const* pFD; |
| 61 if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { | 61 |
| 62 if ((pFD = FindFont(NULL, dwFontStyles, TRUE, wCodePage)) == NULL) { | 62 pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage); |
|
Lei Zhang
2016/06/23 17:56:00
Do you want to do what I did in https://codereview
dsinclair
2016/06/23 18:46:52
Done.
| |
| 63 if ((pFD = FindFont(NULL, dwFontStyles, FALSE, wCodePage)) == NULL) | 63 if (!pFD) { |
| 64 return NULL; | 64 pFD = FindFont(nullptr, dwFontStyles, TRUE, wCodePage); |
| 65 if (!pFd) { | |
| 66 pFD = FindFont(nullptr, dwFontStyles, FALSE, wCodePage); | |
| 67 if (!pFD) | |
| 68 return nullptr; | |
| 65 } | 69 } |
| 66 } | 70 } |
| 67 ASSERT(pFD); | 71 ASSERT(pFD); |
| 68 pFont = | 72 pFont = |
| 69 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 73 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
| 70 if (pFont) { | 74 if (pFont) { |
| 71 m_Fonts.Add(pFont); | 75 m_Fonts.Add(pFont); |
| 72 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 76 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 73 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); | 77 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); |
| 74 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 78 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 75 return LoadFont(pFont, dwFontStyles, wCodePage); | 79 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 76 } | 80 } |
| 77 return NULL; | 81 return nullptr; |
| 78 } | 82 } |
| 79 | 83 |
| 80 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCharset( | 84 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCharset( |
| 81 uint8_t nCharset, | 85 uint8_t nCharset, |
| 82 uint32_t dwFontStyles, | 86 uint32_t dwFontStyles, |
| 83 const FX_WCHAR* pszFontFamily) { | 87 const FX_WCHAR* pszFontFamily) { |
| 84 return GetDefFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, | 88 return GetDefFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, |
| 85 pszFontFamily); | 89 pszFontFamily); |
| 86 } | 90 } |
| 87 | 91 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 const FX_WCHAR* pszFontFamily) { | 134 const FX_WCHAR* pszFontFamily) { |
| 131 return GetDefFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), | 135 return GetDefFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), |
| 132 dwFontStyles, pszFontFamily); | 136 dwFontStyles, pszFontFamily); |
| 133 } | 137 } |
| 134 | 138 |
| 135 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, | 139 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, |
| 136 uint32_t dwFontStyles, | 140 uint32_t dwFontStyles, |
| 137 uint16_t wCodePage) { | 141 uint16_t wCodePage) { |
| 138 uint32_t dwHash = | 142 uint32_t dwHash = |
| 139 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); | 143 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); |
| 140 CFGAS_GEFont* pFont = NULL; | 144 CFGAS_GEFont* pFont = nullptr; |
| 141 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 145 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
| 142 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; | 146 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; |
| 143 } | 147 } |
| 144 FX_FONTDESCRIPTOR const* pFD = NULL; | 148 FX_FONTDESCRIPTOR const* pFD = nullptr; |
| 145 if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { | 149 pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage); |
| 146 if ((pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage)) == | 150 if (!pFD) { |
|
Lei Zhang
2016/06/23 17:56:00
Ditto
dsinclair
2016/06/23 18:46:52
Done.
| |
| 147 NULL) { | 151 pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage); |
| 148 return NULL; | 152 if (!pFD) |
| 149 } | 153 return nullptr; |
| 150 } | 154 } |
| 151 ASSERT(pFD); | 155 ASSERT(pFD); |
| 152 if (wCodePage == 0xFFFF) { | 156 if (wCodePage == 0xFFFF) { |
| 153 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); | 157 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); |
| 154 } | 158 } |
| 155 pFont = | 159 pFont = |
| 156 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 160 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
| 157 if (pFont) { | 161 if (pFont) { |
| 158 m_Fonts.Add(pFont); | 162 m_Fonts.Add(pFont); |
| 159 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 163 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 160 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); | 164 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); |
| 161 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 165 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 162 return LoadFont(pFont, dwFontStyles, wCodePage); | 166 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 163 } | 167 } |
| 164 return NULL; | 168 return nullptr; |
| 165 } | 169 } |
| 166 | 170 |
| 167 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, | 171 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, |
| 168 int32_t iLength) { | 172 int32_t iLength) { |
| 169 ASSERT(pBuffer && iLength > 0); | 173 ASSERT(pBuffer && iLength > 0); |
| 170 CFGAS_GEFont* pFont = NULL; | 174 CFGAS_GEFont* pFont = nullptr; |
| 171 if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { | 175 if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { |
| 172 if (pFont) { | 176 if (pFont) { |
| 173 return pFont->Retain(); | 177 return pFont->Retain(); |
| 174 } | 178 } |
| 175 } | 179 } |
| 176 pFont = CFGAS_GEFont::LoadFont(pBuffer, iLength, this); | 180 pFont = CFGAS_GEFont::LoadFont(pBuffer, iLength, this); |
| 177 if (pFont) { | 181 if (pFont) { |
| 178 m_Fonts.Add(pFont); | 182 m_Fonts.Add(pFont); |
| 179 m_BufferFonts.SetAt((void*)pBuffer, pFont); | 183 m_BufferFonts.SetAt((void*)pBuffer, pFont); |
| 180 return pFont->Retain(); | 184 return pFont->Retain(); |
| 181 } | 185 } |
| 182 return NULL; | 186 return nullptr; |
| 183 } | 187 } |
| 184 | 188 |
| 185 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, | 189 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, |
| 186 const FX_WCHAR* pszFontAlias, | 190 const FX_WCHAR* pszFontAlias, |
| 187 uint32_t dwFontStyles, | 191 uint32_t dwFontStyles, |
| 188 uint16_t wCodePage, | 192 uint16_t wCodePage, |
| 189 FX_BOOL bSaveStream) { | 193 FX_BOOL bSaveStream) { |
| 190 ASSERT(pFontStream && pFontStream->GetLength() > 0); | 194 ASSERT(pFontStream && pFontStream->GetLength() > 0); |
| 191 CFGAS_GEFont* pFont = NULL; | 195 CFGAS_GEFont* pFont = nullptr; |
| 192 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { | 196 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { |
| 193 if (pFont) { | 197 if (pFont) { |
| 194 if (pszFontAlias) { | 198 if (pszFontAlias) { |
| 195 uint32_t dwHash = | 199 uint32_t dwHash = |
| 196 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); | 200 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); |
| 197 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 201 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 198 } | 202 } |
| 199 return LoadFont(pFont, dwFontStyles, wCodePage); | 203 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 200 } | 204 } |
| 201 } | 205 } |
| 202 pFont = CFGAS_GEFont::LoadFont(pFontStream, this, bSaveStream); | 206 pFont = CFGAS_GEFont::LoadFont(pFontStream, this, bSaveStream); |
| 203 if (pFont) { | 207 if (pFont) { |
| 204 m_Fonts.Add(pFont); | 208 m_Fonts.Add(pFont); |
| 205 m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); | 209 m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); |
| 206 if (pszFontAlias) { | 210 if (pszFontAlias) { |
| 207 uint32_t dwHash = | 211 uint32_t dwHash = |
| 208 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); | 212 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); |
| 209 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 213 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 210 } | 214 } |
| 211 return LoadFont(pFont, dwFontStyles, wCodePage); | 215 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 212 } | 216 } |
| 213 return NULL; | 217 return nullptr; |
| 214 } | 218 } |
| 215 | 219 |
| 216 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont, | 220 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont, |
| 217 uint32_t dwFontStyles, | 221 uint32_t dwFontStyles, |
| 218 uint16_t wCodePage) { | 222 uint16_t wCodePage) { |
| 219 ASSERT(pSrcFont); | 223 ASSERT(pSrcFont); |
| 220 if (pSrcFont->GetFontStyles() == dwFontStyles) { | 224 if (pSrcFont->GetFontStyles() == dwFontStyles) { |
| 221 return pSrcFont->Retain(); | 225 return pSrcFont->Retain(); |
| 222 } | 226 } |
| 223 void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, | 227 void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, |
| 224 (void*)(uintptr_t)wCodePage}; | 228 (void*)(uintptr_t)wCodePage}; |
| 225 uint32_t dwHash = FX_HashCode_GetA( | 229 uint32_t dwHash = FX_HashCode_GetA( |
| 226 CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false); | 230 CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false); |
| 227 CFGAS_GEFont* pFont = NULL; | 231 CFGAS_GEFont* pFont = nullptr; |
| 228 if (m_DeriveFonts.GetCount() > 0) { | 232 if (m_DeriveFonts.GetCount() > 0) { |
| 229 m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); | 233 m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); |
| 230 if (pFont) { | 234 if (pFont) { |
| 231 return pFont->Retain(); | 235 return pFont->Retain(); |
| 232 } | 236 } |
| 233 } | 237 } |
| 234 pFont = pSrcFont->Derive(dwFontStyles, wCodePage); | 238 pFont = pSrcFont->Derive(dwFontStyles, wCodePage); |
| 235 if (pFont) { | 239 if (pFont) { |
| 236 m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 240 m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 237 int32_t index = m_Fonts.Find(pFont); | 241 int32_t index = m_Fonts.Find(pFont); |
| 238 if (index < 0) { | 242 if (index < 0) { |
| 239 m_Fonts.Add(pFont); | 243 m_Fonts.Add(pFont); |
| 240 pFont->Retain(); | 244 pFont->Retain(); |
| 241 } | 245 } |
| 242 return pFont; | 246 return pFont; |
| 243 } | 247 } |
| 244 return NULL; | 248 return nullptr; |
| 245 } | 249 } |
| 246 | 250 |
| 247 void CFGAS_StdFontMgrImp::ClearFontCache() { | 251 void CFGAS_StdFontMgrImp::ClearFontCache() { |
| 248 for (int32_t i = 0; i < m_Fonts.GetSize(); i++) | 252 for (int32_t i = 0; i < m_Fonts.GetSize(); i++) |
| 249 m_Fonts[i]->Reset(); | 253 m_Fonts[i]->Reset(); |
| 250 } | 254 } |
| 251 | 255 |
| 252 void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, | 256 void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, |
| 253 CFGAS_GEFont* pFont) { | 257 CFGAS_GEFont* pFont) { |
| 254 FX_POSITION pos = fontMap.GetStartPosition(); | 258 FX_POSITION pos = fontMap.GetStartPosition(); |
| 255 void* pKey; | 259 void* pKey; |
| 256 void* pFind; | 260 void* pFind; |
| 257 while (pos) { | 261 while (pos) { |
| 258 pFind = NULL; | 262 pFind = nullptr; |
| 259 fontMap.GetNextAssoc(pos, pKey, pFind); | 263 fontMap.GetNextAssoc(pos, pKey, pFind); |
| 260 if (pFind != (void*)pFont) { | 264 if (pFind != (void*)pFont) { |
| 261 continue; | 265 continue; |
| 262 } | 266 } |
| 263 fontMap.RemoveKey(pKey); | 267 fontMap.RemoveKey(pKey); |
| 264 break; | 268 break; |
| 265 } | 269 } |
| 266 } | 270 } |
| 267 | 271 |
| 268 void CFGAS_StdFontMgrImp::RemoveFont(CFGAS_GEFont* pFont) { | 272 void CFGAS_StdFontMgrImp::RemoveFont(CFGAS_GEFont* pFont) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 293 params.pwsFamily = pszFontFamily; | 297 params.pwsFamily = pszFontFamily; |
| 294 params.dwFontStyles = dwFontStyles; | 298 params.dwFontStyles = dwFontStyles; |
| 295 params.dwMatchFlags = dwMatchFlags; | 299 params.dwMatchFlags = dwMatchFlags; |
| 296 FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(¶ms, m_FontFaces); | 300 FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(¶ms, m_FontFaces); |
| 297 if (pDesc) { | 301 if (pDesc) { |
| 298 return pDesc; | 302 return pDesc; |
| 299 } | 303 } |
| 300 if (pszFontFamily && m_pEnumerator) { | 304 if (pszFontFamily && m_pEnumerator) { |
| 301 CFX_FontDescriptors namedFonts; | 305 CFX_FontDescriptors namedFonts; |
| 302 m_pEnumerator(namedFonts, pszFontFamily, wUnicode); | 306 m_pEnumerator(namedFonts, pszFontFamily, wUnicode); |
| 303 params.pwsFamily = NULL; | 307 params.pwsFamily = nullptr; |
| 304 pDesc = FX_DefFontMatcher(¶ms, namedFonts); | 308 pDesc = FX_DefFontMatcher(¶ms, namedFonts); |
| 305 if (pDesc == NULL) { | 309 if (!pDesc) { |
| 306 return NULL; | 310 return nullptr; |
| 307 } | 311 } |
| 308 for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { | 312 for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { |
| 309 FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i); | 313 FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i); |
| 310 if (*pMatch == *pDesc) { | 314 if (*pMatch == *pDesc) { |
| 311 return pMatch; | 315 return pMatch; |
| 312 } | 316 } |
| 313 } | 317 } |
| 314 int index = m_FontFaces.Add(*pDesc); | 318 int index = m_FontFaces.Add(*pDesc); |
| 315 return m_FontFaces.GetPtrAt(index); | 319 return m_FontFaces.GetPtrAt(index); |
| 316 } | 320 } |
| 317 return NULL; | 321 return nullptr; |
| 318 } | 322 } |
| 319 | 323 |
| 320 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, | 324 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, |
| 321 const CFX_FontDescriptors& fonts) { | 325 const CFX_FontDescriptors& fonts) { |
| 322 FX_FONTDESCRIPTOR const* pBestFont = NULL; | 326 FX_FONTDESCRIPTOR const* pBestFont = nullptr; |
| 323 int32_t iBestSimilar = 0; | 327 int32_t iBestSimilar = 0; |
| 324 FX_BOOL bMatchStyle = | 328 FX_BOOL bMatchStyle = |
| 325 (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0; | 329 (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0; |
| 326 int32_t iCount = fonts.GetSize(); | 330 int32_t iCount = fonts.GetSize(); |
| 327 for (int32_t i = 0; i < iCount; ++i) { | 331 for (int32_t i = 0; i < iCount; ++i) { |
| 328 FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i); | 332 FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i); |
| 329 if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == | 333 if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == |
| 330 FX_FONTSTYLE_BoldItalic) { | 334 FX_FONTSTYLE_BoldItalic) { |
| 331 continue; | 335 continue; |
| 332 } | 336 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 363 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) { | 367 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) { |
| 364 return pFont; | 368 return pFont; |
| 365 } | 369 } |
| 366 } | 370 } |
| 367 int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); | 371 int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); |
| 368 if (iBestSimilar < iSimilarValue) { | 372 if (iBestSimilar < iSimilarValue) { |
| 369 iBestSimilar = iSimilarValue; | 373 iBestSimilar = iSimilarValue; |
| 370 pBestFont = pFont; | 374 pBestFont = pFont; |
| 371 } | 375 } |
| 372 } | 376 } |
| 373 return iBestSimilar < 1 ? NULL : pBestFont; | 377 return iBestSimilar < 1 ? nullptr : pBestFont; |
| 374 } | 378 } |
| 375 | 379 |
| 376 int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont, | 380 int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont, |
| 377 uint32_t dwFontStyles) { | 381 uint32_t dwFontStyles) { |
| 378 int32_t iValue = 0; | 382 int32_t iValue = 0; |
| 379 if ((dwFontStyles & FX_FONTSTYLE_Symbolic) == | 383 if ((dwFontStyles & FX_FONTSTYLE_Symbolic) == |
| 380 (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) { | 384 (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) { |
| 381 iValue += 64; | 385 iValue += 64; |
| 382 } | 386 } |
| 383 if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) == | 387 if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) == |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 FXSYS_memcpy(&pFont->FontSignature, &lpntme->ntmFontSig, | 441 FXSYS_memcpy(&pFont->FontSignature, &lpntme->ntmFontSig, |
| 438 sizeof(lpntme->ntmFontSig)); | 442 sizeof(lpntme->ntmFontSig)); |
| 439 ((CFX_FontDescriptors*)lParam)->Add(*pFont); | 443 ((CFX_FontDescriptors*)lParam)->Add(*pFont); |
| 440 FX_Free(pFont); | 444 FX_Free(pFont); |
| 441 return 1; | 445 return 1; |
| 442 } | 446 } |
| 443 | 447 |
| 444 static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts, | 448 static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts, |
| 445 const FX_WCHAR* pwsFaceName, | 449 const FX_WCHAR* pwsFaceName, |
| 446 FX_WCHAR wUnicode) { | 450 FX_WCHAR wUnicode) { |
| 447 HDC hDC = ::GetDC(NULL); | 451 HDC hDC = ::GetDC(nullptr); |
| 448 LOGFONTW lfFind; | 452 LOGFONTW lfFind; |
| 449 FXSYS_memset(&lfFind, 0, sizeof(lfFind)); | 453 FXSYS_memset(&lfFind, 0, sizeof(lfFind)); |
| 450 lfFind.lfCharSet = DEFAULT_CHARSET; | 454 lfFind.lfCharSet = DEFAULT_CHARSET; |
| 451 if (pwsFaceName) { | 455 if (pwsFaceName) { |
| 452 FXSYS_wcsncpy(lfFind.lfFaceName, pwsFaceName, 31); | 456 FXSYS_wcsncpy(lfFind.lfFaceName, pwsFaceName, 31); |
| 453 lfFind.lfFaceName[31] = 0; | 457 lfFind.lfFaceName[31] = 0; |
| 454 } | 458 } |
| 455 EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, | 459 EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, |
| 456 (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); | 460 (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); |
| 457 ::ReleaseDC(NULL, hDC); | 461 ::ReleaseDC(nullptr, hDC); |
| 458 } | 462 } |
| 459 | 463 |
| 460 FX_LPEnumAllFonts FX_GetDefFontEnumerator() { | 464 FX_LPEnumAllFonts FX_GetDefFontEnumerator() { |
| 461 return FX_EnumGdiFonts; | 465 return FX_EnumGdiFonts; |
| 462 } | 466 } |
| 463 | 467 |
| 464 #else | 468 #else |
| 465 const FX_CHAR* g_FontFolders[] = { | 469 const FX_CHAR* g_FontFolders[] = { |
| 466 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ | 470 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ |
| 467 "/usr/share/fonts", "/usr/share/X11/fonts/Type1", | 471 "/usr/share/fonts", "/usr/share/X11/fonts/Type1", |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 481 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { | 485 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { |
| 482 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) | 486 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) |
| 483 m_FolderPaths.Add(g_FontFolders[i]); | 487 m_FolderPaths.Add(g_FontFolders[i]); |
| 484 } | 488 } |
| 485 | 489 |
| 486 CFX_FontSourceEnum_File::~CFX_FontSourceEnum_File() {} | 490 CFX_FontSourceEnum_File::~CFX_FontSourceEnum_File() {} |
| 487 | 491 |
| 488 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { | 492 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { |
| 489 Restart: | 493 Restart: |
| 490 void* pCurHandle = | 494 void* pCurHandle = |
| 491 m_FolderQueue.GetSize() == 0 | 495 m_FolderQueue.GetSize() == 0 |
|
Lei Zhang
2016/06/23 17:56:00
flip the logic?
dsinclair
2016/06/23 18:46:52
Done.
| |
| 492 ? NULL | 496 ? nullptr |
| 493 : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; | 497 : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; |
| 494 if (NULL == pCurHandle) { | 498 if (!pCurHandle) { |
| 495 if (m_FolderPaths.GetSize() < 1) { | 499 if (m_FolderPaths.GetSize() < 1) { |
| 496 return ""; | 500 return ""; |
| 497 } | 501 } |
| 498 pCurHandle = | 502 pCurHandle = |
| 499 FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str()); | 503 FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str()); |
| 500 FX_HandleParentPath hpp; | 504 FX_HandleParentPath hpp; |
| 501 hpp.pFileHandle = pCurHandle; | 505 hpp.pFileHandle = pCurHandle; |
| 502 hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; | 506 hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; |
| 503 m_FolderQueue.Add(hpp); | 507 m_FolderQueue.Add(hpp); |
| 504 } | 508 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 524 } | 528 } |
| 525 if (bsName == "." || bsName == "..") { | 529 if (bsName == "." || bsName == "..") { |
| 526 continue; | 530 continue; |
| 527 } | 531 } |
| 528 if (bFolder) { | 532 if (bFolder) { |
| 529 FX_HandleParentPath hpp; | 533 FX_HandleParentPath hpp; |
| 530 hpp.bsParentPath = | 534 hpp.bsParentPath = |
| 531 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + | 535 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + |
| 532 bsFolderSpearator + bsName; | 536 bsFolderSpearator + bsName; |
| 533 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str()); | 537 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str()); |
| 534 if (hpp.pFileHandle == NULL) { | 538 if (!hpp.pFileHandle) { |
| 535 continue; | 539 continue; |
| 536 } | 540 } |
| 537 m_FolderQueue.Add(hpp); | 541 m_FolderQueue.Add(hpp); |
| 538 pCurHandle = hpp.pFileHandle; | 542 pCurHandle = hpp.pFileHandle; |
| 539 continue; | 543 continue; |
| 540 } | 544 } |
| 541 bsName = | 545 bsName = |
| 542 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + | 546 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + |
| 543 bsFolderSpearator + bsName; | 547 bsFolderSpearator + bsName; |
| 544 break; | 548 break; |
| 545 } | 549 } |
| 546 return bsName; | 550 return bsName; |
| 547 } | 551 } |
| 548 | 552 |
| 549 FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { | 553 FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { |
| 550 m_wsNext = GetNextFile().UTF8Decode(); | 554 m_wsNext = GetNextFile().UTF8Decode(); |
| 551 if (0 == m_wsNext.GetLength()) { | 555 if (m_wsNext.GetLength() == 0) { |
| 552 return (FX_POSITION)0; | 556 return (FX_POSITION)0; |
| 553 } | 557 } |
| 554 return (FX_POSITION)-1; | 558 return (FX_POSITION)-1; |
| 555 } | 559 } |
| 556 | 560 |
| 557 IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { | 561 IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { |
| 558 IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); | 562 IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); |
| 559 m_wsNext = GetNextFile().UTF8Decode(); | 563 m_wsNext = GetNextFile().UTF8Decode(); |
| 560 pos = 0 != m_wsNext.GetLength() ? pAccess : NULL; | 564 pos = m_wsNext.GetLength() != 0 ? pAccess : nullptr; |
| 561 return pAccess; | 565 return pAccess; |
| 562 } | 566 } |
| 563 | 567 |
| 564 IFGAS_FontMgr* IFGAS_FontMgr::Create(CFX_FontSourceEnum_File* pFontEnum) { | 568 IFGAS_FontMgr* IFGAS_FontMgr::Create(CFX_FontSourceEnum_File* pFontEnum) { |
| 565 if (!pFontEnum) | 569 if (!pFontEnum) |
| 566 return nullptr; | 570 return nullptr; |
| 567 | 571 |
| 568 std::unique_ptr<CFGAS_FontMgrImp> pFontMgr(new CFGAS_FontMgrImp(pFontEnum)); | 572 std::unique_ptr<CFGAS_FontMgrImp> pFontMgr(new CFGAS_FontMgrImp(pFontEnum)); |
| 569 if (!pFontMgr->EnumFonts()) | 573 if (!pFontMgr->EnumFonts()) |
| 570 return nullptr; | 574 return nullptr; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 735 const FX_WCHAR* pszFontFamily) { | 739 const FX_WCHAR* pszFontFamily) { |
| 736 return GetFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, | 740 return GetFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, |
| 737 pszFontFamily); | 741 pszFontFamily); |
| 738 } | 742 } |
| 739 | 743 |
| 740 CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByUnicode( | 744 CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByUnicode( |
| 741 FX_WCHAR wUnicode, | 745 FX_WCHAR wUnicode, |
| 742 uint32_t dwFontStyles, | 746 uint32_t dwFontStyles, |
| 743 const FX_WCHAR* pszFontFamily) { | 747 const FX_WCHAR* pszFontFamily) { |
| 744 CFGAS_GEFont* pFont = nullptr; | 748 CFGAS_GEFont* pFont = nullptr; |
| 745 if (m_FailedUnicodes2NULL.Lookup(wUnicode, pFont)) | 749 if (m_FailedUnicodes2Nullptr.Lookup(wUnicode, pFont)) |
| 746 return nullptr; | 750 return nullptr; |
| 747 const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode); | 751 const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode); |
| 748 uint16_t wCodePage = x ? x->wCodePage : 0xFFFF; | 752 uint16_t wCodePage = x ? x->wCodePage : 0xFFFF; |
| 749 uint16_t wBitField = x ? x->wBitField : 0x03E7; | 753 uint16_t wBitField = x ? x->wBitField : 0x03E7; |
| 750 CFX_ByteString bsHash; | 754 CFX_ByteString bsHash; |
| 751 if (wCodePage == 0xFFFF) | 755 if (wCodePage == 0xFFFF) |
| 752 bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles); | 756 bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles); |
| 753 else | 757 else |
| 754 bsHash.Format("%d, %d", wCodePage, dwFontStyles); | 758 bsHash.Format("%d, %d", wCodePage, dwFontStyles); |
| 755 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); | 759 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 778 if (!VerifyUnicode(pDesc, wUnicode)) | 782 if (!VerifyUnicode(pDesc, wUnicode)) |
| 779 continue; | 783 continue; |
| 780 pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); | 784 pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); |
| 781 if (!pFont) | 785 if (!pFont) |
| 782 continue; | 786 continue; |
| 783 pFont->SetLogicalFontStyle(dwFontStyles); | 787 pFont->SetLogicalFontStyle(dwFontStyles); |
| 784 pFonts->Add(pFont); | 788 pFonts->Add(pFont); |
| 785 return pFont; | 789 return pFont; |
| 786 } | 790 } |
| 787 if (!pszFontFamily) | 791 if (!pszFontFamily) |
| 788 m_FailedUnicodes2NULL.SetAt(wUnicode, nullptr); | 792 m_FailedUnicodes2Nullptr.SetAt(wUnicode, nullptr); |
| 789 return nullptr; | 793 return nullptr; |
| 790 } | 794 } |
| 791 | 795 |
| 792 FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc, | 796 FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc, |
| 793 FX_WCHAR wcUnicode) { | 797 FX_WCHAR wcUnicode) { |
| 794 IFX_FileRead* pFileRead = CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); | 798 IFX_FileRead* pFileRead = CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); |
| 795 if (!pFileRead) | 799 if (!pFileRead) |
| 796 return FALSE; | 800 return FALSE; |
| 797 FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); | 801 FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); |
| 798 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); | 802 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1124 pos = m_IFXFont2FileRead.GetStartPosition(); | 1128 pos = m_IFXFont2FileRead.GetStartPosition(); |
| 1125 while (pos) { | 1129 while (pos) { |
| 1126 CFGAS_GEFont* pFont; | 1130 CFGAS_GEFont* pFont; |
| 1127 IFX_FileRead* pFileRead; | 1131 IFX_FileRead* pFileRead; |
| 1128 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); | 1132 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); |
| 1129 pFileRead->Release(); | 1133 pFileRead->Release(); |
| 1130 } | 1134 } |
| 1131 } | 1135 } |
| 1132 | 1136 |
| 1133 void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) { | 1137 void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) { |
| 1134 if (NULL == pEFont) { | 1138 if (!pEFont) { |
| 1135 return; | 1139 return; |
| 1136 } | 1140 } |
| 1137 IFX_FileRead* pFileRead; | 1141 IFX_FileRead* pFileRead; |
| 1138 if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { | 1142 if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { |
| 1139 pFileRead->Release(); | 1143 pFileRead->Release(); |
| 1140 m_IFXFont2FileRead.RemoveKey(pEFont); | 1144 m_IFXFont2FileRead.RemoveKey(pEFont); |
| 1141 } | 1145 } |
| 1142 FX_POSITION pos; | 1146 FX_POSITION pos; |
| 1143 pos = m_Hash2Fonts.GetStartPosition(); | 1147 pos = m_Hash2Fonts.GetStartPosition(); |
| 1144 while (pos) { | 1148 while (pos) { |
| 1145 uint32_t dwHash; | 1149 uint32_t dwHash; |
| 1146 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; | 1150 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; |
| 1147 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); | 1151 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); |
| 1148 if (NULL != pFonts) { | 1152 if (pFonts) { |
| 1149 for (int32_t i = 0; i < pFonts->GetSize(); i++) { | 1153 for (int32_t i = 0; i < pFonts->GetSize(); i++) { |
| 1150 if (pFonts->GetAt(i) == pEFont) { | 1154 if (pFonts->GetAt(i) == pEFont) { |
| 1151 pFonts->SetAt(i, NULL); | 1155 pFonts->SetAt(i, nullptr); |
| 1152 } | 1156 } |
| 1153 } | 1157 } |
| 1154 } else { | 1158 } else { |
| 1155 m_Hash2Fonts.RemoveKey(dwHash); | 1159 m_Hash2Fonts.RemoveKey(dwHash); |
| 1156 } | 1160 } |
| 1157 } | 1161 } |
| 1158 } | 1162 } |
| 1159 | 1163 |
| 1160 void CFGAS_FontMgrImp::RegisterFace(FXFT_Face pFace, | 1164 void CFGAS_FontMgrImp::RegisterFace(FXFT_Face pFace, |
| 1161 CFX_FontDescriptors& Fonts, | 1165 CFX_FontDescriptors& Fonts, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1232 return flag; | 1236 return flag; |
| 1233 } | 1237 } |
| 1234 | 1238 |
| 1235 #define GetUInt8(p) ((uint8_t)((p)[0])) | 1239 #define GetUInt8(p) ((uint8_t)((p)[0])) |
| 1236 #define GetUInt16(p) ((uint16_t)((p)[0] << 8 | (p)[1])) | 1240 #define GetUInt16(p) ((uint16_t)((p)[0] << 8 | (p)[1])) |
| 1237 #define GetUInt32(p) \ | 1241 #define GetUInt32(p) \ |
| 1238 ((uint32_t)((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])) | 1242 ((uint32_t)((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])) |
| 1239 | 1243 |
| 1240 void CFGAS_FontMgrImp::GetNames(const uint8_t* name_table, | 1244 void CFGAS_FontMgrImp::GetNames(const uint8_t* name_table, |
| 1241 CFX_WideStringArray& Names) { | 1245 CFX_WideStringArray& Names) { |
| 1242 if (NULL == name_table) { | 1246 if (!name_table) { |
| 1243 return; | 1247 return; |
| 1244 } | 1248 } |
| 1245 uint8_t* lpTable = (uint8_t*)name_table; | 1249 uint8_t* lpTable = (uint8_t*)name_table; |
| 1246 CFX_WideString wsFamily; | 1250 CFX_WideString wsFamily; |
| 1247 uint8_t* sp = lpTable + 2; | 1251 uint8_t* sp = lpTable + 2; |
| 1248 uint8_t* lpNameRecord = lpTable + 6; | 1252 uint8_t* lpNameRecord = lpTable + 6; |
| 1249 uint16_t nNameCount = GetUInt16(sp); | 1253 uint16_t nNameCount = GetUInt16(sp); |
| 1250 uint8_t* lpStr = lpTable + GetUInt16(sp + 2); | 1254 uint8_t* lpStr = lpTable + GetUInt16(sp + 2); |
| 1251 for (uint16_t j = 0; j < nNameCount; j++) { | 1255 for (uint16_t j = 0; j < nNameCount; j++) { |
| 1252 uint16_t nNameID = GetUInt16(lpNameRecord + j * 12 + 6); | 1256 uint16_t nNameID = GetUInt16(lpNameRecord + j * 12 + 6); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1362 charsets.push_back(FX_CHARSET_Default); | 1366 charsets.push_back(FX_CHARSET_Default); |
| 1363 } | 1367 } |
| 1364 return charsets; | 1368 return charsets; |
| 1365 } | 1369 } |
| 1366 | 1370 |
| 1367 #undef CODEPAGERANGE_IMPLEMENT | 1371 #undef CODEPAGERANGE_IMPLEMENT |
| 1368 void CFGAS_FontMgrImp::GetUSBCSB(FXFT_Face pFace, | 1372 void CFGAS_FontMgrImp::GetUSBCSB(FXFT_Face pFace, |
| 1369 uint32_t* USB, | 1373 uint32_t* USB, |
| 1370 uint32_t* CSB) { | 1374 uint32_t* CSB) { |
| 1371 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); | 1375 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); |
| 1372 if (NULL != pOS2) { | 1376 if (pOS2) { |
| 1373 USB[0] = pOS2->ulUnicodeRange1; | 1377 USB[0] = pOS2->ulUnicodeRange1; |
| 1374 USB[1] = pOS2->ulUnicodeRange2; | 1378 USB[1] = pOS2->ulUnicodeRange2; |
| 1375 USB[2] = pOS2->ulUnicodeRange3; | 1379 USB[2] = pOS2->ulUnicodeRange3; |
| 1376 USB[3] = pOS2->ulUnicodeRange4; | 1380 USB[3] = pOS2->ulUnicodeRange4; |
| 1377 CSB[0] = pOS2->ulCodePageRange1; | 1381 CSB[0] = pOS2->ulCodePageRange1; |
| 1378 CSB[1] = pOS2->ulCodePageRange2; | 1382 CSB[1] = pOS2->ulCodePageRange2; |
| 1379 } else { | 1383 } else { |
| 1380 USB[0] = 0; | 1384 USB[0] = 0; |
| 1381 USB[1] = 0; | 1385 USB[1] = 0; |
| 1382 USB[2] = 0; | 1386 USB[2] = 0; |
| 1383 USB[3] = 0; | 1387 USB[3] = 0; |
| 1384 CSB[0] = 0; | 1388 CSB[0] = 0; |
| 1385 CSB[1] = 0; | 1389 CSB[1] = 0; |
| 1386 } | 1390 } |
| 1387 } | 1391 } |
| 1388 | 1392 |
| 1389 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, | 1393 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, |
| 1390 const CFX_WideString& Name2) { | 1394 const CFX_WideString& Name2) { |
| 1391 if (Name1.Find(Name2.c_str()) != -1) { | 1395 if (Name1.Find(Name2.c_str()) != -1) { |
| 1392 return 1; | 1396 return 1; |
| 1393 } | 1397 } |
| 1394 return 0; | 1398 return 0; |
| 1395 } | 1399 } |
| 1396 | 1400 |
| 1397 #endif | 1401 #endif |
| OLD | NEW |