Home > Net >  C # to load a custom font problem
C # to load a custom font problem

Time:05-18

Through code load font under WIN10 run well, but on the Windows 7 is an error, which a great god to help me with what problem, the code is simple:

Private void button1_Click (object sender, EventArgs e)
{
String path1=@ 456. The vera.ttf ";
String path2=@ "D: \ SourceHanSansCN \ SourceHanSansCN \ SourceHanSansCN - Light otf";
PrivateFontCollection PFC=new PrivateFontCollection ();
PFC. AddFontFile (path1);
PFC. AddFontFile (path2);

The Font f=new Font (PFC) Families [0], 16);

RichTextBox1. The Font=f;
}

Tried a relative path and absolute paths are no,


An error as below


Thank god!!!!!

CodePudding user response:

Are you sure 456. The vera.ttf the relative path can be? I can't under win10. Only the absolute path

CodePudding user response:

If the relative path can be, that is, under the relative path without this file

CodePudding user response:

https://bbs.csdn.net/topics/390279248

CodePudding user response:

All said can't find the file, there is nothing to discuss

CodePudding user response:

reference 1st floor wang_peng response:
456. You confirmed the vera.ttf the relative path can be? I can't under win10. Only the absolute path


Can I have the computer files

CodePudding user response:

reference 4 floor xuzuning response:
all say can't find the file, have nothing to discuss


Can't find the file, but there are files

CodePudding user response:

love tea assistant reference 3 floor response:
https://bbs.csdn.net/topics/390279248


But I am under the WIN10 can, under the Windows 7 doesn't work
  •  Tags:  
  • C#
  • Related