CreateFont detailed explanation

Source: Internet
Author: User


CFont * F;
f = new CFont;
F->createfont (Ten,//nheight
0,//nwidth
0,//nescapement
0,//norientation
Fw_bold,//Nweight
FALSE,//Bitalic
FALSE,//Bunderline
0,//cstrikeout
Ansi_charset,//Ncharset
Out_default_precis,//Noutprecision
Clip_default_precis,//Nclipprecision
Default_quality,//Nquality
Default_pitch | Ff_swiss,//npitchandfamily
_t ("Arial")); Lpszfac

Cheight is the height of the font.
Cwidth is the width of the font.
Cescapement is the tilt angle of the font.


Corientation is the tilt angle of the font.
Cweight is the weight of the font.
Bitalic is whether the font is italic.
Bunderline is whether the font has an underscore.
Bstrikeout is whether the font has strikethrough.


Icharset is the character set used by the font.


Ioutprecision is to specify how to select the appropriate font.
The iclipprecision is used to determine the precision of the cropping.
Iquality is how to match the chosen font.
Ipitchandfamily is the spacing flag and attribute flags.


Pszfacename is the name of the font.


function function: This function creates a special logical font that can be selected at a later time, regardless of the device.

Function prototypes: Hfont createfont (int nheight, int nwidth, int nescapement, int norientation, int fnweight, DWORD fdwltalic, DWORD FDW Underline, DWORD Fdwstrikeout, DWORD

Fdwcharset, DWORD Fdwoutputprecision, DWORD Fdwclipprecision, DWORD fdwquality, DWORD fdwpitchandfamily, LPCTSTR Lpszface).

Number of references:

Nheight: Specifies the logical unit height of the character cell or character of the font, the height value of the character (also called Em height), which is the character cell height minus the internal header value.

The font mapper interprets the values specified by the nheight, as in the following ways, meaning

For:

>0: The font mapper converts this value in device units and matches the cell height of the existing font.

0: The font mapper conversion uses a default height value when selecting a match.

<0: The font mapper converts this value to device units. and matches its absolute value to the character height of the existing font.

The font mapper chooses a maximum font size that is not larger than the full height.

This mapping occurs when the font is used for the first time.

For the Mm_text mapping method. You can determine the height of a font that specifies a point size using the following formula:

Nheight=-muldiv (Pointsize, GetDeviceCaps (HDC, Logpixelsy), 72)

Nwidth: Specifies the average width of the logical units of characters for the requested font.

Assuming this value is 0, the font mapper chooses a closest match value, and the closest match value is a digitized feature of the current device's feature factor and the available font

Determined by the absolute value of the difference between the coefficients.

Nescapement: Specifies an angle between the shift vector and the x-axis of the device, in a very moderate degree. The shift vector is parallel to the baseline of the body line.

Windows NT: Specifies the shift angle of a string when the graphics device is set to gm_advanced and can be positioned without relying on the character of the string.

When the graphics mode is set to Gm_compatible, nescapement specifies the shift angle and the location angle at the same time, and can set nescapement and norientation to the same value.

Windows 95:nescapement Specifies the shift angle and the location angle at the same time, you can set nescapement and norientation to the same value.

Norientation: Specifies the angle between the baseline of each character and the x-axis of the device.

Fnweight: Specifies the weight of the font between 0 and 1000, such as 400 for the standard body and 700 for the black (thick) body, assuming this value is 0, the default weight is used.

For ease of definition. You can use the following values, for example:

Fw_dontcare:0;fw_thin. 100;fw_extralight;200;fw_ultralight;200;fw_light. 300;

fw_normal:400;fw_regular;400. fw_medium;500;fw_semibold;600. fw_demibold;600.

fw_bold:700;fw_extrabold;800;fw_ultrabold;800;fw_heavy;900;fw_black;900.

Fdwitalic: Specifies italic if set to true.

Fdwunderline: The assumption is set to true. Specifies that the underlined word is all.

Fdwstrikeout: The assumption is set to true. The strikeout specifies the font.

Fdwcharset: Specifies the character set. The following values are defined in advance:

Ansi_charset; Baltic_charset; Chinesebig5_charset; Default_charset;

Easteurope_charset; Gb2312_charset; Greek_charset; Hangul_charset; Mac_charset; Oem_charset; Russian_charset; Shiftjis_charset;

Symbol_charset; Turkish_charset.

Korea Windows:johab_charset;

Middle East Windows:hebrew_charsset; Arabic_charset

Windows:thai_charset Thailand

OEM_CHARSET Specifies the character set associated with the operating system.

The ability to use the Default_charset value to agree on the name and size of the font to fully describe the narrative logical font. Assume that the specified font name does not exist. Regardless of the character set font can be substituted for the specified font, so be careful to use

Default_charset to avoid unexpected results.

There are other character set fonts in the operating system. If an application uses a font of an unknown character set, the application does not attempt to translate or interpret a string written in that font.

This parameter is important in the font mapping process. To ensure that consistent results are achieved. Specifies a special character set. Assume that a font name is specified in the Lpszface parameter to determine whether the Fdwcharset value and the font character set specified by Lpszface are

With.

Fdwoutputprecision: Specifies the output precision, the output precision of the output with the required font height, width, character positioning, shift, character spacing and character type matching program, it is preferable to one of the following values:

