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