[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 6cac3e5 13/57: Update style/fontspec.el to packa
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 6cac3e5 13/57: Update style/fontspec.el to package version 2.6a |
Date: |
Tue, 25 Jul 2017 14:02:28 -0400 (EDT) |
branch: externals/auctex
commit 6cac3e59a1d9eaccc52cd9116aa28a91cff95760
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Update style/fontspec.el to package version 2.6a
* style/fontspec.el (LaTeX-fontspec-font-features): Update
variable to package version 2.6a.
(LaTeX-fontspec-auto-cleanup): New function for parsing support
for \newfontfamily and \newfontface macros.
("fontspec"): Add missing macros and environment.
(LaTeX-fontspec-package-options): Update with new options.
---
style/fontspec.el | 396 ++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 280 insertions(+), 116 deletions(-)
diff --git a/style/fontspec.el b/style/fontspec.el
index 5ec7bb4..58f4e48 100644
--- a/style/fontspec.el
+++ b/style/fontspec.el
@@ -1,9 +1,9 @@
-;;; fontspec.el --- AUCTeX style for `fontspec.sty' version 2.3c.
+;;; fontspec.el --- AUCTeX style for `fontspec.sty' version 2.6a.
-;; Copyright (C) 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2017 Free Software Foundation, Inc.
;; Maintainer: address@hidden
-;; Author: Mosè Giordano <address@hidden>
+;; Author: Mosè Giordano <address@hidden>
;; Keywords: tex
;; This file is part of AUCTeX.
@@ -25,94 +25,119 @@
;;; Commentary:
-;; This file adds support for `fontspec.sty' version 2.3c.
+;; This file adds support for `fontspec.sty' version 2.6a. Starting
+;; with `fontspec.sty' v2.4, the order of mandatory font names and
+;; optional font features in related macros has changed, i.e. optional
+;; argument comes after the mandatory one. This change is now (April
+;; 2017) implemented in this file. Fontification support retains
+;; backward compatibilty.
;;; Code:
(defvar LaTeX-fontspec-font-features
- '(;; More control over font shape selection
+ '(;; 5 Font selection
+ ("Extension" (".otf" ".ttf" ".ttc" ".dfont"))
+ ("Path")
+ ;; 6.1 More control over font shape selection
("BoldFont")
("ItalicFont")
("BoldItalicFont")
("SlantedFont")
("BoldSlantedFont")
("SmallCapsFont")
- ;; Different features for different font shapes
+ ;; 6.2 Specifically choosing the NFSS family
+ ("NFSSFamily")
+ ("FontFace")
+ ;; 11 Different features for different font shapes
+ ("UprightFeatures")
("BoldFeatures")
("ItalicFeatures")
("BoldItalicFeatures")
("SlantedFeatures")
("BoldSlantedFeatures")
("SmallCapsFeatures")
- ;; Different features for different font sizes
+ ;; 13 Different features for different font sizes
("SizeFeatures")
- ;; Font independent options
+ ;; 14 Font independent options
("Color")
("Scale" ("MatchLowercase" "MatchUppercase"))
("WordSpace")
("PunctuationSpace")
("HyphenChar")
("OpticalSize")
- ;; OpenType options
- ("Ligatures" ("Required"
- "NoRequired"
- "Common"
- "NoCommon"
- "Contextual"
- "NoContextual"
- "Rare"
- "Historic"
- "TeX"))
- ("Letters" ("Uppercase"
- "SmallCaps"
- "PetiteCaps"
- "UppercaseSmallCaps"
- "UppercasePetiteCaps"
- "Unicase"))
- ("Numbers" ("Lining"
- "OldStyle"
- "Proportional"
- "Monospaced"
- "SlashedZero"
- "Arabic"))
- ("Contextuals" ("Swash"
- "Alternate"
- "WordInitial"
- "WordFinal"
- "LineFinal"
- "Inner"))
- ("VerticalPosition" ("Superior"
- "Inferior"
- "Numerator"
- "Denominator"
- "ScientificInferior"
- "Ordinal"))
- ("Fraction" ("On" "Alternate"))
- ("StylisticSet")
- ("CharacterVariants")
- ("Alternate")
- ("Style" ("Alternate"
- "Italic"
- "Ruby"
- "Swash"
- "Historic"
- "TitlingCaps"
- "HorizontalKana"
- "VerticalKana"))
- ("Diacritics" ("MarkToBase"
- "NoMarkToBase"
- "MarkToMark"
- "NoMarkToMark"
- "AboveBase"
- "NoAboveBase"
- "BelowBase"
- "NoBelowBase"))
- ("Kerning" ("Uppercase" "On" "Off"))
("AutoFakeBold")
("AutoFakeSlant")
("FakeSlant")
("FakeStretch")
("FakeBold")
+ ("LetterSpace")
+ ;; 16 OpenType options
+ ("Ligatures" ("Required" "RequiredOff"
+ "Common" "CommonOff"
+ "Contextual" "ContextualOff"
+ "Rare" "RareOff"
+ "Discretionary" "DiscretionaryOff"
+ "Historic" "HistoricOff"
+ "TeX"
+ "ResetAll"))
+ ("Letters" ("Uppercase" "UppercaseOff"
+ "SmallCaps" "SmallCapsOff"
+ "PetiteCaps" "PetiteCapsOff"
+ "UppercaseSmallCaps" "UppercaseSmallCapsOff"
+ "UppercasePetiteCaps" "UppercasePetiteCapsOff"
+ "Unicase" "UnicaseOff"
+ "ResetAll"))
+ ("Numbers" ("Uppercase" "UppercaseOff"
+ "Lowercase" "LowercaseOff"
+ "Lining" "LiningOff"
+ "OldStyle" "OldStyleOff"
+ "Proportional" "ProportionalOff"
+ "Monospaced" "MonospacedOff"
+ "SlashedZero" "SlashedZeroOff"
+ "Arabic" "ArabicOff"
+ "ResetAll"))
+ ("Contextuals" ("Swash" "SwashOff"
+ "Alternate" "AlternateOff"
+ "WordInitial" "WordInitialOff"
+ "WordFinal" "WordFinalOff"
+ "LineFinal" "LineFinalOff"
+ "Inner" "InnerOff"
+ "ResetAll"))
+ ("VerticalPosition" ("Superior" "SuperiorOff"
+ "Inferior" "InferiorOff"
+ "Numerator" "NumeratorOff"
+ "Denominator" "DenominatorOff"
+ "ScientificInferior" "ScientificInferiorOff"
+ "Ordinal" "OrdinalOff"
+ "ResetAll"))
+ ("Fraction" ("On" "Off" "Reset" "Alternate" "AlternateOff" "ResetAll"))
+ ("StylisticSet")
+ ("CharacterVariant")
+ ("Alternate" ("Random"))
+ ("Style" ("Alternate" "AlternateOff"
+ "Italic" "ItalicOff"
+ "Ruby" "RubyOff"
+ "Swash" "SwashOff"
+ "Cursive" "CursiveOff"
+ "Historic" "HistoricOff"
+ "TitlingCaps" "TitlingCapsOff"
+ "HorizontalKana" "HorizontalKanaOff"
+ "VerticalKana" "VerticalKanaOff"
+ "ResetAll"))
+ ("Diacritics" ("MarkToBase" "MarkToBaseOff"
+ "MarkToMark" "MarkToMarkOff"
+ "AboveBase" "AboveBaseOff"
+ "BelowBase" "BelowBaseOff"
+ "ResetAll"))
+ ("Kerning" ("Uppercase" "UppercaseOff" "On" "Off" "Reset" "ResetAll"))
+ ("CharacterWidth" ("Proportional" "ProportionalOff"
+ "Full" "FullOff"
+ "Half" "HalfOff"
+ "Third" "ThirdOff"
+ "Quarter" "QuarterOff"
+ "AlternateProportional" "AlternateProportionalOff"
+ "AlternateHalf" "AlternateHalfOff"
+ "ResetAll"))
("Annotation")
("CJKShape" ("Traditional"
"Simplified"
@@ -121,16 +146,24 @@
"JIS1990"
"Expert"
"NLC"))
- ("CharacterWidth" ("Proportional"
- "Full"
- "Half"
- "Third"
- "Quarter"
- "AlternateProportional"
- "AlternateHalf"))
- ("Vertical" ("RotatedGlyphs")))
+ ("Vertical" ("RotatedGlyphs" "RotatedGlyphsOff"
+ "AlternatesForRotation" "AlternatesForRotationOff"
+ "Alternates" "AlternatesOff"
+ "KanaAlternates" "KanaAlternatesOff"
+ "Kerning" "KerningOff"
+ "AlternateMetrics" "AlternateMetricsOff"
+ "HalfMetrics" "HalfMetricsOff"
+ "ProportionalMetrics" "ProportionalMetricsOff"
+ "ResetAll"))
+ ;; 25 Going behind fontspec's back: Offer only an excerpt of all
+ ;; possible tags:
+ ("RawFeature" ("frac" "lnum" "onum" "pnum" "smcp" "tnum" "zero")))
"Font features options for macros of the fontspec package.")
+(defvar LaTeX-fontspec-font-features-local nil
+ "Buffer-local font features options for macros of the fontspec package.")
+(make-variable-buffer-local 'LaTeX-fontspec-font-features-local)
+
(defvar LaTeX-fontspec-font-list nil
"List of the fonts accessible to fontspec.")
@@ -163,74 +196,205 @@ to retrieve the list of fonts."
(or LaTeX-fontspec-font-list LaTeX-fontspec-font-list-default))
optional))
+(defun LaTeX-fontspec-update-font-features ()
+ "Update Color key=values in `LaTeX-fontspec-font-features-local'."
+ ;; Check if any color defininig package is loaded and update the
+ ;; key=values for coloring. Prefer xcolor.sty if both packages are
+ ;; loaded.
+ (when (or (member "xcolor" (TeX-style-list))
+ (member "color" (TeX-style-list)))
+ (let* ((colorcmd (if (member "xcolor" (TeX-style-list))
+ #'LaTeX-xcolor-definecolor-list
+ #'LaTeX-color-definecolor-list))
+ (tmp (copy-alist LaTeX-fontspec-font-features-local)))
+ (setq tmp (assq-delete-all (car (assoc "Color" tmp)) tmp))
+ (push (list "Color" (mapcar #'car (funcall colorcmd))) tmp)
+ (setq LaTeX-fontspec-font-features-local
+ (copy-alist tmp)))))
+
+;; Setup for \newfontfamily and \newfontface:
+(TeX-auto-add-type "fontspec-newfontcmd" "LaTeX")
+
+(defvar LaTeX-fontspec-newfontcmd-regexp
+ '("\\\\newfontfa\\(?:ce\\|mily\\)[ \t\n\r%]*\\\\\\([a-zA-Z]+\\)"
+ 1 LaTeX-auto-fontspec-newfontcmd)
+ "Matches new macros defined with \\newfontface and \\newfontfamily.")
+
+(defun LaTeX-fontspec-auto-prepare ()
+ "Clear `LaTeX-auto-fontspec-newfontcmd' before parsing."
+ (setq LaTeX-auto-fontspec-newfontcmd nil))
+
+(defun LaTeX-fontspec-auto-cleanup ()
+ "Process parsed elements for fontspec package."
+ (dolist (mac (mapcar #'car (LaTeX-fontspec-newfontcmd-list)))
+ ;; Add macro to list of known macros
+ (TeX-add-symbols mac)
+ ;; Cater for fontification
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords `((,mac ""))
+ 'type-declaration)))
+ ;; Update values of Color key:
+ (LaTeX-fontspec-update-font-features))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-fontspec-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-fontspec-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
(TeX-add-style-hook
"fontspec"
(lambda ()
(TeX-check-engine-add-engines 'luatex 'xetex)
(TeX-run-style-hooks "expl3" "xparse")
+
+ ;; Add fontspec to the parser.
+ (TeX-auto-add-regexp LaTeX-fontspec-newfontcmd-regexp)
+
+ ;; Activate the buffer local version of font features:
+ (setq LaTeX-fontspec-font-features-local
+ (copy-alist LaTeX-fontspec-font-features))
+
(TeX-add-symbols
- ;; Font selection
- '("fontspec" [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- LaTeX-fontspec-arg-font)
+ ;; 4.3 Commands for old-style and lining numbers: \oldstylenums is
+ ;; already provided by LaTeX, so just add \liningnums here
+ '("liningnums" "Numbers")
+
+ ;; 4.5 Emphasis and nested emphasis
+ ;; \emshape seems to be an internal macro
+ "emshape"
+ '("emfontdeclare" t)
+ "emreset"
+
+ ;; 4.6 Strong emphasis
+ '("strong" t)
+ '("strongfontdeclare" t)
+ "strongreset"
+
+ ;; 5 Font selection
+ '("fontspec"
+ LaTeX-fontspec-arg-font
+ [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+
;; Default font families
'("setmainfont"
- [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- (LaTeX-fontspec-arg-font "Main font name"))
+ (LaTeX-fontspec-arg-font "Main font name")
+ [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
'("setsansfont"
- [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- (LaTeX-fontspec-arg-font "Sans font name"))
+ (LaTeX-fontspec-arg-font "Sans font name")
+ [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
'("setmonofont"
- [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- (LaTeX-fontspec-arg-font "Mono font name"))
- ;; New commands to select font families
+ (LaTeX-fontspec-arg-font "Mono font name")
+ [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+
+ ;; 5.3 Querying whether a font exists
+ '("IfFontExistsTF" LaTeX-fontspec-arg-font 2)
+
+ ;; 6 commands to select font families
'("newfontfamily" TeX-arg-define-macro
- [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- LaTeX-fontspec-arg-font)
+ LaTeX-fontspec-arg-font
+ [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+
'("newfontface" TeX-arg-define-macro
- [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- LaTeX-fontspec-arg-font)
- ;; Math(s) fonts
- '("setmathrm" [ "Font features" ] "Font name")
- '("setmathsf" [ "Font features" ] "Font name")
- '("setmathtt" [ "Font features" ] "Font name")
- '("setboldmathrm" [ "Font features" ] "Font name")
- ;; Emphasis and nested emphasis
- "emshape"
- "eminnershape"
- ;; Default settings
+ LaTeX-fontspec-arg-font
+ [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+
+ ;; 6.4 Math(s) fonts
+ '("setmathrm" "Font name" [ "Font features" ])
+ '("setmathsf" "Font name" [ "Font features" ])
+ '("setmathtt" "Font name" [ "Font features" ])
+ '("setboldmathrm" "Font name" [ "Font features" ])
+
+ ;; 8 Default settings
'("defaultfontfeatures" [ LaTeX-fontspec-arg-font ]
- (TeX-arg-key-val LaTeX-fontspec-font-features "Font features"))
+ (TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"))
+ '("defaultfontfeatures+" [ LaTeX-fontspec-arg-font ]
+ (TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"))
+
+ ;; 10 Working with the currently selected features
+ '("IfFontFeatureActiveTF"
+ [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font feature"] 2)
+
;; Changing the currently selected features
'("addfontfeatures"
- (TeX-arg-key-val LaTeX-fontspec-font-features "Font features"))
- ;; Defining new scripts and languages
+ (TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"))
+
+ ;; 23 Defining new features
+ '("newAATfeature"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Existing feature")
+ LaTeX-fontspec-font-features-local)
+ "New option" 2)
+
+ '("newopentypefeature"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Existing feature")
+ LaTeX-fontspec-font-features-local)
+ "New option" t)
+
+ '("newfontfeature" "New feature" t)
+
+ ;; 24 Defining new scripts and languages
'("newfontscript" "Script name" "OpenType tag")
- '("newfontlanguage" "Language name" "OpenType tag"))
+ '("newfontlanguage" "Language name" "OpenType tag")
+
+ ;; 26 Renaming existing features & options
+ '("aliasfontfeature"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Existing feature")
+ LaTeX-fontspec-font-features-local)
+ "New name")
+
+ '("aliasfontfeatureoption"
+ (TeX-arg-eval
+ (lambda ()
+ (let* ((key (completing-read
+ (TeX-argument-prompt optional nil "Feature")
+ LaTeX-fontspec-font-features-local))
+ (val (completing-read
+ (TeX-argument-prompt optional nil "Existing name")
+ (cadr (assoc key LaTeX-fontspec-font-features-local)))))
+ (TeX-argument-insert key optional)
+ (format "%s" val))))
+ "New name") )
+
+ (LaTeX-add-environments
+ ;; 4.6 Strong emphasis
+ '("strong"))
;; Fontification
(when (and (featurep 'font-latex)
(eq TeX-install-font-lock 'font-latex-setup))
- (font-latex-add-keywords '(("fontspec" "[{")
- ("setmainfont" "[{")
- ("setsansfont" "[{")
- ("setmonofont" "[{")
- ("newfontfamily" "\\[{")
- ("newfontface" "\\[{")
- ("setmathrm" "[{")
- ("setmathsf" "[{")
- ("setmathtt" "[{")
- ("setboldmathrm" "[{")
- ("emshape")
- ("eminnershape")
- ("defaultfontfeatures" "[{")
- ("addfontfeature" "{")
- ("newfontscript" "{{")
- ("newfontlanguage" "{{"))
- 'function)))
+ (font-latex-add-keywords '(("fontspec" "[{[")
+ ("setmainfont" "[{[")
+ ("setsansfont" "[{[")
+ ("setmonofont" "[{[")
+ ("newfontfamily" "\\[{[")
+ ("newfontface" "\\[{[")
+ ("setmathrm" "[{[")
+ ("setmathsf" "[{[")
+ ("setmathtt" "[{[")
+ ("setboldmathrm" "[{[")
+ ("defaultfontfeatures" "+[{")
+ ("addfontfeature" "{")
+ ("addfontfeatures" "{")
+ ("newfontscript" "{{")
+ ("newfontlanguage" "{{")
+ ("emfontdeclare" "{")
+ ("strongfontdeclare" "{")
+ ("newAATfeature" "{{{{")
+ ("newopentypefeature" "{{{")
+ ("newfontfeature" "{{")
+ ("aliasfontfeature" "{{")
+ ("aliasfontfeatureoption" "{{{"))
+ 'function)
+ (font-latex-add-keywords '(("liningnums" "{"))
+ 'type-command)
+ (font-latex-add-keywords '(("strong" "{"))
+ 'bold-command)))
LaTeX-dialect)
(defvar LaTeX-fontspec-package-options
- '("math" "no-math" "config" "no-config" "quiet" "silent")
+ '("tuenc" "euenc" "math" "no-math" "config" "no-config" "quiet" "silent")
"Package options for the fontspec package.")
;;; fontspec.el ends here
- [elpa] externals/auctex 7eab03a 20/57: * tex-ispell.el: Move entries from style/empheq.el to this file., (continued)
- [elpa] externals/auctex 7eab03a 20/57: * tex-ispell.el: Move entries from style/empheq.el to this file., Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 0e4ad85 21/57: * latex/preview.dtx: Adjust contact email address., Tassilo Horn, 2017/07/25
- [elpa] externals/auctex d004ac7 28/57: * tex.el (TeX-command-list): Fix typo in help string (mendex -> upmendex), Tassilo Horn, 2017/07/25
- [elpa] externals/auctex cd28c6f 23/57: Improve further the exclusion of reserved characters, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex f472378 22/57: Work around bug#26694, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex bde89b9 27/57: * latex.el (LaTeX-env-label-as-keyval): Use `buffer-substring-no-properties'., Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 7249c78 11/57: * latex.el (LaTeX-common-initialization): Add eminnershape macro., Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 00c76fb 29/57: Don't discard process output with `TeX-run-silent', Tassilo Horn, 2017/07/25
- [elpa] externals/auctex aed9191 33/57: * tests/tex/compilation-log.txt:, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 4d426ea 37/57: Suggest to rerun LaTeX if xsim properties changed, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 6cac3e5 13/57: Update style/fontspec.el to package version 2.6a,
Tassilo Horn <=
- [elpa] externals/auctex e0d067f 53/57: Manually cherry-pick commit bc0db60e, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 42aa58c 40/57: Add support for xreader viewer, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex cd1075b 43/57: Add new style/canadian.el, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex fa24654 55/57: * font-latex.el: Use the standard utf-8 rather than latin-1, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 8e89a80 17/57: Add new style/floatrow.el, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 32f71f6 57/57: Release GNU AUCTeX 11.91.0, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 370a4b9 31/57: Resolve preview-latex incompatibility with Japanese TeX (Bug#25322), Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 8c172d5 51/57: ; make change-history-commit, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex fbbb17b 39/57: Update key=value options to graphicx package version 1.1a, Tassilo Horn, 2017/07/25
- [elpa] externals/auctex 97dca3f 52/57: ; Release_11.91, Tassilo Horn, 2017/07/25