[OpenFontLibrary] Font previewer requirements

Behdad Esfahbod behdad at behdad.org
Mon Mar 16 21:04:13 PDT 2009


On 02/17/2009 04:09 AM, Nicolas Mailhot wrote:
>
> Le Jeu 12 février 2009 22:22, Ed Trager a écrit :
>> Hi, all,
>
> Hi,
>
> Sorry for slacking on the answer,

Hi everyone,

I'm finally in a position to reply to this thread.  Meaning that I've got my 
fontconfig and pango releases out...


>> OK, I'll try to clarify ...
>>
>> On Wed, Feb 11, 2009 at 10:47 PM,<Fontfreedom at aol.com>  wrote:
>>>>> A good static previewer:
>>>> Ed Trager's upcoming "Fontaine" ought to be helpful here :-)
>>> Does that have a webpage?
>>>
>> There are a number of different programs being developed for the the
>> OFLB web site:
>>
>> FONTAINE:
>> -------------
>>
>> This is a new program I'm writing initially for the OFLB project.  The
>> software is getting close to a releasable stage, but I haven't
>> released it yet.  The primary license will be GPL v. 2.0 or any later
>> version.  I am thinking of creating a SourceForge project for SVN
>> hosting of fontaine, but I haven't got that far yet.
>>
>> Fontaine is a command-line utility that displays key meta information
>> about font files, including but not limited to font name, style,
>> weight, glyph count, character count, copyright, license information
>> and orthographic coverage.
>
> This part seems do do the same thing that the fc-query command Behdad
> added to fontconfig recently. Since fc-query gives you the fontconfig
> script coverage view, that a lot of apps will use (including on
> non-windows platforms), I feel it would be better to enhance fc-query
> output if it's lacking for whatever reason.

Agreed.  fc-query now supports an extensive format specifier language too.


> A new fontconfig release has been announced soonish, so now is the
> good time to send Behdad patches.

Too late.  My release is out:

http://lists.freedesktop.org/archives/fontconfig/2009-March/003137.html

But I'm interested in patches to make fontconfig extract copyright and license 
information from the font.


>> To facilitate different usage scenarios, fontaine produces reports in
>> JSON (default), XML, XHTML, and TEXT formats.  In the code, there is a
>> base "MLR" ("markup language report") class from which specific
>> reporting classes like JSON and XML are derived.  This architecture
>> should make it easy to create additional report formats if needed.
>
> Apart from the TEXT format that fc-query also does this does not look
> terribly useful in a non-dynamic-web context

fc-query can produce reports in any format you tell it.  For example, to 
extract a list of font families from the font, escaped for HTML, use:

fc-query --format '<ul>\n%{[]family{<li>%{family|xmlescape}</li>\n}}</ul>\n' 
fontfile.ttf


>> Fontaine's orthography database includes "sample sentences" and
>> "sample characters" for each orthography. For many orthographies, the
>> "sample sentence" (or sometimes more than one sentence) is actually a
>> pangram.  However, since many orthographies, such as Chinese and
>> Japanese, don't support "pangrams" per se, I just use the more general
>> term "sample sentence" which works across all orthographies.  I
>> provide instances of pangrams for those orthographies where I have
>> been able to locate them.  Future community contributions will
>> certainly be valuable in expanding and vetting the orthography data
>> that I have compiled so far.
>
> The sample database looks nice and would definitely be something
> needed for a static previewer too.

Pango has API to for that: pango_language_get_sample_string().  Here is the 
list of samples I have:

http://git.gnome.org/cgit/pango/tree/pango/pango-language-sample-table.h

Patches welcome.  You should really contribute Fontain's sample sentences to 
Pango!


>> The plan is that report output from  Fontaine can be used as input to
>> generate a font preview image.  The font preview image can be
>> generated from one or more of the sample sentences (pangrams) or
>> sample character strings provided by fontaine. A separate program
>> --such as PCFP (below)-- is used to create the preview graphic.
>>
>> I am still thinking about how this last step should best be handled.
>> At issue is the fact that most of the good modern Open Source fonts
>> provide coverage for a number of different orthographic categories.
>> For example, a font like SIL's Gentium covers many different Latin
>> orthographies (incl. but not limited to Western Latin, Central
>> European, Turkish, and Vietnamese), plus both monotonic and polytonic
>> Greek, plus Cyrillic, and more.  So how do you choose one
>> representative pangram or sample character string for use as the
>> default static font preview ?
>
> This IMHO is the most difficult but also the most useful thing a
> static previewer needs: good heuristics to choose the correct samples
> to display automatically

Pango also has another useful API: pango_script_get_sample_language().
The list of scripts is pretty short (~45).  One can try each script, get the 
sample language, render it with the font and fallback disabled, and use 
pango_layout_get_unknown_glyph_count() to decide whether the font "supports" 
that language.  Or just check the fontconfig language coverage for that.


>> PCFP
>> ------
>>
>> "pcfp" stands for "Pango-Cairo Font Playground".  Pcfp is a simple
>> command-line utility I wrote to take a font specification and a text
>> string on the command line and render the text in the specified font
>> to a PNG (portable networks graphics) canvas.  The dynamic font
>> previewer currently on http://openfontlibrary.fontly.org/ uses pcfp on
>> the server.  One significant advantage of pcfp is that complex scripts
>> like Arabic and Devanagari are rendered correctly -- because of Pango
>> of course.  Pcfp is released under GPL v.2.0 or any later version.

pango-view from the pango 1.24.0 I made today also does that.

> PNG is nice but is pixel-density dependent and the hardware is moving
> the other way, especially in the embedded space. svgz shapes would be
> much better in a non-web scenario (I agree that a web scenario
> probably needs to take IE into account).

pango-view from pango 1.24.0 also supports output to PS, EPS, PDF, and SVG.


>> "Font Playground" and "Key Curry"
>> -------------------------------------------
>>
>> A browser-based dynamic font previewer requires an AJAX-based
>> Javascript program on the client side.
>
> This part is clearly dynamic web only so it's useless in my context.
>
> So, to sum up:
> 1. the property detection part of fontaine should IMHO better be
> integrated to fc-query
> 2. the samples database is nice, but it seems fontaine-dependant, when
> we want to stay as close to fontconfig as possible. Also it's missing
> the critical sample choosing heuristics needed in a fully automated
> workflow
> 3. pcfp looks something we could use, it it had a svgz output
>
> Thank you very much for posting on your advancement. It's not really
> what we need Fedora-side now, but some bits look close, and I hope
> someone will contribute the needed changes so they can be used in
> non-OFLB context too.
>
> Regards,

Seriously, I think all these stuff belong to Pango and below.  Just file a bug 
to request missing features.  Or better, submit patches!

Cheers,

behdad


More information about the OpenFontLibrary mailing list