How can an application add extra "font" directories at startup? Is there an environment variable that allows adding directories to the fontconfig search path? We have a few .ttf files we would like to distribute internally with an application. This is using Qt4 built with fontconfig support. Adding the fonts to all user''s or all system''s font directories is not a good option. These are systems running CentOS4, fontconfig version 2.2.3.
On 7/30/07, Peter Shinners <peters at imageworks.com> wrote:> How can an application add extra "font" directories at startup? Is there > an environment variable that allows adding directories to the fontconfig > search path? > > We have a few .ttf files we would like to distribute internally with an > application. This is using Qt4 built with fontconfig support. Adding the > fonts to all user''s or all system''s font directories is not a good option. > > These are systems running CentOS4, fontconfig version 2.2.3.What you can do is place the fonts in something like /usr/share/myapplication/fonts when the administrator installs the application. Then, when the user runs the application for the first time, you put a copy of the fonts into ~/.fonts/myapplication/ Per user fonts are located by default in ~/.fonts/. The fonts are discovered even if they are in subdirectories. Simos
On Monday 30 July 2007 20:50:08 Peter Shinners wrote:> How can an application add extra "font" directories at startup? Is there > an environment variable that allows adding directories to the fontconfig > search path? > > We have a few .ttf files we would like to distribute internally with an > application. This is using Qt4 built with fontconfig support. Adding the > fonts to all user''s or all system''s font directories is not a good option. > > These are systems running CentOS4, fontconfig version 2.2.3.If you want to use the fonts only in your application and you are using Qt 4 then you could just bundle them as Qt resources and make them available to your application using QFontDatabase::addApplicationFont. Simon -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part. Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20070731/2c88a5b6/attachment.pgp
>>>>> "Peter" == Peter Shinners <peters at imageworks.com> writes:Peter> How can an application add extra "font" directories at startup? Peter> Is there an environment variable that allows adding directories Peter> to the fontconfig search path? Check out the function FcConfigAppFontAddDir(). It lets you add a directory of application-specific fonts to the config. There is also FcConfigAppFontAdd() to add a single font file. They are mentioned in fontconfig(3) and also in the fontconfig-devel manual. I am not familiar with how Qt interacts with fontconfig. There may be something in the Qt api to call those, or you may have to do so manually. I''d take a look thru the Qt src for where it calls FcInit(), FcInitLoadConfig() and/or FcInitLoadConfigAndFonts(). -JimC -- James Cloos <cloos at jhcloos.com> OpenPGP: 1024D/ED7DAEA6