Just for illustration only, to show what is possible:
Output along the weight axis (theoretically, from 1-1000):

Along the width axis (a percentage, generally something like 75%-125%, whatever the font designer has defined):

(Note the म in the current version of the font, 1.002, has a bug at width < 100% and width > 100%.)
Along both axes simultaneously:

MWE
*Just for reference. A real-world use-case would use one \newfontfamily
plus associated \textXX
commands across maybe only three or four axis-settings, rather than 64+ \newfontface
commands (here, the multi-face method was used as part of a quick 5-minute code copy-paste)).
\documentclass[12pt]{article}
\newcommand\myfontpath{C:/Users/...really long path name .../}
\newcommand\test{मराठी मजकूर}
\newcommand\testb{मराठी}
\newcommand\fsetting{Path=\myfontpath,
Extension=.ttf,
Colour=blue,
UprightFont=*,
}
\newcommand\fname{AnekDevanagari[wdth,wght]}
\usepackage{xcolor}
\usepackage{fontspec}
\defaultfontfeatures{RawFeature={+axis={wght=400,wdth=100}}}
\setmainfont[
Path=\myfontpath,
Extension=.ttf,
UprightFont=*,
]{AnekDevanagari[wdth,wght]}
\newfontface\AnekBoldc[
Path=\myfontpath,
Extension=.ttf,
Colour=blue,
UprightFont=*,
UprightFeatures={RawFeature={+axis={wght=200,wdth=180}}},
BoldFont=*,
BoldFeatures={RawFeature={+axis={wght=900,wdth=125}}},
]{AnekDevanagari[wdth,wght]}
\newfontface\AnekBoldb[
Path=\myfontpath,
Extension=.ttf,
UprightFont=*,
BoldFont=*,
BoldFeatures={RawFeature={+axis={wght=700}}},
]{AnekDevanagari[wdth,wght]}
%---
\newfontface\AnekDga[\fsetting
UprightFeatures={RawFeature={+axis={wght=100}}},]{\fname}
\newfontface\AnekDgb[\fsetting
UprightFeatures={RawFeature={+axis={wght=200}}},]{\fname}
\newfontface\AnekDgc[\fsetting
UprightFeatures={RawFeature={+axis={wght=300}}},]{\fname}
\newfontface\AnekDgd[\fsetting
UprightFeatures={RawFeature={+axis={wght=400}}},]{\fname}
\newfontface\AnekDge[\fsetting
UprightFeatures={RawFeature={+axis={wght=500}}},]{\fname}
\newfontface\AnekDgf[\fsetting
UprightFeatures={RawFeature={+axis={wght=600}}},]{\fname}
\newfontface\AnekDgg[\fsetting
UprightFeatures={RawFeature={+axis={wght=700}}},]{\fname}
\newfontface\AnekDgh[\fsetting
UprightFeatures={RawFeature={+axis={wght=800}}},]{\fname}
%---
\newfontface\AnekDda[\fsetting
UprightFeatures={RawFeature={+axis={wdth=75}}},]{\fname}
\newfontface\AnekDdb[\fsetting
UprightFeatures={RawFeature={+axis={wdth=80}}},]{\fname}
\newfontface\AnekDdc[\fsetting
UprightFeatures={RawFeature={+axis={wdth=90}}},]{\fname}
\newfontface\AnekDdd[\fsetting
UprightFeatures={RawFeature={+axis={wdth=100}}},]{\fname}
\newfontface\AnekDde[\fsetting
UprightFeatures={RawFeature={+axis={wdth=110}}},]{\fname}
\newfontface\AnekDdf[\fsetting
UprightFeatures={RawFeature={+axis={wdth=115}}},]{\fname}
\newfontface\AnekDdg[\fsetting
UprightFeatures={RawFeature={+axis={wdth=120}}},]{\fname}
\newfontface\AnekDdh[\fsetting
UprightFeatures={RawFeature={+axis={wdth=125}}},]{\fname}
%--- Grid
\newfontface\AnekDgdaa[\fsetting UprightFeatures={RawFeature={+axis={wght=100,wdth=75}}},]{\fname} \newfontface\AnekDgdab[\fsetting UprightFeatures={RawFeature={+axis={wght=100,wdth=80}}},]{\fname} \newfontface\AnekDgdac[\fsetting UprightFeatures={RawFeature={+axis={wght=100,wdth=90}}},]{\fname} \newfontface\AnekDgdad[\fsetting UprightFeatures={RawFeature={+axis={wght=100,wdth=100}}},]{\fname} \newfontface\AnekDgdae[\fsetting UprightFeatures={RawFeature={+axis={wght=100,wdth=110}}},]{\fname} \newfontface\AnekDgdaf[\fsetting UprightFeatures={RawFeature={+axis={wght=100,wdth=115}}},]{\fname} \newfontface\AnekDgdag[\fsetting UprightFeatures={RawFeature={+axis={wght=100,wdth=120}}},]{\fname} \newfontface\AnekDgdah[\fsetting UprightFeatures={RawFeature={+axis={wght=100,wdth=125}}},]{\fname}
\newfontface\AnekDgdba[\fsetting UprightFeatures={RawFeature={+axis={wght=200,wdth=75}}},]{\fname} \newfontface\AnekDgdbb[\fsetting UprightFeatures={RawFeature={+axis={wght=200,wdth=80}}},]{\fname} \newfontface\AnekDgdbc[\fsetting UprightFeatures={RawFeature={+axis={wght=200,wdth=90}}},]{\fname} \newfontface\AnekDgdbd[\fsetting UprightFeatures={RawFeature={+axis={wght=200,wdth=100}}},]{\fname} \newfontface\AnekDgdbe[\fsetting UprightFeatures={RawFeature={+axis={wght=200,wdth=110}}},]{\fname} \newfontface\AnekDgdbf[\fsetting UprightFeatures={RawFeature={+axis={wght=200,wdth=115}}},]{\fname} \newfontface\AnekDgdbg[\fsetting UprightFeatures={RawFeature={+axis={wght=200,wdth=120}}},]{\fname} \newfontface\AnekDgdbh[\fsetting UprightFeatures={RawFeature={+axis={wght=200,wdth=125}}},]{\fname}
\newfontface\AnekDgdca[\fsetting UprightFeatures={RawFeature={+axis={wght=300,wdth=75}}},]{\fname} \newfontface\AnekDgdcb[\fsetting UprightFeatures={RawFeature={+axis={wght=300,wdth=80}}},]{\fname} \newfontface\AnekDgdcc[\fsetting UprightFeatures={RawFeature={+axis={wght=300,wdth=90}}},]{\fname} \newfontface\AnekDgdcd[\fsetting UprightFeatures={RawFeature={+axis={wght=300,wdth=100}}},]{\fname} \newfontface\AnekDgdce[\fsetting UprightFeatures={RawFeature={+axis={wght=300,wdth=110}}},]{\fname} \newfontface\AnekDgdcf[\fsetting UprightFeatures={RawFeature={+axis={wght=300,wdth=115}}},]{\fname} \newfontface\AnekDgdcg[\fsetting UprightFeatures={RawFeature={+axis={wght=300,wdth=120}}},]{\fname} \newfontface\AnekDgdch[\fsetting UprightFeatures={RawFeature={+axis={wght=300,wdth=125}}},]{\fname}
\newfontface\AnekDgdda[\fsetting UprightFeatures={RawFeature={+axis={wght=400,wdth=75}}},]{\fname} \newfontface\AnekDgddb[\fsetting UprightFeatures={RawFeature={+axis={wght=400,wdth=80}}},]{\fname} \newfontface\AnekDgddc[\fsetting UprightFeatures={RawFeature={+axis={wght=400,wdth=90}}},]{\fname} \newfontface\AnekDgddd[\fsetting UprightFeatures={RawFeature={+axis={wght=400,wdth=100}}},]{\fname} \newfontface\AnekDgdde[\fsetting UprightFeatures={RawFeature={+axis={wght=400,wdth=110}}},]{\fname} \newfontface\AnekDgddf[\fsetting UprightFeatures={RawFeature={+axis={wght=400,wdth=115}}},]{\fname} \newfontface\AnekDgddg[\fsetting UprightFeatures={RawFeature={+axis={wght=400,wdth=120}}},]{\fname} \newfontface\AnekDgddh[\fsetting UprightFeatures={RawFeature={+axis={wght=400,wdth=125}}},]{\fname}
\newfontface\AnekDgdea[\fsetting UprightFeatures={RawFeature={+axis={wght=500,wdth=75}}},]{\fname} \newfontface\AnekDgdeb[\fsetting UprightFeatures={RawFeature={+axis={wght=500,wdth=80}}},]{\fname} \newfontface\AnekDgdec[\fsetting UprightFeatures={RawFeature={+axis={wght=500,wdth=90}}},]{\fname} \newfontface\AnekDgded[\fsetting UprightFeatures={RawFeature={+axis={wght=500,wdth=100}}},]{\fname} \newfontface\AnekDgdee[\fsetting UprightFeatures={RawFeature={+axis={wght=500,wdth=110}}},]{\fname} \newfontface\AnekDgdef[\fsetting UprightFeatures={RawFeature={+axis={wght=500,wdth=115}}},]{\fname} \newfontface\AnekDgdeg[\fsetting UprightFeatures={RawFeature={+axis={wght=500,wdth=120}}},]{\fname} \newfontface\AnekDgdeh[\fsetting UprightFeatures={RawFeature={+axis={wght=500,wdth=125}}},]{\fname}
\newfontface\AnekDgdfa[\fsetting UprightFeatures={RawFeature={+axis={wght=600,wdth=75}}},]{\fname} \newfontface\AnekDgdfb[\fsetting UprightFeatures={RawFeature={+axis={wght=600,wdth=80}}},]{\fname} \newfontface\AnekDgdfc[\fsetting UprightFeatures={RawFeature={+axis={wght=600,wdth=90}}},]{\fname} \newfontface\AnekDgdfd[\fsetting UprightFeatures={RawFeature={+axis={wght=600,wdth=100}}},]{\fname} \newfontface\AnekDgdfe[\fsetting UprightFeatures={RawFeature={+axis={wght=600,wdth=110}}},]{\fname} \newfontface\AnekDgdff[\fsetting UprightFeatures={RawFeature={+axis={wght=600,wdth=115}}},]{\fname} \newfontface\AnekDgdfg[\fsetting UprightFeatures={RawFeature={+axis={wght=600,wdth=120}}},]{\fname} \newfontface\AnekDgdfh[\fsetting UprightFeatures={RawFeature={+axis={wght=600,wdth=125}}},]{\fname}
\newfontface\AnekDgdga[\fsetting UprightFeatures={RawFeature={+axis={wght=700,wdth=75}}},]{\fname} \newfontface\AnekDgdgb[\fsetting UprightFeatures={RawFeature={+axis={wght=700,wdth=80}}},]{\fname} \newfontface\AnekDgdgc[\fsetting UprightFeatures={RawFeature={+axis={wght=700,wdth=90}}},]{\fname} \newfontface\AnekDgdgd[\fsetting UprightFeatures={RawFeature={+axis={wght=700,wdth=100}}},]{\fname} \newfontface\AnekDgdge[\fsetting UprightFeatures={RawFeature={+axis={wght=700,wdth=110}}},]{\fname} \newfontface\AnekDgdgf[\fsetting UprightFeatures={RawFeature={+axis={wght=700,wdth=115}}},]{\fname} \newfontface\AnekDgdgg[\fsetting UprightFeatures={RawFeature={+axis={wght=700,wdth=120}}},]{\fname} \newfontface\AnekDgdgh[\fsetting UprightFeatures={RawFeature={+axis={wght=700,wdth=125}}},]{\fname}
\newfontface\AnekDgdha[\fsetting UprightFeatures={RawFeature={+axis={wght=800,wdth=75}}},]{\fname} \newfontface\AnekDgdhb[\fsetting UprightFeatures={RawFeature={+axis={wght=800,wdth=80}}},]{\fname} \newfontface\AnekDgdhc[\fsetting UprightFeatures={RawFeature={+axis={wght=800,wdth=90}}},]{\fname} \newfontface\AnekDgdhd[\fsetting UprightFeatures={RawFeature={+axis={wght=800,wdth=100}}},]{\fname} \newfontface\AnekDgdhe[\fsetting UprightFeatures={RawFeature={+axis={wght=800,wdth=110}}},]{\fname} \newfontface\AnekDgdhf[\fsetting UprightFeatures={RawFeature={+axis={wght=800,wdth=115}}},]{\fname} \newfontface\AnekDgdhg[\fsetting UprightFeatures={RawFeature={+axis={wght=800,wdth=120}}},]{\fname} \newfontface\AnekDgdhh[\fsetting UprightFeatures={RawFeature={+axis={wght=800,wdth=125}}},]{\fname}
\begin{document}
100: weight मराठी मजकूर
700: weight {\AnekBoldc\textbf{मराठी मजकूर}} wght 200 wdth 180: {\AnekBoldc मराठी मजकूर}
900: weight {\AnekBoldb\textbf{मराठी मजकूर}} no bold: {\AnekBoldb मराठी मजकूर}
\begin{tabular}{ll}
Weight & Example (at width=100) \\
100 & \AnekDga \test \\
200 & \AnekDgb \test \\
300 & \AnekDgc \test \\
400 & \AnekDgd \test \\
500 & \AnekDge \test \\
600 & \AnekDgf \test \\
700 & \AnekDgg \test \\
800 & \AnekDgh \test \\
\end{tabular}
\bigskip
\begin{tabular}{ll}
Width (\%) & Example (at weight=400) \\
75 & \AnekDda \test \\
80 & \AnekDdb \test \\
90 & \AnekDdc \test \\
100 & \AnekDdd \test \\
110 & \AnekDde \test \\
115 & \AnekDdf \test \\
120 & \AnekDdg \test \\
125 & \AnekDdh \test \\
\end{tabular}
%--- Grid Sample
\bigskip
\begin{tabular}{lllllllll}
& 75 & 80 & 90 & 100 & 110 & 115 & 120 & 125 \\
100 & \AnekDgdaa \testb & \AnekDgdab \testb & \AnekDgdac \testb & \AnekDgdad \testb & \AnekDgdae \testb & \AnekDgdaf \testb & \AnekDgdag \testb & \AnekDgdah \testb \\
200 & \AnekDgdba \testb & \AnekDgdbb \testb & \AnekDgdbc \testb & \AnekDgdbd \testb & \AnekDgdbe \testb & \AnekDgdbf \testb & \AnekDgdbg \testb & \AnekDgdbh \testb \\
300 & \AnekDgdca \testb & \AnekDgdcb \testb & \AnekDgdcc \testb & \AnekDgdcd \testb & \AnekDgdce \testb & \AnekDgdcf \testb & \AnekDgdcg \testb & \AnekDgdch \testb \\
400 & \AnekDgdda \testb & \AnekDgddb \testb & \AnekDgddc \testb & \AnekDgddd \testb & \AnekDgdde \testb & \AnekDgddf \testb & \AnekDgddg \testb & \AnekDgddh \testb \\
500 & \AnekDgdea \testb & \AnekDgdeb \testb & \AnekDgdec \testb & \AnekDgded \testb & \AnekDgdee \testb & \AnekDgdef \testb & \AnekDgdeg \testb & \AnekDgdeh \testb \\
600 & \AnekDgdfa \testb & \AnekDgdfb \testb & \AnekDgdfc \testb & \AnekDgdfd \testb & \AnekDgdfe \testb & \AnekDgdff \testb & \AnekDgdfg \testb & \AnekDgdfh \testb \\
700 & \AnekDgdga \testb & \AnekDgdgb \testb & \AnekDgdgc \testb & \AnekDgdgd \testb & \AnekDgdge \testb & \AnekDgdgf \testb & \AnekDgdgg \testb & \AnekDgdgh \testb \\
800 & \AnekDgdha \testb & \AnekDgdhb \testb & \AnekDgdhc \testb & \AnekDgdhd \testb & \AnekDgdhe \testb & \AnekDgdhf \testb & \AnekDgdhg \testb & \AnekDgdhh \testb \\
\end{tabular}
\end{document}
Tutorial
This is a mini-tutorial on how to set the variables of a variable font (in this case, along the weight axis and along the width axis of one of the Anek fonts).
The code was compiled on Windows under the TeXLive 2020 distribution (TL2020 does not have the version of the HarfBuzz font-shaping engine that supports variable fonts), and was compiled using the lualatex engine as compiler (because fontspec under lualatex can switch font renderers, and because lualatex understands file names that contain [
and ]
).
HarfBuzz is needed to get proper ligatures (conjuncts) in complex scripts (e.g., न + ् + त = न्त).
Many things need to happen at once, so there is much detail.
- Be familiar with the references.
Reference: Open the latex font guide (texdoc fntguide
) and the fontspec
manual (texdoc fontspec
).
Download the Anek fonts.
The fontspec Path=
option is used here, so installing the fonts as system fonts is not strictly necessary (at least under Windows).
The font AnekDevanagari[wdth,wght].ttf
is used as demonstration. (To compile with xelatex, rename the font file to plain characters; also, xelatex uses HarfBuzz by default).
The font is used as the main font, with no specific script or language settings, because it contains latn
script. For the Path=
option, type in the actual path on your system, or type it into the \myfontpath
macro.
\setmainfont[
Path=\myfontpath,
Extension=.ttf,
Colour=black,
UprightFont=*,
]{AnekDevanagari[wdth,wght]}
- For Devanagari, use the
dev2
script for preference; it fixes some misunderstandings encoded into the original deva
script).
\newfontscript{Devanagari}{dev2,deva}
- Define an Anek font face with no HarfBuzz and set the variables for standard fontfaces (UprightFont and BoldFont), and for a custom fontface as demonstration.
Full definition:
\newfontface\anekexamplefont[
Path=\myfontpath,
Extension=.ttf,
Colour=blue,
Script=Devanagari,
Language=Marathi,
UprightFont=*,
UprightFeatures={RawFeature={+axis={wght=400,wdth=100}}},
BoldFont=*,
BoldFeatures={RawFeature={+axis={wght=700,wdth=105}}},
FontFace={ubux}{n}{Font={*},RawFeature={+axis={wght=900,wdth=125}},
},
]{AnekDevanagari[wdth,wght]}
- Setp-by-step: Tell fontspec to use Devanagari Script, and Marathi Language:
Script=Devanagari,
Language=Marathi,
- Tell fontspec that the name of the UprightFont file is the same as the main name:
UprightFont=*,
- Set the upright font's variable font features to "normal" values (weight=400, width=100):
UprightFeatures={RawFeature={+axis={wght=400,wdth=100}}},
Weight is a number, theoretically 1 (light) to 1000 (heavy), and width is a percentage and is generally 75-125, but is actually whatever the font-designer has designed.
- Do likewise for the BoldFont:
BoldFont=*,
BoldFeatures={RawFeature={+axis={wght=700,wdth=105}}},
- Define a custom fontface that will be an ultra-bold and ultra-extended series (
ubux
) and normal shape (n
) - the fntguide
lists the recommended series naming.
FontFace={ubux}{n}{Font={*},RawFeature={+axis={wght=900,wdth=125}},
},
- Define another font with the same settings, with the addition that it will use the HarfBuzz renderer:
\newfontface\anekexamplefonthb[
Path=\myfontpath,
Extension=.ttf,
Colour=blue,
Script=Devanagari,
Language=Marathi,
Renderer=HarfBuzz,
UprightFont=*,
UprightFeatures={RawFeature={+axis={wght=400,wdth=100}}},
BoldFont=*,
BoldFeatures={RawFeature={+axis={wght=700,wdth=105}}},
FontFace={ubux}{n}{Font={*},RawFeature={+axis={wght=900,wdth=125}},
},
]{AnekDevanagari[wdth,wght]}
- Define a static font, for comparison:
\newfontface\shobhikafont[Renderer=HarfBuzz,
Script=Devanagari,
Language=Marathi,]{Shobhika}
- Define a command using the custom series
ubux
:
\DeclareRobustCommand{\ubuxseries}{\fontseries{ubux}\selectfont}
- Define a
\text....
command that uses the custom series:
\DeclareTextFontCommand{\textubux}{\ubuxseries}
- Now, generate some output, to show the weights/widths:
\anekexamplefont
\test
...
\textbf{\test}
...
\textubux{\test}
...

- Similarly for the HarfBuzz version, showing that HarfBuzz (in TL2020) defaults to normal weight/width:
\anekexamplefonthb
\test
...
\textbf{\test}
...
\textubux{\test}
...

- Update your TeX installation when ready. :)
Full MWE
\documentclass{article}
\newcommand\myfontpath{C:/Users/...<really long path name>.../Variable/}
\newcommand\test{मराठी मजकूर तलॆन्त}
\usepackage{xcolor}
\usepackage{fontspec}
%\defaultfontfeatures{RawFeature={+axis={wght=400,wdth=100}}}
\setmainfont[
Path=\myfontpath,
Extension=.ttf,
Colour=black,
UprightFont=*,
]{AnekDevanagari[wdth,wght]}
\newfontscript{Devanagari}{dev2,deva}
\newfontface\anekexamplefont[
Path=\myfontpath,
Extension=.ttf,
Colour=blue,
Script=Devanagari,
Language=Marathi,
UprightFont=*,
UprightFeatures={RawFeature={+axis={wght=400,wdth=100}}},
BoldFont=*,
BoldFeatures={RawFeature={+axis={wght=700,wdth=105}}},
FontFace={ubux}{n}{Font={*},RawFeature={+axis={wght=900,wdth=125}},
},
]{AnekDevanagari[wdth,wght]}
\newfontface\anekexamplefonthb[
Path=\myfontpath,
Extension=.ttf,
Colour=blue,
Script=Devanagari,
Language=Marathi,
Renderer=HarfBuzz,
UprightFont=*,
UprightFeatures={RawFeature={+axis={wght=400,wdth=100}}},
BoldFont=*,
BoldFeatures={RawFeature={+axis={wght=700,wdth=105}}},
FontFace={ubux}{n}{Font={*},RawFeature={+axis={wght=900,wdth=125}},
},
]{AnekDevanagari[wdth,wght]}
\newfontface\shobhikafont[Renderer=HarfBuzz,
Script=Devanagari,
Language=Marathi,]{Shobhika}
\DeclareRobustCommand{\ubuxseries}{\fontseries{ubux}\selectfont}
\DeclareTextFontCommand{\textubux}{\ubuxseries}
\begin{document}
This is the main font (default).
\bigskip
%
\section{A}
Without using HarfBuzz renderer: +weight, +width, no ligatures
This is an Anek variable font, acting as ``normal'' font:
\begin{quotation}
\anekexamplefont
\test
\par weight=400, width=100
\end{quotation}
%
\textbackslash textbf:
\begin{quotation}
\anekexamplefont
\textbf{\test}
\par normal-bold, normal-ish width:
\par weight=700, width=105
\end{quotation}
%
\textbackslash textubux:
\begin{quotation}
\anekexamplefont
\textubux{\test}
\par ultra-bold, ultra-extended:
\par weight=900, width=125
\end{quotation}
\bigskip
\section{B}
Using HarfBuzz font-shaping engine: ligatures, normal weight and width only
%
This is an Anek variable font, acting as ``normal'' font:
\begin{quotation}
\anekexamplefonthb\test
\par weight=400, width=100
\end{quotation}
%
\textbackslash textbf:
\begin{quotation}
\anekexamplefonthb\textbf{\test}
\par normal-bold, normal-ish width:
\par weight=700, width=105
\end{quotation}
%
\textbackslash textubux:
\begin{quotation}
\anekexamplefonthb\textubux{\test}
\par ultra-bold, ultra-extended:
\par weight=900, width=125
\end{quotation}
\bigskip
\section{C}
Static font using HarfBuzz:
Shobhika font, normal:
\begin{quotation}
\shobhikafont\test
\end{quotation}
\end{document}

%
and not#
.