描述
获取指定样式或样式组合的此字体家族的单元格提升(在设计单位).
C++ Syntax
UINT16 GetCellAscent( [in] INT style ) const; |
FreeBASIC 语法
FUNCTION GetCellAscent ( _ 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 cell ascent in design units,
' and outputs the value as text.
' ========================================================================================
SUB Example_GetCellAscent (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 ascentFontFamily AS CGpFontFamily = "arial"
' // Get the cell ascent of the font family in design units
DIM cellAscent AS LONG = ascentFontFamily.GetCellAscent(FontStyleRegular)
' // Copy the cell ascent into a string and draw the string
DIM solidBrush AS CGpSolidBrush = GDIP_ARGB(255, 0, 0, 0)
DIM font AS CGpFont = CGpFont(@ascentFontFamily, AfxPointsToPixelsX(16) / rxRatio)
DIM wszText AS WSTRING * 260
wszText = "ascentFontFamily.GetCellAscent() returns " & STR(cellAscent)
graphics.DrawString(@wszText, -1, @font, 0, 0, @solidbrush)
END SUB
' ========================================================================================


