Page 1 of 1

questions about fonts

Posted: 2007-12-15T03:35:51-07:00
by maceis
Hello together,

by entering "identify -list font" I can print a list of fonts, IM knows by name.
I get about 35 which I have installed togehther with ghostscript.

Is there any collection of (free) fonts available for download?
I am particularly interested in the fonts used in the examples of Anthony's website.

On Mac OS X I have a collection of truetype fonts locatet in /System/Library/Fonts and /Library/Fonts.
These have filenames with the extension .ttf.
I can use this fonts by entering the fullpathname e.g
-font /Library/Fonts/Arial.ttf

Is there any way to use these just by name (without path and extension)?

Re: questions about fonts

Posted: 2007-12-16T21:37:48-07:00
by anthony
Is there any collection of (free) fonts available for download?
I name a couple of free to download font libraries on the top level page of IM Examples
Is there any way to use these just by name (without path and extension)?
Same place, the top level page of IM Examples.

Re: questions about fonts

Posted: 2007-12-17T03:04:41-07:00
by maceis
Thank you very much. You made my day.
I have read this, but I didn't remember ;).

The 'imagick_type_gen'- works quite well on Mac OS X but there is one little problem.
There are a lot of fonts in "/Library/Fonts" with spaces in their filename e.g "Andale Mono.ttf" or "Arial Narrow Bold Italic.ttf".
The script does not seem to process those.

However, I found a workaround for this problem which might be helpfult to other Mac OS X Users.
I quoted line 352 ‘map { glob "$_" }‘ inside the 'locate' subroutine.
I didn't notice any negative sideeffects by now.

btw: I really appreciate your "IM Examples" webiste. It's very, very helpful.

Re: questions about fonts

Posted: 2007-12-17T17:26:29-07:00
by anthony
That is strange. I would not have expected quotes in a glob argument to have been necessary. Good pickup.

I have fixed the script as per your suggestion, though it may take a day or so to appear in the main IM Examples web pages

Re: questions about fonts

Posted: 2007-12-18T00:07:00-07:00
by maceis
No wait.
I said this wrong. (My English is not the best)
The quoting was my first try. But it didn't work.

I finally commented out the whole line. This worked for me but it might not be helpful in other environments.

Re: questions about fonts

Posted: 2007-12-18T17:17:47-07:00
by anthony
What exactly did you comment out?

I myself do not use MacOSX so I have to rely on others to get this to work right with the very limited version of the "locate" command that Mac's use.

Specifically the use of '-r' so as to avoid the use of 'grep', and that the lack of '-0' for handling special characters such as a space, or return charcater in the file name (preventing the need for 'glob' to handle '?' in the output of 'locate'. (see the commented line in the script)

Any help from a MacOSX user that is in the know would be appreciated.
Ditto for Windows users!

Re: questions about fonts

Posted: 2007-12-19T12:16:13-07:00
by maceis
I changed the locate subroutine to

Code: Select all

sub locate {
  # This fails under MacOSX
  #return split('\0', `locate -0er '\\.$_[0]\$'`);

  # Use perl to 'glob' expand '?' in locate output on MacOSX
  return grep {  /\.$_[0]$/ && -f $_ }
#           map { glob "$_" }
             split "\n", `locate '.$_[0]'`;
}
btw. as of Mac OS X 10.5 (which I use) the locate command has '-0' but it still lacks '-r' and '-e'

I can do some further testing on Mac OS X 10.2, 10.3, 10.4 to find a way to handle all those systems properly. I don't think there are very many 10.1 and 10.0 users arround any more.
I will, however, need a few days because I have to install 10.3 and 10.2 on my Apple notebook for this.

I have still another question:
In which cases you expect '?' in locate output? I don't have any '?' in locate output (at least not in Mac OS X 10.5).
Edit: I found out that this can happen (depending on the setup of the shell) when filenames contain multibyte characters.

On Windows I think the script will not run because there is no locate command at all. It might only be available if cygwin is installed.

Re: questions about fonts

Posted: 2007-12-19T16:51:42-07:00
by anthony
Thanks maceis Please keep me informed of you progress. And yes it probably is multi-byte characters than cause the problem.
maceis wrote:On Windows I think the script will not run because there is no locate command at all. It might only be available if cygwin is installed.
I was hoping there was a windows equivelent but didn't think there was. However if windows has a specific setup I was thinking that perhaps a text can be made for a specific directory and just look for fonts in that directory. The location for the output file also needs to be updated in the scripts opening comments.

The perl script looks at TTF files directly without relying on any other programs to parse the files, as such it should be a good guide to either modifying it for direct windows (or cygwin) usage, OR to create a windows specific version.

In any case thanks for looking into this for Mac Users.