描述
返回字体大?ㄍǔ3莆狤M大?┱?span style="font-weight: bold;">Font对象.尺寸在这Font对象的单位.
C++ Syntax
REAL GetSize() const; |
FreeBASIC 语法
FUNCTION GetSize () AS SINGLE |
参数
该方法没有参数.
返回值
该方法返回字体大小.尺寸在这Font对象的单位.
引用文件
CGpFont.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a Font object, gets the size of the font, and creates a second
' Font object of the same size as the first. The second Font object is then used to draw text.
' ========================================================================================
SUB Example_GetSize (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 Font object according to the DPI setting
DIM font AS CGpFont = CGpFont("Arial", AfxPointsToPixelsX(16) / rxRatio)
' // Get the size of font
DIM size AS SINGLE = font.GetSize
' // Create a second Font object with the same emSize as myFont.
DIM sizeFont AS CGpFont = CGpFont("Arial", size)
' // Draw text using sizeFont
DIM solidbrush AS CGpSolidBrush = GDIP_ARGB(255, 0, 0, 0)
DIM wszText AS WSTRING * 260 = "Font with an acquired size"
graphics.DrawString(@wszText, -1, @sizeFont, 0, 0, @solidbrush)
END SUB
' ========================================================================================