-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable #467
Conversation
@@ -608,6 +608,66 @@ \subsection{Letter spacing} | |||
In particular, small amounts of letter spacing can be very useful, when setting small caps or all caps titles. | |||
Also see the OpenType \opt{Uppercase} option of the \feat{Letters} feature (\vref{sec:letters}). | |||
|
|||
|
|||
\section{Variable fonts} \label{sec:variable} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is the best place for this, but since it's not really OpenType specific due to the MM stuff I thought that a generic place is best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay for now. The situation would anything non-OpenType fontspec is rather weird and uncertain
\subsection{Weight} \label{sec:variable-weight} | ||
For fonts with a variable weight axis, the weight can be specified through the | ||
\feat{Weight} feature. The value should be between 0 and 1000, where typically | ||
400 corresponds to regular wight and 700 is a bold font. | ||
\begin{Verbatim} | ||
\fontspec{Source Serif Variable}[Weight=700] | ||
Bold \\ | ||
\fontspec{Source Serif Variable}[Weight=200] | ||
Extra Light \\ | ||
\end{Verbatim} | ||
|
||
|
||
\subsection{Width} \label{sec:variable-width} | ||
Similarly, the \feat{Width} feature allows specifying the value of the width axis, | ||
where the value is a percentage of normal width. | ||
\begin{Verbatim} | ||
\fontspec{Noto Serif}[Width=100] | ||
Normal Width \\ | ||
\fontspec{Noto Serif}[Width=75] | ||
Condensed \\ | ||
\end{Verbatim} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not tested with Multiple Master fonts, but since the code was already there I assume that it works for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see if anyone actually tries :) From memory MacOS has deprecated a number of APIs that XeTeX used to use to make this work in the older xdv2pdf backend. I can't recall what xdvipdfmx does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xdvipdfmx never supported Apple GX, and when xdv2pdf was finally retired I foolishly removed GX support from XeTeX as being dead technology (I thought no the primitives are still there by they do nothing).
\ifluahbtex | ||
\defaultfontfeatures{Renderer=HarfBuzz} | ||
\fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature generally also works for the Node
renderer, but the HarfBuzz supports is a bit more consistent IMO. (I'm probably biased though)
fontspec-code-internal.dtx
Outdated
% \begin{macro}{\@@_get_variations:} | ||
% \cmd{\@@_get_variations:} builds the feature string representing the | ||
% current variation instance and/or axis settings. | ||
% \begin{macrocode} | ||
\cs_new:Nn \@@_format_axis:nn | ||
{ | ||
#1 = #2 , | ||
} | ||
\cs_new:Nn \@@_get_variations: | ||
{ | ||
\tl_if_empty:NF \g_@@_instance_tl | ||
{ | ||
instance = { \g_@@_instance_tl }; | ||
} | ||
\prop_if_empty:NF \g_@@_rawvariations_prop | ||
{ | ||
axis = { | ||
\prop_map_function:NN \g_@@_rawvariations_prop \@@_format_axis:nn | ||
}; | ||
} | ||
} | ||
% \end{macrocode} | ||
% \end{macro} | ||
% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not made LuaTeX specific since I could imagine a similar interface applying to XeTeX too if they ever get Variable font support.
This would require adding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing, thank you so much! I had one question about naming -- wdyt?
I am sorry I have never had the time to explore this properly, I have always been very excited for MM technology. Sigh, if only there were more hours in the day. Next someone needs to integrate microtype expansion using variable axes fonts :)
@@ -608,6 +608,66 @@ \subsection{Letter spacing} | |||
In particular, small amounts of letter spacing can be very useful, when setting small caps or all caps titles. | |||
Also see the OpenType \opt{Uppercase} option of the \feat{Letters} feature (\vref{sec:letters}). | |||
|
|||
|
|||
\section{Variable fonts} \label{sec:variable} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay for now. The situation would anything non-OpenType fontspec is rather weird and uncertain
% \subsubsection{Variation instances} | ||
% | ||
% \begin{macrocode} | ||
\@@_keys_define_code:nnn {fontspec-opentype} {Instance} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "Instance" specific enough or would "VariationInstance" be better? (Not sure, just thinking out loud). WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really have a qualified opinion on that. Personally I prefer Instance, but that's purely subjective.
\subsection{Weight} \label{sec:variable-weight} | ||
For fonts with a variable weight axis, the weight can be specified through the | ||
\feat{Weight} feature. The value should be between 0 and 1000, where typically | ||
400 corresponds to regular wight and 700 is a bold font. | ||
\begin{Verbatim} | ||
\fontspec{Source Serif Variable}[Weight=700] | ||
Bold \\ | ||
\fontspec{Source Serif Variable}[Weight=200] | ||
Extra Light \\ | ||
\end{Verbatim} | ||
|
||
|
||
\subsection{Width} \label{sec:variable-width} | ||
Similarly, the \feat{Width} feature allows specifying the value of the width axis, | ||
where the value is a percentage of normal width. | ||
\begin{Verbatim} | ||
\fontspec{Noto Serif}[Width=100] | ||
Normal Width \\ | ||
\fontspec{Noto Serif}[Width=75] | ||
Condensed \\ | ||
\end{Verbatim} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see if anyone actually tries :) From memory MacOS has deprecated a number of APIs that XeTeX used to use to make this work in the older xdv2pdf backend. I can't recall what xdvipdfmx does
Status
READY/FOR DISCUSSION
Description
Add an interface for loading variable fonts under LuaLaTeX.
While fontspec already had undocumented
Width
andWeight
font features (probably for Multiple Master fonts), these didn't set the current values to work for Variable fonts with luaotfload. Also there was no interface to set arbitrary axes. This was particularly problematic sinceluaotfload
expects all axis values to be passed in a singleaxis
feature, so usingRawFeature
to set one axis overwrites the values for all previously set axes.Therefore this PR, besides making
Weight
andWidth
compatible with luaotfload and Variable fonts, adds a companion toRawFeature
calledRawAxis
which allows to set arbitrary axis values.Todos
Minimal example demonstrating the new/fixed functionality