描述
在设计单位中获取该字体家族的大?ㄍǔ3莆狤M大小或EM高度).
C++ Syntax
UINT16 GetEmHeight( [in] INT style ); |
FreeBASIC 语法
FUNCTION GetEmHeight ( _ BYVAL nStyle AS INT_ _ ) AS UINT16 |
参数
nStyle
[in]整数,指定字体的样式.该值必须在FontStyle枚举或一位或运算符应用于两种或两种以上的元素的结果的一个元素.例如,fontstylebold或fontstyleunderline或fontstylestrikeout指定组合的三种风格.
返回值
此方法返回该字体家族的设计单位的大小.
引用文件
CGpFontFamily.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a FontFamily object, gets the em height in design units,
' and outputs the value as text.
' ========================================================================================
SUB Example_GetEmHeight (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context
DIM graphics AS CGpGraphics = hdc
' // Get the DPI scaling ratio
DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
DIM ryRatio AS SINGLE = graphics.GetDpiY / 96
' // Set the scale transform
graphics.ScaleTransform(rxRatio, ryRatio)
' // Create a FontFamily object
DIM emHeightFontFamily AS CGpFontFamily = "arial"
' // Get the cell ascent of the font family in design units.
DIM emHeight AS LONG = emHeightFontFamily.GetEmHeight(FontStyleRegular)
' // Copy the height into a string and draw the string.
DIM solidBrush AS CGpSolidBrush = GDIP_ARGB(255, 0, 0, 0)
DIM font AS CGpFont = CGpFont(@emHeightFontFamily, AfxPointsToPixelsX(16) / rxRatio)
DIM wszText AS WSTRING * 260
wszText = "emHeightFontFamily.GetEmHeight() returns " & STR(emHeight)
graphics.DrawString(@wszText, -1, @font, 0, 0, @solidbrush)
END SUB
' ========================================================================================


