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

GetLineSpacing

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

描述

 

获取指定样式或样式组合的该字体家族的设计单位的行间距.行间距是连续两行文本的基线之间的垂直距离.

 

C++ Syntax

 

UINT16 GetLineSpacing(

[in]  INT style

) const;

 

FreeBASIC 语法

 

FUNCTION GetLineSpacing ( _

   BYVAL nStyle AS INT_ _

) AS UINT16

 

参数

 

nStyle

 

[in]整数,指定字体的样式.该值必须在FontStyle枚举或一位或运算符应用于两种或两种以上的元素的结果的一个元素.例如,fontstylebold或fontstyleunderline或fontstylestrikeout指定组合的三种风格.

 

返回值

 

此方法返回此字体家族的行间距.

 

引用文件

 

CGpFontFamily.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a FontFamily object, gets the line spacing in design units,

' and outputs the value as text.

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

SUB Example_GetLineSpacing (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 lineSpacingFontFamily AS CGpFontFamily = "arial"

 

  ' // Get the cell ascent of the font family in design units.

  DIM lineSpacing AS LONG = lineSpacingFontFamily.GetLineSpacing(FontStyleRegular)

 

  ' // Copy the line spacing into a string and draw the string.

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

  DIM font AS CGpFont = CGpFont(@lineSpacingFontFamily, AfxPointsToPixelsX(16) / rxRatio)

  DIM wszText AS WSTRING * 260 = "lineSpacingFontFamily.GetLineSpacing() returns " & STR(lineSpacing)

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

 

END SUB

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