Win32Prn() > Font methods xHarbour Developers Network  

oWin32Prn:setFont()

Selects the current font.

Syntax

:setFont( <cFontName>   , ;
         [<nPointSize>] , ;
         [<nFontWidth>] , ;
         [<nFontWeight>], ;
         [<lUnderline>] , ;
         [<lItalic>]    , ;
         [<nCharSet>]     ) --> lSuccess

Arguments

<cFontName>
This is a character string holding the name of the font to select as current. It is case sensitive.
<nPointSize>
This is a numeric value indicating the font size in points. If omitted, a default font size is used.
<nFontWidth>
This can be a numeric value indicating the font width in pixels. If omitted, a default font width is used.

Alternatively, a two element array can be passed. It is used to calculate the font width in the unit "Characters Per Inch" (CPI) by dividing the second element by the first element. For example:

   aFontWidth := { 3, 50 }

   nCPI := aFontWidth[2]/aFontWidth[1]

   ? nCPI  // 16.67 characters per inch

When the array {0,0} is passed, the default font width is selected.

Note:  when the second element contains a negative value, fixed character spacing is enforced, even if the font is a proportional font.

<nFontWeight>
This is a numeric value indicating the font weight. If omitted, a default font weight is used. #define constants are available in the file WinGdi.ch that can be used for <nFontWeight>:

Constants for font weights
ConstantValue
FW_DONTCARE0
FW_THIN100
FW_EXTRALIGHT200
FW_LIGHT300
FW_NORMAL400
FW_MEDIUM500
FW_SEMIBOLD600
FW_BOLD700
FW_EXTRABOLD800
FW_HEAVY900

<lUnderline>
This is a logical value specifying the underlined mode of the font. The value .T. (true) switches underlined on, and .F. (false) switches it off. When omitted, the current underlined mode of the Win32Prn object is used.
<lItalic>
This is a logical value specifying the italic mode of the font. The value .T. (true) switches italic on, and .F. (false) switches it off. When omitted, the current italic mode of the Win32Prn object is used.
<nCharSet>
This is a numeric value indicating the character set. If omitted, the current character set of the Win32Prn object is used. #define constants are available in the file WinGdi.ch that can be used for <nCharSet>:

Constants for character sets
ConstantValue
ANSI_CHARSET0
DEFAULT_CHARSET *)1
SYMBOL_CHARSET2
SHIFTJIS_CHARSET128
HANGEUL_CHARSET129
HANGUL_CHARSET129
GB2312_CHARSET134
CHINESEBIG5_CHARSET136
OEM_CHARSET255
JOHAB_CHARSET130
HEBREW_CHARSET177
ARABIC_CHARSET178
GREEK_CHARSET161
TURKISH_CHARSET162
VIETNAMESE_CHARSET163
THAI_CHARSET222
EASTEUROPE_CHARSET238
RUSSIAN_CHARSET204

Description

Method :setFont() selects the current font. This font is used by methods :textOut() or :textOutAt() for printing text. When the font with the desired properties exists and can be selected, the method returns .T. (true). Note that the operating system may select a font that does not match the passed parameters exactly, but chooses a "best fit" font instead.

Use method :getFonts() to obtain a font information array holding data of all fonts available.


Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe