One-day training of Windows APIs (28) createfont Function

Source: Internet
Author: User
The appearance history of the text can be traced back to the use of Oracle, and the use of the text until today. In software development, cross-country languages are often used. Because the world is flattening, the world is becoming smaller, and transportation is very developed, in Shenzhen where I am located, A 12-hour flight to the east can arrive in London, and a 12-hour flight to the West can arrive in the United States. For example, foreign currency speculators can work all day without having to go to bed. For example, in the morning, they can speculate in Tokyo, in the afternoon, they can speculate in London, and in the evening they can speculate in New York. The development of software is also global. For example, it was developed in the United States last night. In the morning, the same software can be developed in China, 24 hours a day. This accelerates the development of software. The global market has become synchronized, and the software developed can adapt to any place where human beings exist. Frequently-developed software must be bilingual in Chinese and English. In this way, we need to use different fonts to meet the international needs. Next we will learn how to create a font and use it.

The createfont function is declared as follows:
Wingdiapi hfont winapi createfonta (_ in int cheight, _ in int cwidth, _ in int cescapement, _ in int corientation, _ in int cweight, _ in DWORD bitalic,
_ In DWORD bunderline, _ in DWORD bstrikeout, _ in DWORD icharset, _ in DWORD ioutprecision, _ in DWORD iclipprecision,
_ In DWORD iquality, _ in DWORD ipitchandfamily, _ in_opt lpcstr pszfacename );
Wingdiapi hfont winapi createfontw (_ in int cheight, _ in int cwidth, _ in int cescapement, _ in int corientation, _ in int cweight, _ in DWORD bitalic,
_ In DWORD bunderline, _ in DWORD bstrikeout, _ in DWORD icharset, _ in DWORD ioutprecision, _ in DWORD iclipprecision,
_ In DWORD iquality, _ in DWORD ipitchandfamily, _ in_opt lpcwstr pszfacename );
# Ifdef Unicode
# Define createfont createfontw
# Else
# Define createfont createfonta
# Endif //! Unicode

CheightIs the font height.
CwidthIs the font width.
CescapementIs the tilt angle of the font.
CorientationIs the tilt angle of the font.
CweightIs the font width.
BitalicWhether the font is italic or not.
BunderlineWhether the font contains underscores.
BstrikeoutWhether the font has been deleted.
IcharsetIs the character set used by the font.
IoutprecisionSpecifies how to select the appropriate font.
IclipprecisionIs used to determine the crop precision.
IqualityHow is it consistent with the selected font.
IpitchandfamilyIs the spacing flag and attribute flag.
PszfacenameIs the font name.

An example of calling this function is as follows:
#001 // create a font.
#002 //
#003 // Cai junsheng 2007/09/03 QQ: 9073204 Shenzhen
#004 //
#005 hfont ccaiwinmsg: getfont (void)
#006 {
#007 logfont lf; // character Structure

#008
#009 // obtain the font of the current system.
#010 GetObject (getstockobject (system_font), sizeof (logfont ),
#011 & lf );
#012
#013 // set the font attributes.
#014 lf. lfweight = fw_bold;
#015 lf. lfitalic = true;
#016 lf. lfheight = 26;
#017
#018 // set to.
#019 wsprintf (LF. lffacename, _ T ("% s"), _ T (" "));
#020
#021 // create a font and return it
#022 return createfont (LF. lfheight, LF. lfwidth,
#023 lf. lfescapement, LF. lforientation, LF. lfweight,
#024 lf. lfitalic, LF. lfunderline, LF. lfstrikeout, LF. lfcharset,
#025 lf. lfoutprecision, LF. lfclipprecision, LF. lfquality,
#026 lf. lfpitchandfamily, LF. lffacename );
#027
#028}

Related Article

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.