导航:  GdiPlus Classes > GdiPlus Classes > CGpFont Class > Font Object >

IsAvailable

上一页返回章节概述下一页

描述

 

决定这是否Font对象创建成功.

 

C++ Syntax

 

BOOL IsAvailable() const;

 

FreeBASIC 语法

 

FUNCTION IsAvailable () AS BOOLEAN

 

参数

 

该方法没有参数.

 

返回值

 

如果字体构建成功,此方法将返回TRUE;否则,它返回FALSE.

 

引用文件

 

CGpFont.inc (include CGdiPlus.inc)

 

示例

 

' ========================================================================================

' The following example creates a Font object and then tests whether the Font object is

' available. If the Font object is available, it is used to draw 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 Font object according to the DPI setting

  DIM font AS CGpFont = CGpFont("Arial", AfxPointsToPixelsX(18) / rxRatio)

 

  ' // Check whether font is available

  DIM available AS BOOLEAN = font.IsAvailable

 

  ' // Draw text using font, if it is availiable

  IF available THEN

     DIM solidbrush AS CGpSolidBrush = GDIP_ARGB(255, 0, 0, 0)

     DIM wszText AS WSTRING * 260 = "Here is some text"

     graphics.DrawString(@wszText, -1, @font, 0, 0, @solidbrush)

  END IF

 

END SUB

' ========================================================================================