[GRASS-dev] figureing out fonts - part 3 correction

Glynn Clements glynn at gclements.plus.com
Mon Apr 30 15:27:19 EDT 2007


Michael Barton wrote:

> >> if uname -s can differentiate Debian from other systems, it's easy enough to
> >> make /usr/share/fonts/freetype as the initial directory for those systems.
> > 
> > I suggest parsing etc/freetypecap, and either using the directory part
> > of the path for the first font in that file, or the directory used by
> > most fonts (the former is easier, the latter is probably more useful).
> > 
> > E.g.
> > 
> > cat $GISBASE/etc/freetypecap | awk -F: '{print $2}' | sed 's!/[^/]*$!!' | uniq
> > -c | sort -nr | head -n 1 | cut -c 9-
> > 
> > Alternatively, you could replicate the logic of mkftcap (formerly
> > d.freetypecap), i.e. scan a list of candidate directories and settle
> > for the first one which exists.
> 
> This is logical. Any suggestion on how to figure out the directory used by
> most fonts?

cat $GISBASE/etc/freetypecap | awk -F: '{print $2}' | sed 's!/[^/]*$!!' | uniq -c | sort -nr | head -n 1 | cut -c 9-

Actually, it should check for $GRASS_FT_CAP, and only use
$GISBASE/etc/freetypecap as a fallback.

If you wanted to bypass freetypecap altogether and scan the
directories yourself:

for dir in ... ; do
    if [ -d "$dir" ] ; then
        find "$dir" -type f -iname '*.ttf' -print
    fi
done | sed 's!/[^/]*$!!' | uniq -c | sort -nr | head -n 1 | cut -c 9-

If you wanted to do it entirely in Tcl, you would need to perform
directory traversal, as the actual font files will frequently be in
subdirectories of the standard font directories.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list