导航:  GdiPlus Classes > GdiPlus Classes > CGpFontFamilly Class > FontFamily Object >

Clone

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

描述

 

现有FontFamily对象的内容到一个新的FontFamily对象.

 

C++ Syntax

 

FontFamily* Clone();

 

FreeBASIC 语法

 

FUNCTION Clone ( _

   BYVAL pFontFamily AS CGpBrush PTR _

) AS GpStatus

 

参数

 

pFontFamily

 

一个变量,将获得一个指向对象的指针FontFamily克隆.

 

返回值

 

如果函数执行成功,则返回Ok,这是对Status枚举元素.

如果函数失败,则返回一个枚举的其他元素的Status.

 

引用文件

 

CGpFontFamily.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a FontFamily object, clones that object, and then creates

' a Font object from the clone. It then uses the Font object to draw text.

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

SUB Example_CloneFontFamily (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 arialFontFamily AS CGpFontFamily = "arial"

 

  ' // Clone the FontFamily object and use it to create a Font object

  DIM cloneFontFamily AS CGpFontFamily

  arialFontFamily.Clone(@cloneFontFamily)

  DIM arialFont AS CGpFont = CGpFont(@cloneFontFamily, AfxPointsToPixelsX(16) / rxRatio)

 

  ' // Draw text using the new font

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

  graphics.DrawString("This is an Arial font", -1, @arialFont, 0, 0, @solidbrush)

 

END SUB

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