diff --git a/otagofonts.sty b/otagofonts.sty index 763f44e..edfb765 100644 --- a/otagofonts.sty +++ b/otagofonts.sty @@ -1,8 +1,8 @@ -\def\filedate{11 June 2024} +\def\filedate{26 June 2024} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Set up official Otago fonts based on what’s available. Fall back to close -% facsimiles where possible. +% Set up official Otago fonts based on what’s available. Fall back to reasonable +% alternatives where possible. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -13,41 +13,42 @@ % v1.3 Added new Wickliffe fonts and fallbacks. % v1.3.1 Switched serif font to Wickliffe Light. % v1.3.2 Switched bold fonts to Wickliffe (Sans) Medium. +% v1.4 Switched from mathspec to unicode-math, further font tweaks. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \NeedsTeXFormat{LaTeX2e}[2001/06/01] -\ProvidesPackage{otagofonts}[2024/06/11 Otago standard fonts v1.3.2] +\ProvidesPackage{otagofonts}[2024/06/26 Otago standard fonts v1.4] \RequirePackage{etoolbox} \RequirePackage{ifxetex} -\RequirePackage{amsmath} % needs to be loaded before mathspec +\RequirePackage{amsmath} \ifxetex \RequirePackage[no-math]{fontspec} -\RequirePackage{mathspec} +\RequirePackage{unicode-math} \RequirePackage{xunicode} \RequirePackage{xltxtra} -% Try a few different fonts that are either the official Otago font, or a reasonable -% facsimile thereof. Effectively done via a bunch of nested ifs. I did try using -% etoolbox's list looping macros, but the tricky part was making it generic for all -% three categories of font (primary, sans, mono), and I could only successfully make -% work for the first one encountered. The set of fonts is limited, so this is OK. +% Try a few different fonts that are either the official Otago font or a +% reasonable alternative, using etoolbox's list looping macros. The tricky +% part is making it generic for all three font categories (main, sans, mono), +% and I can only successfully make it work for the first one encountered. +% The set of fonts is limited, so this is OK. % -% Note: Explicitly specify Mapping=tex-text only for the primary and sans fonts, +% Note: Explicitly specify Mapping=tex-text only for the main and sans fonts, % otherwise curly quotes will automatically appear in the mono font. Since % this is pretty much exclusively used for code listings, this is a bad thing. -% Primary font (body text, maths). -\newbool{foundprimaryfont} -\PackageInfo{otagofonts}{Looking for suitable primary font} +% Main font (body text). +\newbool{foundmainfont} +\PackageInfo{otagofonts}{Looking for suitable main font} % font-specific defaults \defaultfontfeatures[Wickliffe Light]{BoldFont={Wickliffe Medium}} @@ -55,47 +56,35 @@ \renewcommand*{\do}[1]{% \PackageInfo{otagofonts}{Trying #1...} \IfFontExistsTF{#1}{% - % The following line is equivalent to: - % \setmainfont{fontname}[options] - % \setmathsfont(Latin,Digits){fontname} - % \setmathrm{fontname} - \setprimaryfont[Mapping=tex-text]{#1}% - \PackageInfo{otagofonts}{Using #1 for primary font}% - \booltrue{foundprimaryfont}% + \setmainfont{#1}[Mapping=tex-text]% + \PackageInfo{otagofonts}{Using #1 for main font}% + \booltrue{foundmainfont}% \listbreak% }{}% } -\docsvlist{Wickliffe Light,Minion Pro,Crimson Pro,Crimson Text,Georgia,Times New Roman} +\docsvlist{Wickliffe Light,Crimson Pro,Crimson Text,Georgia,TeX Gyre Pagella,Times New Roman} -\ifbool{foundprimaryfont}{% - % Hack to prevent digits in hyperlinks from being set in the main font instead of the mono font. - % Note: doesn't matter if this is executed multiple times. Only works if you use \setprimaryfont - % or \setmathsfont first. From https://tex.stackexchange.com/a/99774. - \makeatletter% - \DeclareMathSymbol{0}{\mathalpha}{\eu@DigitsArabic@symfont}{`0}% - \DeclareMathSymbol{1}{\mathalpha}{\eu@DigitsArabic@symfont}{`1}% - \DeclareMathSymbol{2}{\mathalpha}{\eu@DigitsArabic@symfont}{`2}% - \DeclareMathSymbol{3}{\mathalpha}{\eu@DigitsArabic@symfont}{`3}% - \DeclareMathSymbol{4}{\mathalpha}{\eu@DigitsArabic@symfont}{`4}% - \DeclareMathSymbol{5}{\mathalpha}{\eu@DigitsArabic@symfont}{`5}% - \DeclareMathSymbol{6}{\mathalpha}{\eu@DigitsArabic@symfont}{`6}% - \DeclareMathSymbol{7}{\mathalpha}{\eu@DigitsArabic@symfont}{`7}% - \DeclareMathSymbol{8}{\mathalpha}{\eu@DigitsArabic@symfont}{`8}% - \DeclareMathSymbol{9}{\mathalpha}{\eu@DigitsArabic@symfont}{`9}% - \makeatother% -}{% +\ifbool{foundmainfont}{}{% \PackageWarning{otagofonts}{% - Could not find any suitable primary font.\MessageBreak% + Could not find any suitable main font.\MessageBreak% Falling back to LaTeX default.\MessageBreak% Recommended fonts:\MessageBreak% - \space\space Minion Pro (official, commercial)\MessageBreak% + \space\space Wickliffe (official, proprietary)\MessageBreak% \space\space Crimson Pro (https://fonts.google.com/specimen/Crimson+Pro)% \space\space Crimson Text (https://fonts.google.com/specimen/Crimson+Text)% }% } +% Maths font. +% Use Latin Modern, the unicode-math default. It looks reasonably OK alongside +% many fonts including Wickliffe Light. It can always be manually overidden +% using \setmathfont if a better alternative is available. +\setmathfont{latinmodern-math.otf} +\setmathrm{latinmodern-math.otf} + + % Sans-serif font. \newbool{foundsansfont} \PackageInfo{otagofonts}{Looking for suitable sans-serif font} @@ -109,11 +98,7 @@ \renewcommand*{\do}[1]{% \PackageInfo{otagofonts}{Trying #1...} \IfFontExistsTF{#1}{% - % Scale=Match{Upper|Lower}case doesn't work very well for the sans fonts. - % By experimentation Scale=0.912 seems a good compromise, and eliminates the - % weird upscaling of sans fonts in Texlive 2020, which didn't seem to affect - % the serif or monospace fonts (?!?!). - \setsansfont{#1}[Scale=0.912]% + \setsansfont{#1}[Scale=MatchLowercase,Mapping=tex-text]% \PackageInfo{otagofonts}{Using #1 for sans-serif font}% \booltrue{foundsansfont}% \listbreak% @@ -126,6 +111,7 @@ \PackageWarning{otagofonts}{Could not find any suitable sans-serif font.\MessageBreak% Falling back to LaTeX default.\MessageBreak% Recommended fonts:\MessageBreak% + \space\space Wickliffe Sans (official, proprietary)\MessageBreak% \space\space Open Sans (https://fonts.google.com/specimen/Open+Sans)\MessageBreak% \space\space Roboto (https://fonts.google.com/specimen/Roboto)% }% @@ -142,7 +128,7 @@ \renewcommand*{\do}[1]{% \PackageInfo{otagofonts}{Trying #1...} \IfFontExistsTF{#1}{% - \setmonofont{#1}[Scale=MatchUppercase]% + \setmonofont{#1}[Scale=MatchLowercase,Mapping=]% \PackageInfo{otagofonts}{Using #1 for monospaced font}% \booltrue{foundmonofont}% \listbreak%