void* CFX_LinuxFontInfo::FindFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* family, FX_BOOL bMatchName) { CFX_FontFaceInfo* pFind = NULL; FX_DWORD charset_flag = _LinuxGetCharset(charset); int32_t iBestSimilar = 0; for (const auto& it : m_FontList) { const CFX_ByteString& bsName = it.first; CFX_FontFaceInfo* pFont = it.second; if (!(pFont->m_Charsets & charset_flag) && charset != FXFONT_DEFAULT_CHARSET) { continue; } int32_t iSimilarValue = 0; int32_t index = bsName.Find(family); if (bMatchName && index < 0) { continue; } if (!bMatchName && index > 0) { iSimilarValue += 64; } iSimilarValue = _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFont->m_Styles); if (iSimilarValue > iBestSimilar) { iBestSimilar = iSimilarValue; pFind = pFont; } } return pFind; }
void* CFX_LinuxFontInfo::FindFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* family, FX_BOOL bMatchName) { CFontFaceInfo* pFind = NULL; FX_DWORD charset_flag = _LinuxGetCharset(charset); int32_t iBestSimilar = 0; FX_POSITION pos = m_FontList.GetStartPosition(); while (pos) { CFX_ByteString bsName; CFontFaceInfo* pFont = NULL; m_FontList.GetNextAssoc(pos, bsName, (void*&)pFont); if (!(pFont->m_Charsets & charset_flag) && charset != FXFONT_DEFAULT_CHARSET) { continue; } int32_t iSimilarValue = 0; int32_t index = bsName.Find(family); if (bMatchName && index < 0) { continue; } if (!bMatchName && index > 0) { iSimilarValue += 64; } iSimilarValue = _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFont->m_Styles); if (iSimilarValue > iBestSimilar) { iBestSimilar = iSimilarValue; pFind = pFont; } } return pFind; }