Microtype expansion gets disabled when fontsize is changed! (lualatex)

microtype sets up the font expansion only for a restricted set of font size. If you add you size to the list it works (redefining basictext is probably not the best way to do it):

\documentclass{article}
\usepackage[english]{babel}
\usepackage{color}
\usepackage{blindtext}
\usepackage{multicol}
\definecolor{textblack}{RGB}{26,25,25}
\usepackage{fontspec}
\usepackage[expansion=true,stretch=500,shrink=500]{microtype}
\DeclareMicrotypeSet*{basictext}
{ encoding = {OT1,T1,T2A,LY1,OT4,QX,T5,EU1,EU2,TU},
 family = {rm*,sf*},
 series = {md*},
 size = {normalsize,footnotesize,small,large,9.1} %added 9.1
}
\setmainfont[Ligatures=TeX]{Arial}
\begin{document}
    \fontsize{9.1pt}{12pt}\selectfont
    \begin{multicols}{3}
        \blindtext[10]
    \end{multicols}
\end{document}

You can lift the restriction also by e.g. using another set than the default:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{color}
\usepackage{blindtext}
\usepackage{multicol}
\definecolor{textblack}{RGB}{26,25,25}
\usepackage{fontspec}
\usepackage[expansion=true,stretch=500,shrink=500]{microtype}
\UseMicrotypeSet[expansion]{alltext}
\setmainfont[Ligatures=TeX]{Arial}
\begin{document}
    \fontsize{9.1pt}{12pt}\selectfont
    \begin{multicols}{3}
        \blindtext[10]
    \end{multicols}
\end{document}

OR even more terse, by passing expansion=alltext as a package option while loading microtype:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{color}
\usepackage{blindtext}
\usepackage{multicol}
\definecolor{textblack}{RGB}{26,25,25}
\usepackage{fontspec}
\usepackage[expansion=alltext,stretch=500,shrink=500]{microtype}% expansion=all would also work as that set too does not have restrictions on size, and is the least restrictive of all predefined sets
\setmainfont[Ligatures=TeX]{Arial}
\begin{document}
    \fontsize{9.1pt}{12pt}\selectfont
    \begin{multicols}{3}
        \blindtext[10]
    \end{multicols}
\end{document}

enter image description here


To be frank, I don't know why people use microtype at all. Granted, it has some nice interfaces like textls, but for expansion I can achieve the same things with two lines of Lua and a font feature. This also does not have the font size problem.

%main.tex
\documentclass[9pt]{extarticle}
\usepackage[english]{babel}
\usepackage{color}
\usepackage{blindtext}
\usepackage{multicol}
\definecolor{textblack}{RGB}{26,25,25}
\usepackage{fontspec}
\usepackage[expansion=false]{microtype}
\directlua{
  fonts.expansions.setups.default.stretch = 500
  fonts.expansions.setups.default.shrink = 500
}
\adjustspacing=2
\setmainfont[Ligatures=TeX,Renderer=Basic,RawFeature={expansion=default}]{Roboto}
\sloppy
\begin{document}
    \color{textblack}
    \fontsize{8.8pt}{12pt}\selectfont
    \begin{multicols}{3}
        \blindtext[10]
    \end{multicols}
\end{document}

Explanation of commands used:

  1. \adjustspacing: From luatex manual: "When \adjustspacing has value 2, hz optimization will be applied to glyphs and kerns. Whenthe value is 3, only glyphs will be treated. A value smaller than 2 disables this feature." So \adjustspacing=2 enables font expansion, equivalent of microtype's expansion=true (which anyway is by default).
  2. \directlua{...stretch = 500, ...}: lualatex equivalent for microtype's package option stretch=500.
  3. \usepackage[expansion=false]{microtype} Passing expansion=false ensures that you can still use microtype for its other features, while expansion is handled using lua. If you do not pass expansion=false, your lualatex run will fail with an error: "error: (font expansion): font has been expanded with different expansion step", and no pdf will be produced.