We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GdiplusDrawText函数中用Gdiplus::Font font(hDC, pManager->GetFont(iFont));创建字体,它创建出来的字体GetUnit拿到的值是UnitWorld,我们实际绘制的时候都是用UnitPixel,这样会照成部分电脑上绘制的文本异常。需要改造成:
// 获取HFONT的LOGFONT LOGFONT logFont; GetObject(pManager->GetFont(iFont), sizeof(LOGFONT), &logFont); // 创建一个FontFamily对象 Gdiplus::FontFamily fontFamily(logFont.lfFaceName); // 获取字体大小,注意这是以设备无关的逻辑单位,一般为像素 Gdiplus::REAL fontSize = static_castGdiplus::REAL(abs(logFont.lfHeight)); // 用将LOGFONT的样式转换成Gdiplus的样式 INT fontStyle = Gdiplus::FontStyleRegular; if (logFont.lfWeight > FW_NORMAL) fontStyle |= Gdiplus::FontStyleBold; if (logFont.lfItalic) fontStyle |= Gdiplus::FontStyleItalic; if (logFont.lfUnderline) fontStyle |= Gdiplus::FontStyleUnderline; if (logFont.lfStrikeOut) fontStyle |= Gdiplus::FontStyleStrikeout; // 创建新的Gdiplus::Font对象 Gdiplus::Font font(&fontFamily, fontSize, fontStyle, Gdiplus::UnitPixel);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
GdiplusDrawText函数中用Gdiplus::Font font(hDC, pManager->GetFont(iFont));创建字体,它创建出来的字体GetUnit拿到的值是UnitWorld,我们实际绘制的时候都是用UnitPixel,这样会照成部分电脑上绘制的文本异常。需要改造成:
// 获取HFONT的LOGFONT
LOGFONT logFont;
GetObject(pManager->GetFont(iFont), sizeof(LOGFONT), &logFont);
// 创建一个FontFamily对象
Gdiplus::FontFamily fontFamily(logFont.lfFaceName);
// 获取字体大小,注意这是以设备无关的逻辑单位,一般为像素
Gdiplus::REAL fontSize = static_castGdiplus::REAL(abs(logFont.lfHeight));
// 用将LOGFONT的样式转换成Gdiplus的样式
INT fontStyle = Gdiplus::FontStyleRegular;
if (logFont.lfWeight > FW_NORMAL) fontStyle |= Gdiplus::FontStyleBold;
if (logFont.lfItalic) fontStyle |= Gdiplus::FontStyleItalic;
if (logFont.lfUnderline) fontStyle |= Gdiplus::FontStyleUnderline;
if (logFont.lfStrikeOut) fontStyle |= Gdiplus::FontStyleStrikeout;
// 创建新的Gdiplus::Font对象
Gdiplus::Font font(&fontFamily, fontSize, fontStyle, Gdiplus::UnitPixel);
The text was updated successfully, but these errors were encountered: