FontFamily fontFamily(szFaceName/*(WCHAR*)strFaceName.GetBuffer()*/); Font font(&fontFamily, (REAL)m_txLogFont.lfHeight, FontStyleRegular, UnitPixel); // 文本 UINT ascent; REAL ascentPixel; UINT descent; REAL descentPixel; UINT lineSpacing; REAL lineSpacingPixel; // 获取 字体上部距离 ascent = fontFamily.GetCellAscent(FontStyleRegular); // 转换为像素单位 ascentPixel = font.GetSize()*ascent/fontFamily.GetEmHeight(FontStyleRegular); // 获取字体下部距离 descent = fontFamily.GetCellDescent(FontStyleRegular); // 转换为像素单位 descentPixel = font.GetSize()*descent/fontFamily.GetEmHeight(FontStyleRegular); // 获取字体行距 lineSpacing = fontFamily.GetLineSpacing(FontStyleRegular); // 转换为像素单位 lineSpacingPixel = font.GetSize()*lineSpacing/fontFamily.GetEmHeight(FontStyleRegular); // 计算输出文本间行距 REAL rSpaceLine = lineSpacingPixel - ascentPixel - descentPixel;

评论