8

I am having a problem with Minion Pro and breve under accent (via semtrans package or via ḫ). How can I adapt this solution by @egreg to this case?

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Minion Pro}
\usepackage{semtrans}

\begin{document}

Test \U{h}. Test ḫ.

\end{document}
1
  • I added a better version that also keeps into account the slant.
    – egreg
    Commented May 6, 2018 at 19:26

2 Answers 2

4

semtrans is no good for this, because it uses \u and Minion Pro lacks the combining breve (it lacks so many things it is not really good for extensive work).

We can patch the semtrans definition to directly use the breve character (at least Minion Pro has something in it).

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}

\setmainfont{Minion Pro}

% from semtrans
\newcommand*\U[1]{{\oalign{#1\crcr\hidewidth
   \vbox to .2ex{\hbox{\char"02D8}\vss}\hidewidth}}}
\newunicodechar{ḫ}{\U{h}}


\begin{document}

Test \U{h}. Test ḫ.

\end{document}

enter image description here

A version that also keeps into account the slant for italics:

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}

\setmainfont{Minion Pro}

% from semtrans, with changes
\makeatletter
\newcommand*\U[1]{{%
  \oalign{%
    #1\crcr
    \hidewidth
    \vbox to .2ex{\hbox{\kern-\f@size\fontdimen1\font\char"02D8}\vss}%
    \hidewidth\crcr
  }%
}}
\makeatother
\newunicodechar{ḫ}{\U{h}}


\begin{document}

Test \U{h}. Test ḫ. Test \U{m}.

\itshape

Test \U{h}. Test ḫ. Test \U{m}.

\LARGE

Test \U{h}. Test ḫ. Test \U{m}.

\end{document}

enter image description here

7
  • 2
    The tick stealer strikes again. Just before I wanted to post mine. :-) +1 Commented May 6, 2018 at 9:18
  • 2
    @egreg What typeface do you prefer which is both aesthetic and suitable for extensive work. (Except, perhaps, libertine.)
    – blackened
    Commented May 6, 2018 at 9:19
  • 2
    @blackened It's not just a question of preferences; it also depends on what features you require from your font.
    – egreg
    Commented May 6, 2018 at 9:20
  • Since anyone transliterating stray Semitic words in an English context is likely to set them in italics, how would one define, say, a \UI command which would put the breve in the right spot for italics?
    – Thérèse
    Commented May 6, 2018 at 17:45
  • 1
    @Thérèse Done, without \UI. :-)
    – egreg
    Commented May 6, 2018 at 19:25
9

It never ceases to amaze me how powerful LuaTeX's callback mechanism is. Here I hook into pre_linebreak_filter. When I encounter an h with breve in the node list, I replace it by an ordinary h and inject a negative kern and a lowered breve character after it.

On the TeX level this is now completely transparent, no catcode changes required.

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Minion Pro}

\usepackage{luacode}
\begin{luacode*}
local function hbreve(head)
    for n in node.traverse(head) do
        if n.id == node.id("glyph") then
            if n.char == 0x1e2b then
                n.char = 0x68
                local f = n.font
                local slant = font.fonts[f].parameters.slant
                local size = font.fonts[f].size / 2^16

                local breve = node.new("glyph")
                breve.font = f
                breve.lang = tex.language
                breve.char = 0x02D8
                breve.width = n.width

                local hbox = node.hpack(breve)
                hbox.shift = n.height
                head = node.insert_after(head,n,hbox)

                local kern = node.new("kern")
                kern.kern = -(n.width+breve.width+slant*size)/2
                head = node.insert_after(head,n,kern)

                local kern = node.new("kern")
                kern.kern = (n.width-breve.width+slant*size)/2
                head = node.insert_after(head,hbox,kern)
            end
        end
    end
    return head
end

luatexbase.add_to_callback("pre_linebreak_filter", hbreve, "hbreve")
\begin{document}

Test ḫ.

\itshape Test ḫ.

\end{document}

enter image description here

3
  • 1
    Very nice. I hesitate to ask, but could this be made to line up correctly even in italics?
    – Thérèse
    Commented May 6, 2018 at 17:48
  • 1
    @Thérèse In principle it is possible. I extended the example to show how to access the slant in the current font but I couldn't work out the math to align it yet. Commented May 6, 2018 at 21:36
  • 2
    @HenriMenke The slant parameter is “slant per point” with unit points. As you see from my addition, I multiply it by the current fontsize using \f@size.
    – egreg
    Commented May 6, 2018 at 21:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .