On 06/03/2009 02:02 PM, Ben Weiner wrote:
Hi,

Behdad Esfahbod wrote:
Ok, listening. It still slightly worries me that all the new code
being written is duplicating lots of code that is already out there...
>
OK, well, please give us some more hints about which functionality we
shouldn't be duplicating... ;-)

"pcp?" The preview-generating tool. I want to see any missing features added to pango-view instead. Fontaine also overlaps with fontconfig and pango in huge parts. I replied to that in another thread a couple montsh back. Maybe if I find some time I hack something...

Also, Ed talks about fontconfig being a mystery. If someone doesn't
understand some part of it, all they need to do is ask. I'll explain
until they understand :).
>
What happens if you get kidnapped or lose your internet connection?

See, I write the code. Ed already contacted me and I told him how I think this should be done. He didn't CC the list (he's not on the list?), so I attach the relevant parts at the end of this message.

Anyway, point being that, now he knows how things work, and he's much better than me in writing. So he can write good docs! Same applies to everyone else: ask, I'll make sure I answer, you can then write it in a legible form :).

behdad


>
> QUESTION:
>
> So, if I add a font file to a subdirectory of a directory that
> fontconfig knows about (via the fontconfig conf file), does fontconfig
> rescan that subdirectory and re-cache immediately?

Any new process notices that immediately and updates the cache (make sure it has permission to do so). Or you can call FcInitReinitialize(). However, I strongly recommend that you keep all the font dirs out of the default fontconfig config, and add only the directory for the font you are dealing with into the config using FcConfigAppFontAddDir(). That should avoid lots of possible scalability as well as security issues. I'd even recommend using different cache dirs for each font dir.

> Or, alternatively, is it necessary to call fc-cache manually?
>
> SCENARIO:
>
> The scenario for uploading new fonts to OFLB is that the fonts will be
> placed in a subdirectory of the "files/" path.  The fontconfig conf
> file will know about the parent directory called "files/".  A new
> subdirectory under "files/" may be created at any time to contain a
> new set of one or more newly uploaded TTF or OTF font files.  The
> program that generates a bitmap PNG preview of the font is called
> "pcfp" and it uses Pango-Cairo.  The exact font family and style
> names, e.g., "Gentium Italic" will be passed to the pcfp.  Since we
> only want to use glyphs from the specified font, the fontconfig conf
> file is setup to use SIL's "hex box" fallback font for all
> substitutions.  That way, if some glyph is missing from the specified
> font, a hex box will be shown  -- this way, we know right away if
> something (such as an extended Latin character) is missing from the
> font.

If you keep the default fontconfig config empty of fonts and just add the dir for new fonts, pango will *only* see those fonts and will draw hexboxes for everything else.

Alternatively you can turn font fallback off in pango using the PangoAttrFallback attribute.


> I assume that Fontconfig will indeed rescan and recache immediately.
> But at this juncture, that is just an assumption on my part.  So that
> is where the "mystery" is for me ... and it is really only a mystery
> because I haven't tested it myself yet.

Well, test it then :). Since many many fonts in the upload area may have the same family name, style, etc, it's essential to implement the scheme I suggest above or a variant thereof.

Reply via email to