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

GetFamily

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

描述

 

获取基于该字体的字体系列.

 

C++ Syntax

 

Status GetFamily(

[out]  FontFamily* family

) const;

 

FreeBASIC 语法

 

FUNCTION GetFamily ( _

   BYVAL pFamily AS CGpFontFamily PTR _

) AS GpStatus

 

参数

 

pFamily

 

[in]指向FontFamily对象接收字体.

 

返回值

 

如果该方法成功,则返回Ok,这是对Status枚举元素.

如果这个方法失败,它返回一个枚举的其他元素的Status.

 

引用文件

 

CGpFont.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a Font object, retrieves the information about the font

' family on which it is based, and then uses the FontFamily object to create a second Font

' object. The example then uses the second Font object to draw text.

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

SUB Example_GetFamily (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.

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

 

  ' // Get the FontFamily of myFont.

  DIM fontFamily AS CGpFontFamily

  font.GetFamily(@fontFamily)

 

  ' // Create a new Font object from fontFamily.

  DIM familyFont AS CGpFont = CGpFont(@fontFamily, AfxPointsToPixelsX(16) / rxRatio)

 

  ' // Draw Text with familyFont

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

  DIM wszText AS WSTRING * 260 = "This is a Font created from a FontFamily"

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

 

END SUB

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