Hi, I am a Graphviz developer who is particularly in charge of WIN32 port of it. Because of the application directory structure differences between *nix systems and WIN32 , I have had hard time to figure out few things about fontconfig. Here are my questions 1) Is there a way to specify the location of fonts.conf file.It seems fontconfig looks for ../etc/fonts/fonts.conf and I like to move it somewhere in windows users application data directory. 2) Does fontconfig have a function that creates the config files automatically and sets the appropriate windows font directory value. Right now It has to be done during installation of our application and that causes problems on some win32 boxes with tight security policies. 3) We use pangocairo as font renderer for Graphviz. Pangocairo has its own way of handling fontconfig calls.It is a black box for us.We feed pangocairo with a font description and hope that it finds the right font. There are times that user knows everything about a font (name of the file ,location of the file) but we still have to go through to whole font matching process to force fontconfig to locate the font file that we already know. Is there a way to tell fontconfig "hey this is the font file , just give it back to me (in our case give it back to pangocairo) as a return value". Do we need to maintain a font name-font file map and use it to achieve that. Thanks a lot. Arif Bilgin
Hi, Do you have the source of fontconfig and checked it? I think most of your questions are easily understood from the source. On Thu, 21 Jan 2010 10:19:34 -0500 "Arif Bilgin" <arif at research.att.com> wrote:>I am a Graphviz developer who is particularly in charge of WIN32 port of it. >Because of the application directory structure differences between *nix >systems and WIN32 , I have had hard time to figure out few things about >fontconfig. > >Here are my questions > >1) Is there a way to specify the location of fonts.conf file.It seems >fontconfig looks for ../etc/fonts/fonts.conf and I like to move it somewhere >in windows users application data directory.To change the location of system-wide configuration file from ${prefix}/etc/fonts/fonts.conf to anywhere, using --sysconfdir=DIR would be popular for autoconfized softwares. The location of the system-wide fonts.conf would be installed to DIR/fonts/fonts.conf. But you wrote "windows users application data directory". Do you mean something like "C:\Documents and Settings\foo\Application Data\bar\fonts.conf" ? The location of per-user configuration file is specified by the system-wide configuration file. Please find /etc/fonts/conf.d/50-user.conf, it describes <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <!-- Load per-user customization file --> <include ignore_missing="yes">~/.fonts.conf.d</include> <include ignore_missing="yes">~/.fonts.conf</include> </fontconfig> You can change the location of per-user configuration fonts.conf by customizing this file, or add new file into the directory ${prefix}/etc/fonts/conf.d/>2) Does fontconfig have a function that creates the config files >automatically and sets the appropriate windows font directory value. Right >now It has to be done during installation of our application and that causes >problems on some win32 boxes with tight security policies.I''m not sure what is the problem. About the configuration files, I think the installation of fontconfig just copies the system-wide configuration files to the configured directory. If copying files to the configured directory causes the security problem, maybe you will have to install everything (both of library DLLs and configuration files) per-user... is it what you want to do? About "appropriate windows font directory" - please check the part enclosed by "#ifdef _WIN32" ... "#endif" in fontconfig/src/fcxml.c. fontconfig is designed to set the directories in run-time, in automatically, by Win32 APIs.>3) We use pangocairo as font renderer for Graphviz. Pangocairo has its own >way of handling fontconfig calls.It is a black box for us.We feed pangocairo >with a font description and hope that it finds the right font.Why you cannot use Win32 font backend of Pangocairo?>There are times that user knows everything about a font (name of the file >,location of the file) but we still have to go through to whole font >matching process to force fontconfig to locate the font file that we already >know. Is there a way to tell fontconfig "hey this is the font file , just >give it back to me (in our case give it back to pangocairo) as a return >value". Do we need to maintain a font name-font file map and use it to >achieve that.I''m not sure what you mean "give it back to me". Do you want to get some identifier in fontconfig from given pathname? I think fontconfig does not have any identifier except of the pathname of the font file (and the index to specify a face in TTC). Other properties (or combination of them) are not guaranteed to be unique key to specify the font. I guess, what you want to do might be... * you''re using pangocairo with fontconfig backend. * you have to specify a font for pangocairo with a face name. * but the face name Windows user see is (sometimes) different from the face name fontconfig manages. * so you want an unique key to specify a font via fontconfig, from concrete pathname of the font file. I think there is no perfect way. However, if you allow the ambiguity that cannot be identified by the combination of family name, style name and full name, you can use the combination of them as an identifier. I''m not familiar with the smart Win32 way to extract these strings from given pathname of the font file. If there''s no, FreeType2 can extract these properties from given pathname of the font file. Regards, mpsuzuki
I have Here is the wired in config file locations ehich don''t mean a lot to WIN32 /etc/fonts/fonts.conf /etc/fonts/fonts.dtd /etc/fonts/conf.d ~/.fonts.conf> -----Original Message----- > From: mpsuzuki at hiroshima-u.ac.jp [mailto:mpsuzuki at hiroshima-u.ac.jp] > Sent: Thursday, January 21, 2010 2:08 PM > To: Arif Bilgin > Cc: fontconfig at lists.freedesktop.org > Subject: Re: [Fontconfig] WIN32 questions > > Hi, > > Do you have the source of fontconfig and checked it? > I think most of your questions are easily understood > from the source. > > On Thu, 21 Jan 2010 10:19:34 -0500 > "Arif Bilgin" <arif at research.att.com> wrote: > >I am a Graphviz developer who is particularly in charge of WIN32 port > of it. > >Because of the application directory structure differences between > *nix > >systems and WIN32 , I have had hard time to figure out few things > about > >fontconfig. > > > >Here are my questions > > > >1) Is there a way to specify the location of fonts.conf file.It seems > >fontconfig looks for ../etc/fonts/fonts.conf and I like to move it > somewhere > >in windows users application data directory. > > To change the location of system-wide configuration file > from ${prefix}/etc/fonts/fonts.conf to anywhere, using > --sysconfdir=DIR would be popular for autoconfized softwares. > The location of the system-wide fonts.conf would be installed > to DIR/fonts/fonts.conf. > > But you wrote "windows users application data directory". > Do you mean something like > > "C:\Documents and Settings\foo\Application Data\bar\fonts.conf" > > ? The location of per-user configuration file is specified > by the system-wide configuration file. Please find > /etc/fonts/conf.d/50-user.conf, it describes > > <?xml version="1.0"?> > <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> > <fontconfig> > <!-- Load per-user customization file --> > <include ignore_missing="yes">~/.fonts.conf.d</include> > <include ignore_missing="yes">~/.fonts.conf</include> > </fontconfig> > > You can change the location of per-user configuration fonts.conf > by customizing this file, or add new file into the directory > ${prefix}/etc/fonts/conf.d/ > > >2) Does fontconfig have a function that creates the config files > >automatically and sets the appropriate windows font directory value. > Right > >now It has to be done during installation of our application and that > causes > >problems on some win32 boxes with tight security policies. > > I''m not sure what is the problem. About the configuration files, > I think the installation of fontconfig just copies the system-wide > configuration files to the configured directory. If copying files > to the configured directory causes the security problem, maybe > you will have to install everything (both of library DLLs and > configuration files) per-user... is it what you want to do? > > About "appropriate windows font directory" - please check > the part enclosed by "#ifdef _WIN32" ... "#endif" in > fontconfig/src/fcxml.c. fontconfig is designed to set the > directories in run-time, in automatically, by Win32 APIs. > > >3) We use pangocairo as font renderer for Graphviz. Pangocairo has its > own > >way of handling fontconfig calls.It is a black box for us.We feed > pangocairo > >with a font description and hope that it finds the right font. > > Why you cannot use Win32 font backend of Pangocairo? > > >There are times that user knows everything about a font (name of the > file > >,location of the file) but we still have to go through to whole font > >matching process to force fontconfig to locate the font file that we > already > >know. Is there a way to tell fontconfig "hey this is the font file , > just > >give it back to me (in our case give it back to pangocairo) as a > return > >value". Do we need to maintain a font name-font file map and use it to > >achieve that. > > I''m not sure what you mean "give it back to me". Do you want > to get some identifier in fontconfig from given pathname? > I think fontconfig does not have any identifier except of > the pathname of the font file (and the index to specify > a face in TTC). Other properties (or combination of them) > are not guaranteed to be unique key to specify the font. > > I guess, what you want to do might be... > > * you''re using pangocairo with fontconfig backend. > * you have to specify a font for pangocairo with a face name. > * but the face name Windows user see is (sometimes) different > from the face name fontconfig manages. > * so you want an unique key to specify a font via fontconfig, > from concrete pathname of the font file. > > I think there is no perfect way. However, if you allow the > ambiguity that cannot be identified by the combination of > family name, style name and full name, you can use the combination > of them as an identifier. I''m not familiar with the smart > Win32 way to extract these strings from given pathname of > the font file. If there''s no, FreeType2 can extract these > properties from given pathname of the font file. > > Regards, > mpsuzuki
> Here is the wired in config file locations ehich don''t mean a lot to WIN32 > ? /etc/fonts/fonts.conf > ? /etc/fonts/fonts.dtd > ? /etc/fonts/conf.dOf course not, and indeed they aren''t used. The src/Makefile.am passes -DFONTCONFIG_PATH=''"$(CONFDIR)"'' but then in fccfg.c you see #if defined (_WIN32) static FcChar8 fontconfig_path[1000] = ""; (Code to initialise fontconfig_path once with a path that reflects the location of the fontconfig DLL) #undef FONTCONFIG_PATH #define FONTCONFIG_PATH fontconfig_path #endif And thus the code in FcConfigGetPath() uses that variable instead of a hardcoded literal string to construct the pathname.> ? ~/.fonts.confUnless the environment variable HOME exists (it usually doesn''t on Windows), on Windows the ''~'' is expanded to the value of the environment variable USERPROFILE, which normally exists. So that should work. But OK, it would be cleaner to use a directory relative to the per-user AppData directory and not a "dot" directory, as an initial period has no traditional significance on Windows. --tml
On Thu, 21 Jan 2010 23:33:32 +0200 Tor Lillqvist <tml at iki.fi> wrote:>The src/Makefile.am passes >-DFONTCONFIG_PATH=''"$(CONFDIR)"'' but then in fccfg.c you see > >#if defined (_WIN32) > >static FcChar8 fontconfig_path[1000] = ""; > >(Code to initialise fontconfig_path once with a path that reflects the >location of the fontconfig DLL) > >#undef FONTCONFIG_PATH >#define FONTCONFIG_PATH fontconfig_path > >#endifI was not aware of this. Thank you! Regards, mpsuzuki