[Fontconfig] WIN32 questions

mpsuzuki at hiroshima-u.ac.jp mpsuzuki at hiroshima-u.ac.jp
Thu Jan 21 11:07:47 PST 2010


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
>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">
        <!-- Load per-user customization file -->
        <include ignore_missing="yes">~/.fonts.conf.d</include>
        <include ignore_missing="yes">~/.fonts.conf</include>

You can change the location of per-user configuration fonts.conf
by customizing this file, or add new file into the 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.

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.


More information about the Fontconfig mailing list