1 ;;; fontspec.el --- AUCTeX style for `fontspec.sty' version 2.3c.
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
5 ;; Maintainer: auctex-devel@gnu.org
6 ;; Author: Mosè Giordano <giordano.mose@libero.it>
9 ;; This file is part of AUCTeX.
11 ;; AUCTeX is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 ;; This file adds support for `fontspec.sty' version 2.3c.
32 (defvar LaTeX-fontspec-font-features
33 '(;; More control over font shape selection
40 ;; Different features for different font shapes
43 ("BoldItalicFeatures")
45 ("BoldSlantedFeatures")
47 ;; Different features for different font sizes
49 ;; Font independent options
51 ("Scale" ("MatchLowercase" "MatchUppercase"))
57 ("Ligatures" ("Required"
66 ("Letters" ("Uppercase"
78 ("Contextuals" ("Swash"
84 ("VerticalPosition" ("Superior"
90 ("Fraction" ("On" "Alternate"))
102 ("Diacritics" ("MarkToBase"
110 ("Kerning" ("Uppercase" "On" "Off"))
117 ("CJKShape" ("Traditional"
124 ("CharacterWidth" ("Proportional"
129 "AlternateProportional"
131 ("Vertical" ("RotatedGlyphs")))
132 "Font features options for macros of the fontspec package.")
134 (defvar LaTeX-fontspec-font-list nil
135 "List of the fonts accessible to fontspec.")
137 (defun LaTeX-fontspec-arg-font (optional &optional prompt)
138 "Prompt for a font name with completion.
139 If OPTIONAL is non-nil, insert the resulting value as an optional
140 argument, otherwise as a mandatory one. Use PROMPT as the prompt
143 Customize `LaTeX-fontspec-arg-font-search' in order to decide how
144 to retrieve the list of fonts."
145 (unless LaTeX-fontspec-font-list
146 (when (if (eq LaTeX-fontspec-arg-font-search 'ask)
147 (not (y-or-n-p "Find font yourself? "))
148 LaTeX-fontspec-arg-font-search)
149 (message "Searching for fonts...")
151 (shell-command "luaotfload-tool --list=basename" t)
152 ;; Search for the font base names and full names, and add them to
153 ;; `LaTeX-fontspec-font-list'. The list is in the form
154 ;; <base name><TAB><full name><TAB><version>
156 (re-search-forward "^\\([^\n\r\t]*\\)\t\\([^\n\r\t]*\\)\t.*$" nil t)
157 (add-to-list 'LaTeX-fontspec-font-list (match-string-no-properties 1))
158 (add-to-list 'LaTeX-fontspec-font-list
159 (match-string-no-properties 2))))))
162 (TeX-argument-prompt optional prompt "Font name")
163 (or LaTeX-fontspec-font-list LaTeX-fontspec-font-list-default))
169 (TeX-run-style-hooks "expl3" "xparse")
172 '("fontspec" [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
173 LaTeX-fontspec-arg-font)
174 ;; Default font families
176 [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
177 (LaTeX-fontspec-arg-font "Main font name"))
179 [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
180 (LaTeX-fontspec-arg-font "Sans font name"))
182 [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
183 (LaTeX-fontspec-arg-font "Mono font name"))
184 ;; New commands to select font families
185 '("newfontfamily" TeX-arg-define-macro
186 [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
187 LaTeX-fontspec-arg-font)
188 '("newfontface" TeX-arg-define-macro
189 [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
190 LaTeX-fontspec-arg-font)
192 '("setmathrm" [ "Font features" ] "Font name")
193 '("setmathsf" [ "Font features" ] "Font name")
194 '("setmathtt" [ "Font features" ] "Font name")
195 '("setboldmathrm" [ "Font features" ] "Font name")
196 ;; Emphasis and nested emphasis
200 '("defaultfontfeatures" [ LaTeX-fontspec-arg-font ]
201 (TeX-arg-key-val LaTeX-fontspec-font-features "Font features"))
202 ;; Changing the currently selected features
204 (TeX-arg-key-val LaTeX-fontspec-font-features "Font features"))
205 ;; Defining new scripts and languages
206 '("newfontscript" "Script name" "OpenType tag")
207 '("newfontlanguage" "Language name" "OpenType tag"))
210 (when (and (featurep 'font-latex)
211 (eq TeX-install-font-lock 'font-latex-setup))
212 (font-latex-add-keywords '(("fontspec" "[{")
216 ("newfontfamily" "{[{")
217 ("newfontface" "{[{")
221 ("setboldmathrm" "[{")
224 ("defaultfontfeatures" "[{")
225 ("addfontfeature" "{")
226 ("newfontscript" "{{")
227 ("newfontlanguage" "{{"))
231 (defvar LaTeX-fontspec-package-options
232 '("math" "no-math" "config" "no-config" "quiet" "silent")
233 "Package options for the fontspec package.")
235 ;;; fontspec.el ends here