Home > Back-end >  QT, how to install Windows no font
QT, how to install Windows no font

Time:03-19

Before thought the font (XXX. The vera.ttf) so long as has the font file, you can directly copy the program to the disk c under Windows/fonts font can be installed directly, in online checked the found like calling Windows API to increase font, like a AddFontResource function, but I don't know how to use and Internet code seems to be no way to run successfully, your bosses

CodePudding user response:

 int nIndex=QFontDatabase: : addApplicationFont ("./Resources/msyh. The vera.ttf "); 
If (nIndex!=1)
{
QStringList strList (QFontDatabase: : applicationFontFamilies (nIndex));
If (strList. The count () & gt; 0)
{
QFont fontThis (strList) at (0));
FontThis. SetPointSize (9);
A.s etFont (fontThis);
}
}

CodePudding user response:

Tips: the font file copy and paste to the system font folder,
The control panel with the font to open the system font folder,

CodePudding user response:

 # include "Windows. H" 
# pragma comment (lib, "Gdi32. Lib")

Int ret=AddFontResourceA (LPCSTR Arg1);//parameter Arg1 "font file path
"//support the file type. Fon. FNT. The vera.ttf. TTC. Fot. Otf. MMM. PFB. PFM