[XeTeX] Is it possible to set a fonts preference sequence in XeTeX?

Peter Dyballa Peter_Dyballa at Web.DE
Fri Mar 2 16:43:22 CET 2012


Am 2.3.2012 um 11:23 schrieb Cosmia Luna:

> Also I work on more than one computer and they have different fonts
> installed, I just want to make a bit of change in my secondary
> computer but failed because Windows don't have DejaVu Serif by
> default, and I use Linux in most of time.

You can use the ifplatform package to set up fonts accordingly.

Will Robertson once presented this:

> The reason this primitive doesn't exist is for performance reasons; it  
> can be very slow to check for the non-existence of a font.
> 
> Jonathan has a sample file floating around called  
> "testfontavailability" which I've reproduced below; it should be a  
> good starting point :)
> 
> Hope this helps,
> Will
> 
> % Macros to try and find available fonts for XeTeX sample docs
> %
> % Usage:
> %
> % \testFontIsAvailable{font-name}
> % sets \ifFontIsAvailable according to whether or not it could be found
> %
> % \FindAnInstalledFont{font-name/alternative/another/yet-another}{\cs}
> % searches for an available font from among the names given,
> % and \def's the control sequence \cs to the first one found
> % or to <No suitable font found> if none (which will subsequently
> % cause an error when used in a \font command).
> \newif\ifFontIsAvailable
> \def\testFontAvailability#1{
> \count255=\interactionmode
> \batchmode
> \let\preload=\nullfont
> \font\preload="#1" at 10pt
> \ifx\preload\nullfont \FontIsAvailablefalse
> \else \FontIsAvailabletrue \fi
> \interactionmode=\count255
> }
> \def\FindAnInstalledFont#1#2{
> \expandafter\getFirstFontName#1/\end
> \let\next\gobbleTwo
> \ifx\trialFontName\empty
> \def#2{<No suitable font found>}%
> \else
> \testFontAvailability{\trialFontName}
> \ifFontIsAvailable
> \edef#2{\trialFontName}%
> \else
> \let\next\FindAnInstalledFont
> \fi
> \fi
> \expandafter\next\expandafter{\remainingNames}{#2}
> }
> \def\getFirstFontName#1/#2\end{\def\trialFontName{#1}\def 
> \remainingNames{#2}}
> \def\gobbleTwo#1#2{}

It might be faster to ask the system's font service which fonts it knows (and which XeTeX then can use). This can be done from within the (La)TeX document.

\XeTeXcharglyph«Unicode point» can check whether the glyph at «Unicode point» exists in the font in use.

--
Greetings

  Pete

Know thyself. Need help, call GOOGLE.




More information about the XeTeX mailing list