[XeTeX] Checking if a font exists

Grzegorz Murzynowski natror at o2.pl
Sun Aug 29 23:39:43 CEST 2010


W dniu 29.08.2010 19:18, Barry MacKichan pisze:
>   Some variation of
> fc-list "Myriad Pro">  somefile
> should get you a file you can run a test on.
>

And when the 18th output is on (writing to shell), you can put
		
		\immediate\write 18{fc-list "Myriad Pro" > fontcheck.tex}
		\newread\fontcheck
		\immediate\openin\fontcheck="fontcheck.tex"
		\ifeof \fontcheck …

in your main TeX file. (I tested only the first line).
and of course test the font names listed in that file in any way you please.

(Note I'm a Linux (Ubuntu) user and know not much about what font-list 
command is available in other OS-es (and if any)).

Anyway, thank you Barry MacKichan for the tip: I asked the same question 
on this list some months (years?) ago and the aswers were rather 
unsatisfactory.
*This* looks it could work.

Rgds —
Grzegorz Murzynowski.




> --Barry macKichan
>
>
> On 8/29/2010 10:56 AM, Alan Munn wrote:
>>
>> On Aug 29, 2010, at 12:24 PM, Michiel Kamermans wrote:
>>
>>> Hi Alan,
>>>
>>>> Is there a way to check whether a font is present in a user's
>>>> system?  I need to generate a document with Myriad Pro if it exists,
>>>> Arial otherwise, and if neither, exit with an error.
>>>
>>> Myriad Pro is nothing like Arial, though... but just to make your
>>> life worse: thought about version numbers? There are many versions of
>>> Myriad Pro, and many versions of Arial. How do you know which version
>>> numbers are permissible?
>>
>> Well, since I have no information on that, I'll assume that all are
>> useable.
>>
>>>
>>> But let's step back for a moment because there's a fundamental
>>> problem with your question: if you're using TeX, you're implicitly
>>> saying you care deeply about the typesetting of your document, which
>>> includes being particular about which stretches of text use what
>>> font. Not just "which various fonts look good for this text", but
>>> "which font is the one I intend to use for this bit of my document".
>>> Rather than testing for several fonts on a user's machine, and
>>> picking "the best match", like if the content were styled via
>>> (X)HTML+CSS, with a font rule that specifies various fonts with
>>> fallbals, part of the power of TeX is the fact that it will always
>>> look the same on any machine it's compiled on, provided the
>>> dependencies are met. So, either your document will look the same no
>>> matter what machine it's compiled on, or it doesn't compile. The idea
>>> that it will compile with Myriad Pro on one machine, and Arial on
>>> another, basically violates the very idea of TeX.
>>
>> Sure, in an ideal world.  But this particular application is to
>> conform to standards set by my university, and for better or for
>> worse, they've allowed Arial to substitute for Myriad Pro if the
>> latter is not available. And it may turn out that since I can
>> reasonably assume that Myriad Pro should be available, I can fix
>> things so that it is the only font used, as long as it can be found.
>>
>>>
>>> The better way to solve whatever problem you're having that made you
>>> wonder how to detect certain fonts is to simply supply those fonts
>>> along with your .tex source. If other people need to compile your
>>> source, simply ensure that they have everything they need to compile it?
>>
>> Well I don't know if redistribution of Adobe fonts is permitted (I
>> would assume not) so this really isn't a (legal) option.
>>
>> Alan
>>
>>
>
>
>
>
>
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
>    http://tug.org/mailman/listinfo/xetex



More information about the XeTeX mailing list