diff --git a/style/fontspec.el b/style/fontspec.el index 1d73a40..f9137fb 100644 --- a/style/fontspec.el +++ b/style/fontspec.el @@ -138,23 +138,29 @@ "Prompt for a font name with completion. If OPTIONAL is non-nil, insert the resulting value as an optional argument, otherwise as a mandatory one. Use PROMPT as the prompt -string." +string. + +Customize `LaTeX-fontspec-arg-font-search' in order to decide how +to retrieve the list of fonts." (unless LaTeX-fontspec-font-list - (with-temp-buffer - ;; Insert into the temporary buffer the list of fonts retrieved with - ;; `luaotfload-tool'. The list is in the form - ;; - (shell-command "luaotfload-tool --list=basename" t) - ;; Search for the fonts base names and family names, and add them to - ;; `LaTeX-fontspec-font-list'. - (while - (re-search-forward "^\\([^\n\r\t]*\\)\t\\([^\n\r\t]*\\)\t.*$" nil t) - (add-to-list 'LaTeX-fontspec-font-list (match-string-no-properties 1)) - (add-to-list 'LaTeX-fontspec-font-list (match-string-no-properties 2))))) + (when (if (eq LaTeX-fontspec-arg-font-search 'ask) + (not (y-or-n-p "Find font yourself? ")) + LaTeX-fontspec-arg-font-search) + (message "Searching for fonts...") + (with-temp-buffer + (shell-command "luaotfload-tool --list=basename" t) + ;; Search for the font base names and full names, and add them to + ;; `LaTeX-fontspec-font-list'. The list is in the form + ;; + (while + (re-search-forward "^\\([^\n\r\t]*\\)\t\\([^\n\r\t]*\\)\t.*$" nil t) + (add-to-list 'LaTeX-fontspec-font-list (match-string-no-properties 1)) + (add-to-list 'LaTeX-fontspec-font-list + (match-string-no-properties 2)))))) (TeX-argument-insert (completing-read (TeX-argument-prompt optional prompt "Font name") - LaTeX-fontspec-font-list) + (or LaTeX-fontspec-font-list LaTeX-fontspec-font-list-default)) optional)) (TeX-add-style-hook diff --git a/tex-style.el b/tex-style.el index 05a706e..41034d1 100644 --- a/tex-style.el +++ b/tex-style.el @@ -254,6 +254,28 @@ produced by emp.sty and then re-LaTeX the document." :type 'boolean :group 'LaTeX-style) +;; style/fontspec.el + +(defcustom LaTeX-fontspec-arg-font-search t + "If `LaTeX-fontspec-arg-font' should search for fonts. +If the value is t, fonts are retrieved and provided for +completion. If the value is nil, +`LaTeX-fontspec-font-list-default' is used for completion. If +the value is `ask', you are asked for the method to use every +time `LaTeX-fontspec-arg-font' is called. + +`LaTeX-fontspec-arg-font' calls `luaotf-load --list=basename' to +automatically get the list of fonts. This requires +`luaotfload-tool' version 2.3 or higher in order to work." + :group 'LaTeX-style + :type '(choice (const t) (const nil) (const ask))) + +(defcustom LaTeX-fontspec-font-list-default nil + "List of default fonts to be used as completion for +`LaTeX-fontspec-arg-font'." + :group 'LaTeX-style + :type '(repeat :tag "Font" (string))) + ;; style/graphicx.el (defcustom LaTeX-includegraphics-extensions