描述
确定此字体家族是否可用指定样式.
C++ Syntax
BOOL IsStyleAvailable( [in] INT style ) const; |
FreeBASIC 语法
FUNCTION IsStyleAvailable ( _ BYVAL nStyle AS INT_ _ ) AS BOOLEAN |
参数
nStyle
指定字体样式的整数.该值必须在FontStyle枚举或一位或运算符应用于两种或两种以上的元素的结果的一个元素.例如,fontstylebold或fontstyleunderline或fontstylestrikeout指定组合的三种风格.
返回值
如果样式或组合是可行的,该方法返回TRUE;否则,它返回FALSE.
备注
此方法返回一些第三方字体的误导结果.例如,isstyleavailable(FontStyleUnderline)可能会返回FALSE因为它真的是一个普通风格的字体,也是一个下划线字体的测试:(fontstyleregular或fontstyleunderline).如果字体没有固定的风格,isstyleavailable方法返回FALSE.
引用文件
CGpFontFamily.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a FontFamily object. If the font family has a regular style
' available, the example draws text.
' ========================================================================================
SUB Example_IsStyleAvailable (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 the regular style is available.
DIM isStyleAvailable AS BOOLEAN = myFontFamily.IsStyleAvailable(FontStyleRegular)
' // If regular style is available, draw text.
IF isStyleAvailable 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 in regular style"
graphics.DrawString(@wszText, -1, @font, 0, 0, @solidbrush)
END IF
END SUB
' ========================================================================================


