# LuaTeX + Roboto + \= : working with A but not with B, nor C

I want to use the 'bar' accent (\={<letter>}) on capital letters in my document that is typesetted with roboto. If I compile the document using LaTeX, it works perfectly. But if I compile it using LuaLaTeX, \={A} is working great, but neither \={B} nor \={C}:

Questions: Why? How to use the 'bar'-accent with roboto and LuaLaTeX?

Note: I've not encounter such problem with other fonts.

MWE

\documentclass{article}
\usepackage[sfdefault]{roboto}
\usepackage{ifluatex}
\ifluatex
\newcommand{\engine}{LuaTeX}
\else
\newcommand{\engine}{TeX}
\fi
\begin{document}
\engine:
\={A}
\={B}
\={C}
\end{document}

• Missing character: There is no ̄ (U+0304) in font [Roboto-Regular.ttf] Sep 18, 2017 at 12:01
• Roboto doesn't have the accent needed to build the B and C with a macron: in the log-file you get Missing character: There is no ̄ (U+0304) in font [Roboto-Regular.ttf]. (A with macron is a real glyph, U+100). Sep 18, 2017 at 12:01
• As I wrote: A with macron is a real glyph with a unicode position and it is in the font. But B with macron must be build and while the one component (the B) is in the font, the other (the accent) is missing. Sep 18, 2017 at 12:18
• @UlrikeFischer I misunderstood your first comment, my bad. Sep 18, 2017 at 13:24

The Roboto fonts miss the U+0304 COMBINING MACRON character, and indeed you get the dreaded message

Missing character: There is no ̄ (U+0304) in font [Roboto-Regular.ttf]


You can fix this by declaring that the combinations with \= are dealt with in the traditional way, via \accent.

\documentclass{article}
\usepackage{fontspec}

\makeatletter
\DeclareUnicodeEncoding{roboto}{%
\input{tuenc.def}%
\DeclareTextAccent{\=}{roboto}{"00AF}%
}
\makeatother

\setmainfont{Roboto}[
Extension      = .ttf,
NFSSEncoding   = roboto,
UprightFont    = *-Regular,
ItalicFont     = *-RegularItalic,
BoldFont       = *-Bold,
BoldItalicFont = *-BoldItalic,
]

\begin{document}
\={A}
\={B}
\={C}
\end{document}


I don't see an easy way to use the package, because it doesn't allow for adding the NFSSEncoding option to the font choices.

The following workaround (inspired from: https://tex.stackexchange.com/a/233378/112503) seems to work:

\documentclass[12pt]{article}

\usepackage{fontspec}

\setmainfont{Roboto}[%
Extension = .ttf ,
Path = C:/path-to-font-file/ ,
UprightFont = {Roboto-Regular},
]

\begin{document}
\=A (\accent"02C9 A)

\accent"02C9 B

\accent"02C9 C
\end{document}