static FX_BOOL RetrieveSpecificFont(uint8_t charSet, uint8_t pitchAndFamily, LPCSTR pcsFontName, LOGFONTA& lf) { memset(&lf, 0, sizeof(LOGFONTA)); lf.lfCharSet = charSet; lf.lfPitchAndFamily = pitchAndFamily; if (pcsFontName != NULL) { strcpy(lf.lfFaceName, pcsFontName); } return RetrieveSpecificFont(lf); }
static FX_BOOL RetrieveStockFont(int iFontObject, uint8_t charSet, LOGFONTA& lf) { HFONT hFont = (HFONT)::GetStockObject(iFontObject); if (hFont != NULL) { memset(&lf, 0, sizeof(LOGFONTA)); int iRet = ::GetObject(hFont, sizeof(LOGFONTA), &lf); if (iRet > 0 && (lf.lfCharSet == charSet || charSet == 255)) { return RetrieveSpecificFont(lf); } } return FALSE; }
CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { CFX_ByteString csFontName; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ LOGFONTA lf = {}; if (charSet == FXFONT_ANSI_CHARSET) { csFontName = "Helvetica"; return csFontName; } bool bRet = false; if (charSet == FXFONT_SHIFTJIS_CHARSET) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MS Mincho", lf); } else if (charSet == FXFONT_GB2312_CHARSET) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "SimSun", lf); } else if (charSet == FXFONT_CHINESEBIG5_CHARSET) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MingLiU", lf); } if (!bRet) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "Arial Unicode MS", lf); } if (!bRet) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "Microsoft Sans Serif", lf); } if (!bRet) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, nullptr, lf); } if (bRet) { if (pLogFont) memcpy(pLogFont, &lf, sizeof(LOGFONTA)); csFontName = lf.lfFaceName; return csFontName; } #endif return csFontName; }