描述
决定这是否Font对象创建成功.
C++ Syntax
BOOL IsAvailable() const; |
FreeBASIC 语法
FUNCTION IsAvailable () AS BOOLEAN |
参数
该方法没有参数.
返回值
如果字体构建成功,此方法将返回TRUE;否则,它返回FALSE.
引用文件
CGpFontFamily.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a FontFamily object. If the FontFamily object is created
' successfully, the example draws text.
' ========================================================================================
SUB Example_IsAvailable (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 myFontFamily AS CGpFontFamily = "arial"
' // Check to see if myFontFamily is available.
DIM isAvailable AS BOOLEAN = myFontFamily.IsAvailable
' // If myFontFamily is available, draw text.
IF isAvailable THEN
DIM solidBrush AS CGpSolidBrush = GDIP_ARGB(255, 0, 0, 0)
DIM font AS CGpFont = CGpFont(@myFontFamily, AfxPointsToPixelsX(16) / rxRatio)
DIM wszText AS WSTRING * 260 = "myFontFamily is available"
graphics.DrawString(@wszText, -1, @font, 0, 0, @solidbrush)
END IF
END SUB
' ========================================================================================