Out_character_precis. Not used.

Out_default_precis: Specifies the default font mapper state.

Out_device_precis: Indicates that the font mapper selects a device font when there are multiple fonts in the system that use the same name in the same font.

Out_outline_prcis: This value in Windows NT indicates that the font mapper is selected from TrueType and other border-based fonts.

Out_raster_precis: Indicates that the font mapper chooses a raster font when there are multiple fonts in the system that use the same name.

Out_string_precis: This value is not used by the word full mapper. However, when the scanned font is enumerated as the return value.

Out_stroke_precis: This value is not used by the font mapper in Windows NT, but is the return value when TrueType fonts, other border-based fonts, and vector fonts are enumerated.

Windows 95: This value is not used by the font mapper. However, when TrueType fonts or vector fonts are enumerated. As the return value.

Out_tt_only_precis: Indicates that the font mapper is selected only from a TrueType font, and the font mapping returns the default state if no TrueType fonts are installed on the system. 、

Out_tt_precis: Indicates that the font mapper chooses a TrueType font when there are multiple fonts with the same name in the system.

When the operating system contains multiple fonts with the same name as the specified names. Applications can use Out_device_precis,out_raster_precis and Out_tt_precis values to control how the font mapper chooses a font, for example,

Assuming the operating system contains a raster of name symbol and TrueType two fonts, specify OUT_TT_PRECIS to make the font mapper select TrueType mode. Specifies that Out_tt_only_precis causes the font mapper to select a TrueType font.

Although this will give the TrueType font a name.

Fdwclipprecision; Specifies the clipping precision. Crop precision defines how to crop a character that is partially out of the clipping area, and it can have one or more of the following values:

Clip_default_precis: Specifies the default cropping state. Clip_character_precis: Not used.

Clip_stroke_precis: Not used by font mapper, but as a return value when raster fonts, vector fonts, or TrueType fonts are enumerated.

In the Windows environment. To ensure compatibility. This value is always returned when the font is enumerated.

Clip_mask: Not used. Clip_embedded: You must use this flag to use embedded read-only fonts.

Clip_lh_angles: When this value is used, the rotation of all fonts depends on whether the coordinate system is positioned in the left or right direction.

Assuming this value is not used, the device font always rotates counterclockwise, but the rotation of other fonts depends on the orientation of the coordinate system. To get a lot of other information about the orientation of the coordinate system, refer to the number of orientation.

Clip_tt_always: Not used.

Fdwquality: point to output quality. Output quality defines how the GDI carefully matches the logical font attributes to the actual physical font attributes. It is preferable to one of the following values:

Default_quality: The appearance of the font is not important.

Draft_quality: The importance of font appearance is greater than when using proof_quality, the scaling is active for GDI raster fonts, which means that there are multiple font sizes to choose from. But the quality may not be high. If necessary, bold, italic

, underline, strikeout fonts can be combined to use.

Proof_quality: Character quality is more important than exactly matching logical font font attributes.

For GDI scan fonts, the scale is active and the closest size is selected.

Although when proof_quality is used. Select font size is not complete

Full match, but the quality of the font is very high. And there is no appearance on the deformation.

If necessary, bold, italic, underline, strikeout fonts can be used in a comprehensive style.

Fdwpitchandfamily: Specifies the font spacing and font family. Low end two-bit specifies the character spacing of the font, which is one of the following values:

Default_pitch. Fixed_pitch; Variable_pitch

High-end four-bit specified font family, one of the following values is desirable:

Ff_decorative: Fresh fonts. such as older English.

Ff_dontcare: Do not care or do not know.

Ff_mdern: Stroke width fixed font, with or without liner.

such as Pica, Elite and Courier New.

Ff_roman: The font of the stroke width change, with a lined line. such as Ms Serif.

Ff_script: Designed to look like a handwriting font.

such as script and cursive.

Ff_swiss: The font of the stroke width change. No slash. such as Ms Sans Serif.

An application can combine character spacing and font families with operator or to assign a value to fdwpitchandfamily.

The font family description describes the normal appearance of a font that can be used to specify fonts when all the exact words are not available.

Lpszface: A string pointer ending with/0 that points to the typeface name of the specified font, the length of the string cannot exceed 32 characters (including the character/0), and the function enumfontfamilies can be used to enumerate the typeface names of all currently available fonts.

Assume that lpszface is null or points to an empty string. GDI uses the first font that can match other properties.

Return value: Assuming the function call succeeds, the return value is a logical font handle. Assuming the function call fails, the return value is null.

Windows NT: If you want to get a lot of other error messages. Please call the GetLastError function.

Note: When a font is no longer in use. DeleteObject can be used to delete.

To protect the copyrights of vendors who provide fonts to Windows and Windows NT, WIN32-based applications always list the exact names of the selected fonts.

Because different systems will use different fonts, do not feel that the selected font is to be

The font to be asked.

Like what. Suppose a font called Palatino is required, but the system does not provide a font like that. The font mapper will be replaced with a font that has no name but similar properties. The system total font name is selected by the user for the report.

Quick Search: Windows nt:3.1 above numbers. windows:95 above figures; Windows CE: Not supported. Head: wingdi.h; library files: gdi32.lib;unicode: In Windows NT environment, Unicode and ANSI

Two different ways.


CreateFont detailed explanation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.