[XeTeX] Checking if a font exists

Wilfred van Rooijen wvanrooijen at yahoo.com
Mon Aug 30 06:56:44 CEST 2010


Hi,

I am not 100% sure, but "fc-list" and friends might not always list the fonts even if they are on the user's system. For example, on my gentoo linux desktop, fonts for Adobe Acrobat are installed in a specific directory and are not included in the system-wide fonts by default. In fact, I have had to copy some of the Adobe fonts to my $HOME/.fonts to do some testing.

The (more dificult) solution could be to make a shell script which will run the compilation of the xelatex source and detect whether or not the run was succesfull - if not, change the input file to the other font and retry.

Regards,
Wilfred

--- On Mon, 30/8/10, Barry MacKichan <barry.mackichan at mackichan.com> wrote:

> From: Barry MacKichan <barry.mackichan at mackichan.com>
> Subject: Re: [XeTeX] Checking if a font exists
> To: "Unicode-based TeX for Mac OS X and other platforms" <xetex at tug.org>
> Date: Monday, 30 August, 2010, 12:08 PM
>  Since xetex uses fontcache, a extra
> benefit for Windows users is that
> they now have a version. By default it looks at the Windows
> font
> directory among others.
> 
> --Barry
> 
> On 8/29/2010 3:39 PM, Grzegorz Murzynowski wrote:
> > 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
> >
> >
> >
> > --------------------------------------------------
> > Subscriptions, Archive, and List information, etc.:
>http://tug.org/mailman/listinfo/xetex
> 
> 
> -----Inline Attachment Follows-----
> 
> 
> 
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
>   http://tug.org/mailman/listinfo/xetex
> 






More information about the XeTeX mailing list