[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fontsets

From: Juan Manuel Macías
Subject: Re: fontsets
Date: Tue, 12 Jul 2022 11:37:34 +0000

Stefan Nobis writes:

> Hmmm... maybe add optional extra config/output option to the fontset,
> like so:
> ┌────
> │ ;; Fonts
> │ ((myfonta . ((pdflatex . "etc.") (lualatex ...) (html ...) ...))
> │  (myfontb ...)
> │  ...)
> │ ;; Fontsets
> │ ((myfontset .
> │   ((sans . myfonta)
> │    (serif . myfontb)
> │    (mono . myfontc)
> │    (extra . ((lualatex . "\\defaultfontfeatures{Scale=MatchLowercase}")
> │              (html "some CSS...")...))
> │    ...))
> │  ...)
> └────
> This way it may be possible to build a fontset library of fonts that
> blend well together, including some necessary fine-tuning.

I think it's a good idea. And I definitely like Timothy's idea of
fontsets, but I still think that LuaLaTeX and XelaTeX should be unified
in some way.

Perhaps one or two default fontsets could be added.

It was commented in some previous message about the possibility of
checking if a font is present in the system. To add some extra
information, TeX live 2022 includes a lua script, luafindfont, which
runs luaotfload in the background. It is very useful because, in
addition to system fonts, it also returns results from TeX live fonts. I
use this script via helm, and I wrote this to extract a list of

#+begin_src emacs-lisp
(defun build-luafindfont-candidates-list (candidate)
  (let* ((query (shell-command-to-string (concat "luafindfont " candidate)))
         (str (with-temp-buffer
                (insert query)
                (goto-char (point-min))
                (let ((from
                         (re-search-forward "1\\." nil t)
                         (goto-char (point-max))
                    (narrow-to-region from to)
         (str-clean (split-string
                        (insert str)
                        (replace "[[:digit:]]+\\.\s+" "")
                        (replace "\\(.+\\)\\(\\.otf\\|\\.ttf\\)\s+" "")
                        (replace "\s+" " -- ")
                        (buffer-string)) "\n" t)))
    (setq luafindfont-list (mapcar 'identity

On the other hand, fontspec includes the \IfFontExistsTF command.
According to the fontspec documentation:

\IfFontExistsTF{⟨font name⟩}{⟨true branch⟩}{⟨false branch⟩}

The conditional \IfFontExistsTF is provided to test whether the ⟨font name⟩ 
exists or
is loadable. If it is, the ⟨true branch⟩ code is executed; otherwise, the 
⟨false branch⟩ code is.
This command can be slow since the engine may resort to scanning the filesystem 
for a
missing font. Nonetheless, it has been a popular request for users who wish to 
define ‘fallback
fonts’ for their documents for greater portability.

In this command, the syntax for the ⟨font name⟩ is a restricted/simplified 
version of the
font loading syntax used for \fontspec and so on. Fonts to be loaded by 
filename are detected
by the presence of an appropriate extension (.otf, etc.), and paths should be 
included inline.

\IfFontExistsTF{Times New Roman}{T}{F}

Best regards,

Juan Manuel 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]