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

GetStyle

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

描述

 

返回字体大?ㄍǔ3莆狤M大?┱?span style="font-weight: bold;">Font对象.尺寸在这Font对象的单位.

 

C++ Syntax

 

REAL GetSize() const;

 

FreeBASIC 语法

 

FUNCTION GetStyle () AS INT_

 

参数

 

该方法没有参数.

 

返回值

 

该方法返回字体大小.尺寸在这Font对象的单位.

 

引用文件

 

CGpFont.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a Font object, gets the FontStyle associated with the font,

' and creates a second Font object by using the same style. The second Font object is then

' used to draw text.

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

SUB Example_GetStyle (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(16) / rxRatio, FontStyleItalic)

 

  ' // Get the style of font

  DIM style AS SINGLE = font.GetStyle

 

  ' // Create a second Font object with the same emSize as myFont.

  DIM styleFont AS CGpFont = CGpFont("Arial", AfxPointsToPixelsX(20) / rxRatio, style)

 

  ' // Draw text using sizeFont

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

  DIM wszText AS WSTRING * 260 = "Font with an acquired style"

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

 

END SUB

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