"174" C # Add non-default fonts

Source: Internet
Author: User

Reference: C # WinForm Programs install fonts or call non-registered fonts directly

Reference: Baidu knows

Create a new font folder under the Debug folder, and then copy the font file to the inside, and use it to call the font file directly!

        Private voidForm1_Load (Objectsender, EventArgs e) {String Ls_apppath= System.Windows.Forms.Application.StartupPath +"\\font\\";//font is a programString FontFile1= Ls_apppath +"Ygyxsziti2.0.ttf"; System.Drawing.Text.PrivateFontCollection PFC=NewSystem.Drawing.Text.PrivateFontCollection (); Pfc. Addfontfile (fontFile1);//path to the font fileFont myFont1=NewFont (Pfc. families[0], A, Fontstyle.regular, Graphicsunit.point,0);//MyFont1 is the Font object you createdTextbox1.font=MyFont1; }

Example two:

String Ls_apppath = System.Windows.Forms.Application.StartupPath +"\\font\\";//font is a programString FontFile1= Ls_apppath +"lcdm2n__. TTF"; String FontFile2= Ls_apppath +"Zhang Haishan Sharp line body Simple 1.0.TTF"; System.Drawing.Text.PrivateFontCollection PFC=NewSystem.Drawing.Text.PrivateFontCollection ();p FC. Addfontfile (fontFile1);//path to the font filePfc. Addfontfile (FontFile2);//path to the font fileFont myFont1=NewFont (Pfc. families[0], Lb_hour. Font.Size);//MyFont1 is the Font object you createdFont MyFont2 =NewFont (Pfc. families[1], lb_nowDate.Font.Size);//MyFont1 is the Font object you createdLb_hour. Font= Lb_mh1. Font = Lb_mh2. Font = Lb_minite. Font = Lb_second. Font =Myfont1;lb_nowdate.font= Lb_week. Font = MyFont2;

"174" C # Add non-default fonts

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.