| 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 "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" |
| 11 #include "xfa/fgas/crt/fgas_codepage.h" | 11 #include "xfa/fgas/crt/fgas_codepage.h" |
| 12 #include "xfa/fgas/font/fgas_fontutils.h" | 12 #include "xfa/fgas/font/fgas_fontutils.h" |
| 13 | 13 |
| 14 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 14 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 15 IFGAS_FontMgr* IFGAS_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) { | 15 IFGAS_FontMgr* IFGAS_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) { |
| 16 return new CFGAS_StdFontMgrImp(pEnumerator); | 16 return new CFGAS_StdFontMgrImp(pEnumerator); |
| 17 } | 17 } |
| 18 CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) | 18 CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) |
| 19 : m_pEnumerator(pEnumerator), | 19 : m_pEnumerator(pEnumerator), |
| 20 m_FontFaces(), | 20 m_FontFaces(), |
| 21 m_CPFonts(8), | 21 m_CPFonts(8), |
| 22 m_FamilyFonts(16), | 22 m_FamilyFonts(16), |
| 23 m_UnicodeFonts(16), | 23 m_UnicodeFonts(16), |
| 24 m_BufferFonts(4), | 24 m_BufferFonts(4), |
| 25 m_FileFonts(4), | 25 m_FileFonts(4), |
| 26 m_StreamFonts(4), | 26 m_StreamFonts(4), |
| 27 m_DeriveFonts(4) { | 27 m_DeriveFonts(4) { |
| 28 if (m_pEnumerator) { | 28 if (m_pEnumerator) { |
| 29 m_pEnumerator(m_FontFaces, NULL, 0xFEFF); | 29 m_pEnumerator(m_FontFaces, nullptr, 0xFEFF); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { | 33 CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { |
| 34 m_FontFaces.RemoveAll(); | 34 m_FontFaces.RemoveAll(); |
| 35 m_CPFonts.RemoveAll(); | 35 m_CPFonts.RemoveAll(); |
| 36 m_FamilyFonts.RemoveAll(); | 36 m_FamilyFonts.RemoveAll(); |
| 37 m_UnicodeFonts.RemoveAll(); | 37 m_UnicodeFonts.RemoveAll(); |
| 38 m_BufferFonts.RemoveAll(); | 38 m_BufferFonts.RemoveAll(); |
| 39 m_FileFonts.RemoveAll(); | 39 m_FileFonts.RemoveAll(); |
| 40 m_StreamFonts.RemoveAll(); | 40 m_StreamFonts.RemoveAll(); |
| 41 m_DeriveFonts.RemoveAll(); | 41 m_DeriveFonts.RemoveAll(); |
| 42 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) | 42 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) |
| 43 m_Fonts[i]->Release(); | 43 m_Fonts[i]->Release(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCodePage( | 46 IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCodePage( |
| 47 uint16_t wCodePage, | 47 uint16_t wCodePage, |
| 48 uint32_t dwFontStyles, | 48 uint32_t dwFontStyles, |
| 49 const FX_WCHAR* pszFontFamily) { | 49 const FX_WCHAR* pszFontFamily) { |
| 50 uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); | 50 uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); |
| 51 IFGAS_Font* pFont = NULL; | 51 IFGAS_Font* pFont = nullptr; |
| 52 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 52 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
| 53 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; | 53 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; |
| 54 } | |
| 55 FX_FONTDESCRIPTOR const* pFD; | |
| 56 if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { | |
| 57 if ((pFD = FindFont(NULL, dwFontStyles, TRUE, wCodePage)) == NULL) { | |
| 58 if ((pFD = FindFont(NULL, dwFontStyles, FALSE, wCodePage)) == NULL) | |
| 59 return NULL; | |
| 60 } | |
| 61 } | 54 } |
| 62 ASSERT(pFD); | 55 ASSERT(pFD); |
| 63 pFont = IFGAS_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 56 pFont = IFGAS_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
| 64 if (pFont) { | 57 if (pFont) { |
| 65 m_Fonts.Add(pFont); | 58 m_Fonts.Add(pFont); |
| 66 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 59 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 67 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); | 60 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); |
| 68 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 61 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 69 return LoadFont(pFont, dwFontStyles, wCodePage); | 62 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 70 } | 63 } |
| 71 return NULL; | 64 return nullptr; |
| 72 } | 65 } |
| 73 IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCharset( | 66 IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByCharset( |
| 74 uint8_t nCharset, | 67 uint8_t nCharset, |
| 75 uint32_t dwFontStyles, | 68 uint32_t dwFontStyles, |
| 76 const FX_WCHAR* pszFontFamily) { | 69 const FX_WCHAR* pszFontFamily) { |
| 77 return GetDefFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, | 70 return GetDefFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, |
| 78 pszFontFamily); | 71 pszFontFamily); |
| 79 } | 72 } |
| 80 | 73 |
| 81 IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByUnicode( | 74 IFGAS_Font* CFGAS_StdFontMgrImp::GetDefFontByUnicode( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 uint32_t dwFontStyles, | 115 uint32_t dwFontStyles, |
| 123 const FX_WCHAR* pszFontFamily) { | 116 const FX_WCHAR* pszFontFamily) { |
| 124 return GetDefFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), | 117 return GetDefFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), |
| 125 dwFontStyles, pszFontFamily); | 118 dwFontStyles, pszFontFamily); |
| 126 } | 119 } |
| 127 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, | 120 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, |
| 128 uint32_t dwFontStyles, | 121 uint32_t dwFontStyles, |
| 129 uint16_t wCodePage) { | 122 uint16_t wCodePage) { |
| 130 uint32_t dwHash = | 123 uint32_t dwHash = |
| 131 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); | 124 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); |
| 132 IFGAS_Font* pFont = NULL; | 125 IFGAS_Font* pFont = nullptr; |
| 133 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 126 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
| 134 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; | 127 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; |
| 135 } | 128 } |
| 136 FX_FONTDESCRIPTOR const* pFD = NULL; | 129 FX_FONTDESCRIPTOR const* pFD = |
| 137 if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { | 130 FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage); |
| 138 if ((pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage)) == | 131 if (!pFD) |
| 139 NULL) { | 132 pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage); |
| 140 return NULL; | 133 if (!pFD) |
| 141 } | 134 return nullptr; |
| 142 } | 135 |
| 143 ASSERT(pFD); | 136 if (wCodePage == 0xFFFF) |
| 144 if (wCodePage == 0xFFFF) { | |
| 145 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); | 137 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); |
| 146 } | 138 } |
| 147 pFont = IFGAS_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 139 pFont = IFGAS_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
| 148 if (pFont) { | 140 if (pFont) { |
| 149 m_Fonts.Add(pFont); | 141 m_Fonts.Add(pFont); |
| 150 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 142 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 151 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); | 143 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); |
| 152 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 144 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 153 return LoadFont(pFont, dwFontStyles, wCodePage); | 145 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 154 } | 146 } |
| 155 return NULL; | 147 return nullptr; |
| 156 } | 148 } |
| 157 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, | 149 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, |
| 158 int32_t iLength) { | 150 int32_t iLength) { |
| 159 ASSERT(pBuffer && iLength > 0); | 151 ASSERT(pBuffer && iLength > 0); |
| 160 IFGAS_Font* pFont = NULL; | 152 IFGAS_Font* pFont = nullptr; |
| 161 if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { | 153 if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { |
| 162 if (pFont) { | 154 if (pFont) { |
| 163 return pFont->Retain(); | 155 return pFont->Retain(); |
| 164 } | 156 } |
| 165 } | 157 } |
| 166 pFont = IFGAS_Font::LoadFont(pBuffer, iLength, this); | 158 pFont = IFGAS_Font::LoadFont(pBuffer, iLength, this); |
| 167 if (pFont) { | 159 if (pFont) { |
| 168 m_Fonts.Add(pFont); | 160 m_Fonts.Add(pFont); |
| 169 m_BufferFonts.SetAt((void*)pBuffer, pFont); | 161 m_BufferFonts.SetAt((void*)pBuffer, pFont); |
| 170 return pFont->Retain(); | 162 return pFont->Retain(); |
| 171 } | 163 } |
| 172 return NULL; | 164 return nullptr; |
| 173 } | 165 } |
| 174 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) { | 166 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) { |
| 175 ASSERT(pszFileName); | 167 ASSERT(pszFileName); |
| 176 uint32_t dwHash = FX_HashCode_GetW(pszFileName, false); | 168 uint32_t dwHash = FX_HashCode_GetW(pszFileName, false); |
| 177 IFGAS_Font* pFont = NULL; | 169 IFGAS_Font* pFont = nullptr; |
| 178 if (m_FileFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 170 if (m_FileFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
| 179 if (pFont) { | 171 if (pFont) { |
| 180 return pFont->Retain(); | 172 return pFont->Retain(); |
| 181 } | 173 } |
| 182 } | 174 } |
| 183 pFont = IFGAS_Font::LoadFont(pszFileName, NULL); | 175 pFont = IFGAS_Font::LoadFont(pszFileName, nullptr); |
| 184 if (pFont) { | 176 if (pFont) { |
| 185 m_Fonts.Add(pFont); | 177 m_Fonts.Add(pFont); |
| 186 m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 178 m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 187 return pFont->Retain(); | 179 return pFont->Retain(); |
| 188 } | 180 } |
| 189 return NULL; | 181 return nullptr; |
| 190 } | 182 } |
| 191 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, | 183 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, |
| 192 const FX_WCHAR* pszFontAlias, | 184 const FX_WCHAR* pszFontAlias, |
| 193 uint32_t dwFontStyles, | 185 uint32_t dwFontStyles, |
| 194 uint16_t wCodePage, | 186 uint16_t wCodePage, |
| 195 FX_BOOL bSaveStream) { | 187 FX_BOOL bSaveStream) { |
| 196 ASSERT(pFontStream && pFontStream->GetLength() > 0); | 188 ASSERT(pFontStream && pFontStream->GetLength() > 0); |
| 197 IFGAS_Font* pFont = NULL; | 189 IFGAS_Font* pFont = nullptr; |
| 198 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { | 190 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { |
| 199 if (pFont) { | 191 if (pFont) { |
| 200 if (pszFontAlias) { | 192 if (pszFontAlias) { |
| 201 uint32_t dwHash = | 193 uint32_t dwHash = |
| 202 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); | 194 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); |
| 203 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 195 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 204 } | 196 } |
| 205 return LoadFont(pFont, dwFontStyles, wCodePage); | 197 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 206 } | 198 } |
| 207 } | 199 } |
| 208 pFont = IFGAS_Font::LoadFont(pFontStream, this, bSaveStream); | 200 pFont = IFGAS_Font::LoadFont(pFontStream, this, bSaveStream); |
| 209 if (pFont) { | 201 if (pFont) { |
| 210 m_Fonts.Add(pFont); | 202 m_Fonts.Add(pFont); |
| 211 m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); | 203 m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); |
| 212 if (pszFontAlias) { | 204 if (pszFontAlias) { |
| 213 uint32_t dwHash = | 205 uint32_t dwHash = |
| 214 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); | 206 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); |
| 215 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 207 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 216 } | 208 } |
| 217 return LoadFont(pFont, dwFontStyles, wCodePage); | 209 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 218 } | 210 } |
| 219 return NULL; | 211 return nullptr; |
| 220 } | 212 } |
| 221 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFGAS_Font* pSrcFont, | 213 IFGAS_Font* CFGAS_StdFontMgrImp::LoadFont(IFGAS_Font* pSrcFont, |
| 222 uint32_t dwFontStyles, | 214 uint32_t dwFontStyles, |
| 223 uint16_t wCodePage) { | 215 uint16_t wCodePage) { |
| 224 ASSERT(pSrcFont); | 216 ASSERT(pSrcFont); |
| 225 if (pSrcFont->GetFontStyles() == dwFontStyles) { | 217 if (pSrcFont->GetFontStyles() == dwFontStyles) { |
| 226 return pSrcFont->Retain(); | 218 return pSrcFont->Retain(); |
| 227 } | 219 } |
| 228 void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, | 220 void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, |
| 229 (void*)(uintptr_t)wCodePage}; | 221 (void*)(uintptr_t)wCodePage}; |
| 230 uint32_t dwHash = FX_HashCode_GetA( | 222 uint32_t dwHash = FX_HashCode_GetA( |
| 231 CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false); | 223 CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false); |
| 232 IFGAS_Font* pFont = NULL; | 224 IFGAS_Font* pFont = nullptr; |
| 233 if (m_DeriveFonts.GetCount() > 0) { | 225 if (m_DeriveFonts.GetCount() > 0) { |
| 234 m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); | 226 m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); |
| 235 if (pFont) { | 227 if (pFont) { |
| 236 return pFont->Retain(); | 228 return pFont->Retain(); |
| 237 } | 229 } |
| 238 } | 230 } |
| 239 pFont = pSrcFont->Derive(dwFontStyles, wCodePage); | 231 pFont = pSrcFont->Derive(dwFontStyles, wCodePage); |
| 240 if (pFont) { | 232 if (pFont) { |
| 241 m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 233 m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 242 int32_t index = m_Fonts.Find(pFont); | 234 int32_t index = m_Fonts.Find(pFont); |
| 243 if (index < 0) { | 235 if (index < 0) { |
| 244 m_Fonts.Add(pFont); | 236 m_Fonts.Add(pFont); |
| 245 pFont->Retain(); | 237 pFont->Retain(); |
| 246 } | 238 } |
| 247 return pFont; | 239 return pFont; |
| 248 } | 240 } |
| 249 return NULL; | 241 return nullptr; |
| 250 } | 242 } |
| 251 | 243 |
| 252 void CFGAS_StdFontMgrImp::ClearFontCache() { | 244 void CFGAS_StdFontMgrImp::ClearFontCache() { |
| 253 for (int32_t i = 0; i < m_Fonts.GetSize(); i++) | 245 for (int32_t i = 0; i < m_Fonts.GetSize(); i++) |
| 254 m_Fonts[i]->Reset(); | 246 m_Fonts[i]->Reset(); |
| 255 } | 247 } |
| 256 | 248 |
| 257 void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, | 249 void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, |
| 258 IFGAS_Font* pFont) { | 250 IFGAS_Font* pFont) { |
| 259 FX_POSITION pos = fontMap.GetStartPosition(); | 251 FX_POSITION pos = fontMap.GetStartPosition(); |
| 260 void* pKey; | 252 void* pKey; |
| 261 void* pFind; | 253 void* pFind; |
| 262 while (pos) { | 254 while (pos) { |
| 263 pFind = NULL; | 255 pFind = nullptr; |
| 264 fontMap.GetNextAssoc(pos, pKey, pFind); | 256 fontMap.GetNextAssoc(pos, pKey, pFind); |
| 265 if (pFind != (void*)pFont) { | 257 if (pFind != (void*)pFont) { |
| 266 continue; | 258 continue; |
| 267 } | 259 } |
| 268 fontMap.RemoveKey(pKey); | 260 fontMap.RemoveKey(pKey); |
| 269 break; | 261 break; |
| 270 } | 262 } |
| 271 } | 263 } |
| 272 void CFGAS_StdFontMgrImp::RemoveFont(IFGAS_Font* pFont) { | 264 void CFGAS_StdFontMgrImp::RemoveFont(IFGAS_Font* pFont) { |
| 273 RemoveFont(m_CPFonts, pFont); | 265 RemoveFont(m_CPFonts, pFont); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 297 params.pwsFamily = pszFontFamily; | 289 params.pwsFamily = pszFontFamily; |
| 298 params.dwFontStyles = dwFontStyles; | 290 params.dwFontStyles = dwFontStyles; |
| 299 params.dwMatchFlags = dwMatchFlags; | 291 params.dwMatchFlags = dwMatchFlags; |
| 300 FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(¶ms, m_FontFaces); | 292 FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(¶ms, m_FontFaces); |
| 301 if (pDesc) { | 293 if (pDesc) { |
| 302 return pDesc; | 294 return pDesc; |
| 303 } | 295 } |
| 304 if (pszFontFamily && m_pEnumerator) { | 296 if (pszFontFamily && m_pEnumerator) { |
| 305 CFX_FontDescriptors namedFonts; | 297 CFX_FontDescriptors namedFonts; |
| 306 m_pEnumerator(namedFonts, pszFontFamily, wUnicode); | 298 m_pEnumerator(namedFonts, pszFontFamily, wUnicode); |
| 307 params.pwsFamily = NULL; | 299 params.pwsFamily = nullptr; |
| 308 pDesc = FX_DefFontMatcher(¶ms, namedFonts); | 300 pDesc = FX_DefFontMatcher(¶ms, namedFonts); |
| 309 if (pDesc == NULL) { | 301 if (!pDesc) |
| 310 return NULL; | 302 return nullptr; |
| 311 } | 303 |
| 312 for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { | 304 for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { |
| 313 FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i); | 305 FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i); |
| 314 if (*pMatch == *pDesc) { | 306 if (*pMatch == *pDesc) { |
| 315 return pMatch; | 307 return pMatch; |
| 316 } | 308 } |
| 317 } | 309 } |
| 318 int index = m_FontFaces.Add(*pDesc); | 310 int index = m_FontFaces.Add(*pDesc); |
| 319 return m_FontFaces.GetPtrAt(index); | 311 return m_FontFaces.GetPtrAt(index); |
| 320 } | 312 } |
| 321 return NULL; | 313 return nullptr; |
| 322 } | 314 } |
| 323 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, | 315 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, |
| 324 const CFX_FontDescriptors& fonts) { | 316 const CFX_FontDescriptors& fonts) { |
| 325 FX_FONTDESCRIPTOR const* pBestFont = NULL; | 317 FX_FONTDESCRIPTOR const* pBestFont = nullptr; |
| 326 int32_t iBestSimilar = 0; | 318 int32_t iBestSimilar = 0; |
| 327 FX_BOOL bMatchStyle = | 319 FX_BOOL bMatchStyle = |
| 328 (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0; | 320 (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0; |
| 329 int32_t iCount = fonts.GetSize(); | 321 int32_t iCount = fonts.GetSize(); |
| 330 for (int32_t i = 0; i < iCount; ++i) { | 322 for (int32_t i = 0; i < iCount; ++i) { |
| 331 FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i); | 323 FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i); |
| 332 if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == | 324 if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == |
| 333 FX_FONTSTYLE_BoldItalic) { | 325 FX_FONTSTYLE_BoldItalic) { |
| 334 continue; | 326 continue; |
| 335 } | 327 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 366 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) { | 358 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) { |
| 367 return pFont; | 359 return pFont; |
| 368 } | 360 } |
| 369 } | 361 } |
| 370 int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); | 362 int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); |
| 371 if (iBestSimilar < iSimilarValue) { | 363 if (iBestSimilar < iSimilarValue) { |
| 372 iBestSimilar = iSimilarValue; | 364 iBestSimilar = iSimilarValue; |
| 373 pBestFont = pFont; | 365 pBestFont = pFont; |
| 374 } | 366 } |
| 375 } | 367 } |
| 376 return iBestSimilar < 1 ? NULL : pBestFont; | 368 return iBestSimilar < 1 ? nullptr : pBestFont; |
| 377 } | 369 } |
| 378 int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont, | 370 int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont, |
| 379 uint32_t dwFontStyles) { | 371 uint32_t dwFontStyles) { |
| 380 int32_t iValue = 0; | 372 int32_t iValue = 0; |
| 381 if ((dwFontStyles & FX_FONTSTYLE_Symbolic) == | 373 if ((dwFontStyles & FX_FONTSTYLE_Symbolic) == |
| 382 (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) { | 374 (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) { |
| 383 iValue += 64; | 375 iValue += 64; |
| 384 } | 376 } |
| 385 if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) == | 377 if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) == |
| 386 (pFont->dwFontStyles & FX_FONTSTYLE_FixedPitch)) { | 378 (pFont->dwFontStyles & FX_FONTSTYLE_FixedPitch)) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 pFont->wsFontFace[31] = 0; | 427 pFont->wsFontFace[31] = 0; |
| 436 FXSYS_memcpy(&pFont->FontSignature, &lpntme->ntmFontSig, | 428 FXSYS_memcpy(&pFont->FontSignature, &lpntme->ntmFontSig, |
| 437 sizeof(lpntme->ntmFontSig)); | 429 sizeof(lpntme->ntmFontSig)); |
| 438 ((CFX_FontDescriptors*)lParam)->Add(*pFont); | 430 ((CFX_FontDescriptors*)lParam)->Add(*pFont); |
| 439 FX_Free(pFont); | 431 FX_Free(pFont); |
| 440 return 1; | 432 return 1; |
| 441 } | 433 } |
| 442 static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts, | 434 static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts, |
| 443 const FX_WCHAR* pwsFaceName, | 435 const FX_WCHAR* pwsFaceName, |
| 444 FX_WCHAR wUnicode) { | 436 FX_WCHAR wUnicode) { |
| 445 HDC hDC = ::GetDC(NULL); | 437 HDC hDC = ::GetDC(nullptr); |
| 446 LOGFONTW lfFind; | 438 LOGFONTW lfFind; |
| 447 FXSYS_memset(&lfFind, 0, sizeof(lfFind)); | 439 FXSYS_memset(&lfFind, 0, sizeof(lfFind)); |
| 448 lfFind.lfCharSet = DEFAULT_CHARSET; | 440 lfFind.lfCharSet = DEFAULT_CHARSET; |
| 449 if (pwsFaceName) { | 441 if (pwsFaceName) { |
| 450 FXSYS_wcsncpy(lfFind.lfFaceName, pwsFaceName, 31); | 442 FXSYS_wcsncpy(lfFind.lfFaceName, pwsFaceName, 31); |
| 451 lfFind.lfFaceName[31] = 0; | 443 lfFind.lfFaceName[31] = 0; |
| 452 } | 444 } |
| 453 EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, | 445 EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, |
| 454 (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); | 446 (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); |
| 455 ::ReleaseDC(NULL, hDC); | 447 ::ReleaseDC(nullptr, hDC); |
| 456 } | 448 } |
| 457 FX_LPEnumAllFonts FX_GetDefFontEnumerator() { | 449 FX_LPEnumAllFonts FX_GetDefFontEnumerator() { |
| 458 return FX_EnumGdiFonts; | 450 return FX_EnumGdiFonts; |
| 459 } | 451 } |
| 460 #else | 452 #else |
| 461 const FX_CHAR* g_FontFolders[] = { | 453 const FX_CHAR* g_FontFolders[] = { |
| 462 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ | 454 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ |
| 463 "/usr/share/fonts", "/usr/share/X11/fonts/Type1", | 455 "/usr/share/fonts", "/usr/share/X11/fonts/Type1", |
| 464 "/usr/share/X11/fonts/TTF", "/usr/local/share/fonts", | 456 "/usr/share/X11/fonts/TTF", "/usr/local/share/fonts", |
| 465 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 457 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 466 "~/Library/Fonts", "/Library/Fonts", "/System/Library/Fonts", | 458 "~/Library/Fonts", "/Library/Fonts", "/System/Library/Fonts", |
| 467 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ | 459 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ |
| 468 "/system/fonts", | 460 "/system/fonts", |
| 469 #endif | 461 #endif |
| 470 }; | 462 }; |
| 471 | 463 |
| 472 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { | 464 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { |
| 473 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) | 465 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) |
| 474 m_FolderPaths.Add(g_FontFolders[i]); | 466 m_FolderPaths.Add(g_FontFolders[i]); |
| 475 } | 467 } |
| 476 | 468 |
| 477 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { | 469 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { |
| 478 Restart: | 470 Restart: |
| 479 void* pCurHandle = | 471 void* pCurHandle = |
| 480 m_FolderQueue.GetSize() == 0 | 472 m_FolderQueue.GetSize() == 0 |
| 481 ? NULL | 473 ? nullptr |
| 482 : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; | 474 : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; |
| 483 if (NULL == pCurHandle) { | 475 if (!pCurHandle) { |
| 484 if (m_FolderPaths.GetSize() < 1) { | 476 if (m_FolderPaths.GetSize() < 1) |
| 485 return ""; | 477 return ""; |
| 486 } | 478 |
| 487 pCurHandle = | 479 pCurHandle = |
| 488 FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str()); | 480 FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str()); |
| 489 FX_HandleParentPath hpp; | 481 FX_HandleParentPath hpp; |
| 490 hpp.pFileHandle = pCurHandle; | 482 hpp.pFileHandle = pCurHandle; |
| 491 hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; | 483 hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; |
| 492 m_FolderQueue.Add(hpp); | 484 m_FolderQueue.Add(hpp); |
| 493 } | 485 } |
| 494 CFX_ByteString bsName; | 486 CFX_ByteString bsName; |
| 495 FX_BOOL bFolder; | 487 FX_BOOL bFolder; |
| 496 CFX_ByteString bsFolderSpearator = | 488 CFX_ByteString bsFolderSpearator = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 513 } | 505 } |
| 514 if (bsName == "." || bsName == "..") { | 506 if (bsName == "." || bsName == "..") { |
| 515 continue; | 507 continue; |
| 516 } | 508 } |
| 517 if (bFolder) { | 509 if (bFolder) { |
| 518 FX_HandleParentPath hpp; | 510 FX_HandleParentPath hpp; |
| 519 hpp.bsParentPath = | 511 hpp.bsParentPath = |
| 520 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + | 512 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + |
| 521 bsFolderSpearator + bsName; | 513 bsFolderSpearator + bsName; |
| 522 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str()); | 514 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str()); |
| 523 if (hpp.pFileHandle == NULL) { | 515 if (!hpp.pFileHandle) |
| 524 continue; | 516 continue; |
| 525 } | 517 |
| 526 m_FolderQueue.Add(hpp); | 518 m_FolderQueue.Add(hpp); |
| 527 pCurHandle = hpp.pFileHandle; | 519 pCurHandle = hpp.pFileHandle; |
| 528 continue; | 520 continue; |
| 529 } | 521 } |
| 530 bsName = | 522 bsName = |
| 531 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + | 523 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + |
| 532 bsFolderSpearator + bsName; | 524 bsFolderSpearator + bsName; |
| 533 break; | 525 break; |
| 534 } | 526 } |
| 535 return bsName; | 527 return bsName; |
| 536 } | 528 } |
| 537 FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { | 529 FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { |
| 538 m_wsNext = GetNextFile().UTF8Decode(); | 530 m_wsNext = GetNextFile().UTF8Decode(); |
| 539 if (0 == m_wsNext.GetLength()) { | 531 if (0 == m_wsNext.GetLength()) { |
| 540 return (FX_POSITION)0; | 532 return (FX_POSITION)0; |
| 541 } | 533 } |
| 542 return (FX_POSITION)-1; | 534 return (FX_POSITION)-1; |
| 543 } | 535 } |
| 544 | 536 |
| 545 IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { | 537 IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { |
| 546 IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); | 538 IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); |
| 547 m_wsNext = GetNextFile().UTF8Decode(); | 539 m_wsNext = GetNextFile().UTF8Decode(); |
| 548 pos = 0 != m_wsNext.GetLength() ? pAccess : NULL; | 540 pos = 0 != m_wsNext.GetLength() ? pAccess : nullptr; |
| 549 return (IFX_FileAccess*)pAccess; | 541 return (IFX_FileAccess*)pAccess; |
| 550 } | 542 } |
| 551 | 543 |
| 552 IFGAS_FontMgr* IFGAS_FontMgr::Create(CFX_FontSourceEnum_File* pFontEnum) { | 544 IFGAS_FontMgr* IFGAS_FontMgr::Create(CFX_FontSourceEnum_File* pFontEnum) { |
| 553 if (!pFontEnum) | 545 if (!pFontEnum) |
| 554 return nullptr; | 546 return nullptr; |
| 555 | 547 |
| 556 std::unique_ptr<CFGAS_FontMgrImp> pFontMgr(new CFGAS_FontMgrImp(pFontEnum)); | 548 std::unique_ptr<CFGAS_FontMgrImp> pFontMgr(new CFGAS_FontMgrImp(pFontEnum)); |
| 557 if (!pFontMgr->EnumFonts()) | 549 if (!pFontMgr->EnumFonts()) |
| 558 return nullptr; | 550 return nullptr; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 CFX_ArrayTemplate<IFGAS_Font*>* pFonts; | 626 CFX_ArrayTemplate<IFGAS_Font*>* pFonts; |
| 635 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); | 627 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); |
| 636 delete pFonts; | 628 delete pFonts; |
| 637 } | 629 } |
| 638 m_Hash2Fonts.RemoveAll(); | 630 m_Hash2Fonts.RemoveAll(); |
| 639 pos = m_Hash2FileAccess.GetStartPosition(); | 631 pos = m_Hash2FileAccess.GetStartPosition(); |
| 640 while (pos) { | 632 while (pos) { |
| 641 uint32_t dwHash; | 633 uint32_t dwHash; |
| 642 IFX_FileAccess* pFileAccess; | 634 IFX_FileAccess* pFileAccess; |
| 643 m_Hash2FileAccess.GetNextAssoc(pos, dwHash, pFileAccess); | 635 m_Hash2FileAccess.GetNextAssoc(pos, dwHash, pFileAccess); |
| 644 if (NULL != pFileAccess) { | 636 if (pFileAccess) |
| 645 pFileAccess->Release(); | 637 pFileAccess->Release(); |
| 646 } | |
| 647 } | 638 } |
| 648 pos = m_FileAccess2IFXFont.GetStartPosition(); | 639 pos = m_FileAccess2IFXFont.GetStartPosition(); |
| 649 while (pos) { | 640 while (pos) { |
| 650 uint32_t dwHash; | 641 uint32_t dwHash; |
| 651 IFGAS_Font* pFont; | 642 IFGAS_Font* pFont; |
| 652 m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont); | 643 m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont); |
| 653 if (NULL != pFont) { | 644 if (pFont) |
| 654 pFont->Release(); | 645 pFont->Release(); |
| 655 } | |
| 656 } | 646 } |
| 657 pos = m_IFXFont2FileRead.GetStartPosition(); | 647 pos = m_IFXFont2FileRead.GetStartPosition(); |
| 658 while (pos) { | 648 while (pos) { |
| 659 IFGAS_Font* pFont; | 649 IFGAS_Font* pFont; |
| 660 IFX_FileRead* pFileRead; | 650 IFX_FileRead* pFileRead; |
| 661 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); | 651 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); |
| 662 pFileRead->Release(); | 652 pFileRead->Release(); |
| 663 } | 653 } |
| 664 delete this; | 654 delete this; |
| 665 } | 655 } |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 uint32_t dwHash; | 1199 uint32_t dwHash; |
| 1210 CFX_FontDescriptorInfos* pDescs; | 1200 CFX_FontDescriptorInfos* pDescs; |
| 1211 m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); | 1201 m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); |
| 1212 delete pDescs; | 1202 delete pDescs; |
| 1213 } | 1203 } |
| 1214 pos = m_FileAccess2IFXFont.GetStartPosition(); | 1204 pos = m_FileAccess2IFXFont.GetStartPosition(); |
| 1215 while (pos) { | 1205 while (pos) { |
| 1216 uint32_t dwHash; | 1206 uint32_t dwHash; |
| 1217 IFGAS_Font* pFont; | 1207 IFGAS_Font* pFont; |
| 1218 m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont); | 1208 m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pFont); |
| 1219 if (NULL != pFont) { | 1209 if (pFont) |
| 1220 pFont->Release(); | 1210 pFont->Release(); |
| 1221 } | |
| 1222 } | 1211 } |
| 1223 pos = m_IFXFont2FileRead.GetStartPosition(); | 1212 pos = m_IFXFont2FileRead.GetStartPosition(); |
| 1224 while (pos) { | 1213 while (pos) { |
| 1225 IFGAS_Font* pFont; | 1214 IFGAS_Font* pFont; |
| 1226 IFX_FileRead* pFileRead; | 1215 IFX_FileRead* pFileRead; |
| 1227 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); | 1216 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); |
| 1228 pFileRead->Release(); | 1217 pFileRead->Release(); |
| 1229 } | 1218 } |
| 1230 } | 1219 } |
| 1231 void CFGAS_FontMgrImp::RemoveFont(IFGAS_Font* pEFont) { | 1220 void CFGAS_FontMgrImp::RemoveFont(IFGAS_Font* pEFont) { |
| 1232 if (NULL == pEFont) { | 1221 if (!pEFont) |
| 1233 return; | 1222 return; |
| 1234 } | 1223 |
| 1235 IFX_FileRead* pFileRead; | 1224 IFX_FileRead* pFileRead; |
| 1236 if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { | 1225 if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { |
| 1237 pFileRead->Release(); | 1226 pFileRead->Release(); |
| 1238 m_IFXFont2FileRead.RemoveKey(pEFont); | 1227 m_IFXFont2FileRead.RemoveKey(pEFont); |
| 1239 } | 1228 } |
| 1240 FX_POSITION pos; | 1229 FX_POSITION pos; |
| 1241 pos = m_FileAccess2IFXFont.GetStartPosition(); | 1230 pos = m_FileAccess2IFXFont.GetStartPosition(); |
| 1242 while (pos) { | 1231 while (pos) { |
| 1243 uint32_t dwHash; | 1232 uint32_t dwHash; |
| 1244 IFGAS_Font* pCFont; | 1233 IFGAS_Font* pCFont; |
| 1245 m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pCFont); | 1234 m_FileAccess2IFXFont.GetNextAssoc(pos, dwHash, pCFont); |
| 1246 if (pCFont == pEFont) { | 1235 if (pCFont == pEFont) { |
| 1247 m_FileAccess2IFXFont.RemoveKey(dwHash); | 1236 m_FileAccess2IFXFont.RemoveKey(dwHash); |
| 1248 break; | 1237 break; |
| 1249 } | 1238 } |
| 1250 } | 1239 } |
| 1251 pos = m_Hash2Fonts.GetStartPosition(); | 1240 pos = m_Hash2Fonts.GetStartPosition(); |
| 1252 while (pos) { | 1241 while (pos) { |
| 1253 uint32_t dwHash; | 1242 uint32_t dwHash; |
| 1254 CFX_ArrayTemplate<IFGAS_Font*>* pFonts; | 1243 CFX_ArrayTemplate<IFGAS_Font*>* pFonts; |
| 1255 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); | 1244 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); |
| 1256 if (NULL != pFonts) { | 1245 if (pFonts) { |
| 1257 for (int32_t i = 0; i < pFonts->GetSize(); i++) { | 1246 for (int32_t i = 0; i < pFonts->GetSize(); i++) { |
| 1258 if (pFonts->GetAt(i) == pEFont) { | 1247 if (pFonts->GetAt(i) == pEFont) { |
| 1259 pFonts->SetAt(i, NULL); | 1248 pFonts->SetAt(i, nullptr); |
| 1260 } | 1249 } |
| 1261 } | 1250 } |
| 1262 } else { | 1251 } else { |
| 1263 m_Hash2Fonts.RemoveKey(dwHash); | 1252 m_Hash2Fonts.RemoveKey(dwHash); |
| 1264 } | 1253 } |
| 1265 } | 1254 } |
| 1266 } | 1255 } |
| 1267 | 1256 |
| 1268 void CFGAS_FontMgrImp::RegisterFace(FXFT_Face pFace, | 1257 void CFGAS_FontMgrImp::RegisterFace(FXFT_Face pFace, |
| 1269 CFX_FontDescriptors& Fonts, | 1258 CFX_FontDescriptors& Fonts, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 } | 1334 } |
| 1346 } | 1335 } |
| 1347 return flag; | 1336 return flag; |
| 1348 } | 1337 } |
| 1349 #define GetUInt8(p) ((uint8_t)((p)[0])) | 1338 #define GetUInt8(p) ((uint8_t)((p)[0])) |
| 1350 #define GetUInt16(p) ((uint16_t)((p)[0] << 8 | (p)[1])) | 1339 #define GetUInt16(p) ((uint16_t)((p)[0] << 8 | (p)[1])) |
| 1351 #define GetUInt32(p) \ | 1340 #define GetUInt32(p) \ |
| 1352 ((uint32_t)((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])) | 1341 ((uint32_t)((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])) |
| 1353 void CFGAS_FontMgrImp::GetNames(const uint8_t* name_table, | 1342 void CFGAS_FontMgrImp::GetNames(const uint8_t* name_table, |
| 1354 CFX_WideStringArray& Names) { | 1343 CFX_WideStringArray& Names) { |
| 1355 if (NULL == name_table) { | 1344 if (!name_table) |
| 1356 return; | 1345 return; |
| 1357 } | 1346 |
| 1358 uint8_t* lpTable = (uint8_t*)name_table; | 1347 uint8_t* lpTable = (uint8_t*)name_table; |
| 1359 CFX_WideString wsFamily; | 1348 CFX_WideString wsFamily; |
| 1360 uint8_t* sp = lpTable + 2; | 1349 uint8_t* sp = lpTable + 2; |
| 1361 uint8_t* lpNameRecord = lpTable + 6; | 1350 uint8_t* lpNameRecord = lpTable + 6; |
| 1362 uint16_t nNameCount = GetUInt16(sp); | 1351 uint16_t nNameCount = GetUInt16(sp); |
| 1363 uint8_t* lpStr = lpTable + GetUInt16(sp + 2); | 1352 uint8_t* lpStr = lpTable + GetUInt16(sp + 2); |
| 1364 for (uint16_t j = 0; j < nNameCount; j++) { | 1353 for (uint16_t j = 0; j < nNameCount; j++) { |
| 1365 uint16_t nNameID = GetUInt16(lpNameRecord + j * 12 + 6); | 1354 uint16_t nNameID = GetUInt16(lpNameRecord + j * 12 + 6); |
| 1366 if (nNameID != 1) { | 1355 if (nNameID != 1) { |
| 1367 continue; | 1356 continue; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 #define CODEPAGERANGE_IMPLEMENT(n) \ | 1440 #define CODEPAGERANGE_IMPLEMENT(n) \ |
| 1452 for (int32_t i = 0; i < 16; i++) { \ | 1441 for (int32_t i = 0; i < 16; i++) { \ |
| 1453 if ((a##n & g_FX_Bit2Charset##n[i].wBit) != 0) { \ | 1442 if ((a##n & g_FX_Bit2Charset##n[i].wBit) != 0) { \ |
| 1454 Charsets.Add(g_FX_Bit2Charset##n[i].wCharset); \ | 1443 Charsets.Add(g_FX_Bit2Charset##n[i].wCharset); \ |
| 1455 } \ | 1444 } \ |
| 1456 } | 1445 } |
| 1457 void CFGAS_FontMgrImp::GetCharsets(FXFT_Face pFace, | 1446 void CFGAS_FontMgrImp::GetCharsets(FXFT_Face pFace, |
| 1458 CFX_ArrayTemplate<uint16_t>& Charsets) { | 1447 CFX_ArrayTemplate<uint16_t>& Charsets) { |
| 1459 Charsets.RemoveAll(); | 1448 Charsets.RemoveAll(); |
| 1460 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); | 1449 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); |
| 1461 if (NULL != pOS2) { | 1450 if (pOS2) { |
| 1462 uint16_t a1, a2, a3, a4; | 1451 uint16_t a1, a2, a3, a4; |
| 1463 a1 = pOS2->ulCodePageRange1 & 0x0000ffff; | 1452 a1 = pOS2->ulCodePageRange1 & 0x0000ffff; |
| 1464 CODEPAGERANGE_IMPLEMENT(1); | 1453 CODEPAGERANGE_IMPLEMENT(1); |
| 1465 a2 = (pOS2->ulCodePageRange1 >> 16) & 0x0000ffff; | 1454 a2 = (pOS2->ulCodePageRange1 >> 16) & 0x0000ffff; |
| 1466 CODEPAGERANGE_IMPLEMENT(2); | 1455 CODEPAGERANGE_IMPLEMENT(2); |
| 1467 a3 = pOS2->ulCodePageRange2 & 0x0000ffff; | 1456 a3 = pOS2->ulCodePageRange2 & 0x0000ffff; |
| 1468 CODEPAGERANGE_IMPLEMENT(3); | 1457 CODEPAGERANGE_IMPLEMENT(3); |
| 1469 a4 = (pOS2->ulCodePageRange2 >> 16) & 0x0000ffff; | 1458 a4 = (pOS2->ulCodePageRange2 >> 16) & 0x0000ffff; |
| 1470 CODEPAGERANGE_IMPLEMENT(4); | 1459 CODEPAGERANGE_IMPLEMENT(4); |
| 1471 } else { | 1460 } else { |
| 1472 Charsets.Add(FX_CHARSET_Default); | 1461 Charsets.Add(FX_CHARSET_Default); |
| 1473 } | 1462 } |
| 1474 } | 1463 } |
| 1475 #undef CODEPAGERANGE_IMPLEMENT | 1464 #undef CODEPAGERANGE_IMPLEMENT |
| 1476 void CFGAS_FontMgrImp::GetUSBCSB(FXFT_Face pFace, | 1465 void CFGAS_FontMgrImp::GetUSBCSB(FXFT_Face pFace, |
| 1477 uint32_t* USB, | 1466 uint32_t* USB, |
| 1478 uint32_t* CSB) { | 1467 uint32_t* CSB) { |
| 1479 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); | 1468 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); |
| 1480 if (NULL != pOS2) { | 1469 if (pOS2) { |
| 1481 USB[0] = pOS2->ulUnicodeRange1; | 1470 USB[0] = pOS2->ulUnicodeRange1; |
| 1482 USB[1] = pOS2->ulUnicodeRange2; | 1471 USB[1] = pOS2->ulUnicodeRange2; |
| 1483 USB[2] = pOS2->ulUnicodeRange3; | 1472 USB[2] = pOS2->ulUnicodeRange3; |
| 1484 USB[3] = pOS2->ulUnicodeRange4; | 1473 USB[3] = pOS2->ulUnicodeRange4; |
| 1485 CSB[0] = pOS2->ulCodePageRange1; | 1474 CSB[0] = pOS2->ulCodePageRange1; |
| 1486 CSB[1] = pOS2->ulCodePageRange2; | 1475 CSB[1] = pOS2->ulCodePageRange2; |
| 1487 } else { | 1476 } else { |
| 1488 USB[0] = 0; | 1477 USB[0] = 0; |
| 1489 USB[1] = 0; | 1478 USB[1] = 0; |
| 1490 USB[2] = 0; | 1479 USB[2] = 0; |
| 1491 USB[3] = 0; | 1480 USB[3] = 0; |
| 1492 CSB[0] = 0; | 1481 CSB[0] = 0; |
| 1493 CSB[1] = 0; | 1482 CSB[1] = 0; |
| 1494 } | 1483 } |
| 1495 } | 1484 } |
| 1496 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, | 1485 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, |
| 1497 const CFX_WideString& Name2) { | 1486 const CFX_WideString& Name2) { |
| 1498 if (Name1.Find(Name2.c_str()) != -1) { | 1487 if (Name1.Find(Name2.c_str()) != -1) { |
| 1499 return 1; | 1488 return 1; |
| 1500 } | 1489 } |
| 1501 return 0; | 1490 return 0; |
| 1502 } | 1491 } |
| 1503 #endif | 1492 #endif |
| OLD | NEW |