int32_t CXFA_WideTextRead::ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS) { iMaxLength = std::min(iMaxLength, m_wsBuffer.GetLength() - m_iPosition); if (iMaxLength == 0) return 0; FXSYS_wcsncpy(pStr, m_wsBuffer.c_str() + m_iPosition, iMaxLength); m_iPosition += iMaxLength; bEOS = IsEOF(); return iMaxLength; }
static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts, const FX_WCHAR* pwsFaceName, FX_WCHAR wUnicode) { HDC hDC = ::GetDC(nullptr); LOGFONTW lfFind; FXSYS_memset(&lfFind, 0, sizeof(lfFind)); lfFind.lfCharSet = DEFAULT_CHARSET; if (pwsFaceName) { FXSYS_wcsncpy(lfFind.lfFaceName, pwsFaceName, 31); lfFind.lfFaceName[31] = 0; } EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); ::ReleaseDC(nullptr, hDC); }
static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe, NEWTEXTMETRICEX* lpntme, DWORD dwFontType, LPARAM lParam) { if (dwFontType != TRUETYPE_FONTTYPE) return 1; const LOGFONTW& lf = ((LPENUMLOGFONTEXW)lpelfe)->elfLogFont; if (lf.lfFaceName[0] == L'@') return 1; FX_FONTDESCRIPTOR* pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1); FXSYS_memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR)); pFont->uCharSet = lf.lfCharSet; pFont->dwFontStyles = FX_GetGdiFontStyles(lf); FXSYS_wcsncpy(pFont->wsFontFace, (const FX_WCHAR*)lf.lfFaceName, 31); pFont->wsFontFace[31] = 0; FXSYS_memcpy(&pFont->FontSignature, &lpntme->ntmFontSig, sizeof(lpntme->ntmFontSig)); ((CFX_FontDescriptors*)lParam)->Add(*pFont); FX_Free(pFont); return 1; }