Where should I put my fonts?
-
My application comes with non-default fonts that I want to install on the users PC. Until now I have been installing the fonts to a folder in the user's home directory (linux) but since my application is available in /usr/bin I'd like it to be in a location where all users can load the fonts from.
Is there one folder that I can install my fonts to that works across all linux distros? If so, where is that? Also, is there a similar folder where I can install my fonts to for windows?
If I'd install my fonts to these common locations (e.g. /usr/fonts), would QFontDatabase automatically pick it up, or would I need to manually check what OS I am on and then use (e.g. on linux) `QFontDatabase::addApplicationFont("/usr/fonts/myFont.otf")?
-
My application comes with non-default fonts that I want to install on the users PC. Until now I have been installing the fonts to a folder in the user's home directory (linux) but since my application is available in /usr/bin I'd like it to be in a location where all users can load the fonts from.
Is there one folder that I can install my fonts to that works across all linux distros? If so, where is that? Also, is there a similar folder where I can install my fonts to for windows?
If I'd install my fonts to these common locations (e.g. /usr/fonts), would QFontDatabase automatically pick it up, or would I need to manually check what OS I am on and then use (e.g. on linux) `QFontDatabase::addApplicationFont("/usr/fonts/myFont.otf")?
@Creaperdown
You can embed your font as a resource in your app. -
@Creaperdown
You can embed your font as a resource in your app.@mpergand Do I simply put them into a resource file and add them to my binary?
-
@mpergand Do I simply put them into a resource file and add them to my binary?
@Creaperdown said in Where should I put my fonts?:
@mpergand Do I simply put them into a resource file and add them to my binary?
Yes.
The path must begin with :/... -
@Creaperdown said in Where should I put my fonts?:
@mpergand Do I simply put them into a resource file and add them to my binary?
Yes.
The path must begin with :/...@mpergand and how would I add it to the
QFontDatabase
? Would I pass e.g.QFontDatabase::addApplicationFont("qrc:/resources/myFont.otf")
to it, or wouldn't I need to add it anymore at all? -
@mpergand and how would I add it to the
QFontDatabase
? Would I pass e.g.QFontDatabase::addApplicationFont("qrc:/resources/myFont.otf")
to it, or wouldn't I need to add it anymore at all?@Creaperdown
I'm using this:int id=QFontDatabase::addApplicationFont(path); if(id EQ -1) {QTLog(<<"UI Font not found"<<path) return -1; }
-
@Creaperdown
I'm using this:int id=QFontDatabase::addApplicationFont(path); if(id EQ -1) {QTLog(<<"UI Font not found"<<path) return -1; }
@mpergand What is path for you? Is it something like "qrc:/path/to/fonts/myFont.otf")?
-
@mpergand What is path for you? Is it something like "qrc:/path/to/fonts/myFont.otf")?
@Creaperdown said in Where should I put my fonts?:
@mpergand What is path for you? Is it something like "qrc:/path/to/fonts/myFont.otf")?
":/Fonts/Regular.ttf"
":/Fonts/Medium.ttf"
":/Fonts/Bold.ttf"All my fonts are in the same folder named "Fonts"
-
@Creaperdown said in Where should I put my fonts?:
@mpergand What is path for you? Is it something like "qrc:/path/to/fonts/myFont.otf")?
":/Fonts/Regular.ttf"
":/Fonts/Medium.ttf"
":/Fonts/Bold.ttf"All my fonts are in the same folder named "Fonts"
@mpergand Thank you, I will try to do it the same way.
-
Embedding the fonts worked perfectly well. Thank you!
-