考虑DPI映射比例,LOGFONT::lfHeight单位是像素; CHARFORMAT2::yHeight单位是1/1440英寸或1/567厘米(现实长度。
必须根据DC的映射模式换算到实际DC中的像素值。
HDC hDC = ::GetDC(NULL);
lfHeight = yHeight * (GetDeviceCaps(hDC, LOGPIXELSY)/1440)。
yHeight = abs(lfHeight ) *(1440/GetDeviceCaps(hDC, LOGPIXELSY));
————————————————
yHeight Specifies the character height, in twips (1/1440 of an inch, or 1/20 of a printer's point). To use this member, set the CFM_SIZE flag in the dwMask member.
10号字对应 CHARFORMAT2.yHeight应该是200 11号是220 缇(Twips):计量单位,等于“磅”的 1/20
原文链接:https://blog.csdn.net/chenzhisi/article/details/39990513