5

I had a look at different approaches discussed on SO, but they either don't apply to the Tibetan font (e.g. only CJK fonts) or they lower the whole line (not just the part inside the curly braces) or they involve a block which prevents automatic line breaks from working (like \raisebox).

Any idea how I can lower the baseline of the Tibetan font (BabelStrone Tibetan) to make it align with the English text around it?

\documentclass{article}

\usepackage{polyglossia}
\setdefaultlanguage[variant=british]{english}
\setotherlanguage{tibetan}
\setmainfont{Charis SIL}
\newfontfamily{\tibetanfont}[Scale=1.415]{BabelStone Tibetan}

\setlength{\parindent}{0pt}

\begin{document}
the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’\\
\end{document}

I want to make it look like in the second line in the image below where I'm using a different Tibetan font that has better vertical alignment.

First line: BabelStrone Tiebetan. Second line: DDC Uchen

8
  • Will this help? tex.stackexchange.com/questions/282342/… Oct 31, 2018 at 12:42
  • Apparently the font has peculiar ideas about the baseline of Tibetan glyphs; if I use another font I have on my machine I get this output (click)
    – egreg
    Oct 31, 2018 at 12:45
  • @DavidPurton I tried patching \tibetanfont with the xelatex version of that command, which is \special{pdf:literal 1 0 0 1 0 -2 cm}, but it shifts the rest of the line as well, even if I try to shift back at the end of the patch. Oct 31, 2018 at 13:03
  • This is the patch I'm using: \usepackage{etoolbox} \pretocmd{\tibetanfont}{\special{pdf:literal 1 0 0 1 0 -2 cm}}{}{} \apptocmd{\tibetanfont}{\special{pdf:literal 1 0 0 1 0 2 cm}}{}{} Oct 31, 2018 at 13:04
  • etoolbox is not clever enough to patch the \texttibetan macro. But I think xpatch can do it. I'll update my answer. Oct 31, 2018 at 13:08

1 Answer 1

4

Using this answer, you can adjust the baseline with a PDF special.

Update to allow for difference font sizes.

\documentclass{article}

\usepackage{polyglossia}
\setdefaultlanguage[variant=british]{english}
\setotherlanguage{tibetan}
\setmainfont{Charis SIL}
\newfontfamily{\tibetanfont}[Scale=1.415]{BabelStone Tibetan}

\setlength{\parindent}{0pt}

\usepackage{xparse}
\ExplSyntaxOn
\dim_new:N \g__naoki_offset_dim
\cs_new:Nn \__naoki_calc_offset:
  {
    \dim_set:Nn \g__naoki_offset_dim { 1 ex * \dim_ratio:nn { 2 pt } { 5 pt } }
  }
\NewDocumentCommand \dropbaseline { }
  {
    \__naoki_calc_offset:
    \special{pdf:literal~1~0~0~1~0~-\dim_to_decimal:n { \g__naoki_offset_dim }~cm}
  }
\NewDocumentCommand \raisebaseline { }
  {
    \__naoki_calc_offset:
    \special{pdf:literal~1~0~0~1~0~\dim_to_decimal:n { \g__naoki_offset_dim }~cm}
  }
\ExplSyntaxOff

\usepackage{xpatch}
\xpretocmd{\texttibetan}{\dropbaseline}{}{}
\xapptocmd{\texttibetan}{\raisebaseline}{}{}

\newlength{\tempdima}
\begin{document}
English {\tibetanfont\dropbaseline རྫོང་\raisebaseline} English

\Huge the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’

\huge the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’

\LARGE the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’

\Large the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’

\large the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’

\normalsize the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’

\small the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’

\footnotesize the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’

\scriptsize the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’

\tiny the \texttibetan{རྫོང་} \textbf{dzong} ‘fortress’
\end{document}

enter image description here

6
  • Thanks @DavidPurton! Your solution does the job perfectly for \texttibetan. But I would also need \tibetanfont to lower the baseline. Any idea how I can do that? Oct 31, 2018 at 13:27
  • 1
    @NoakiPeter, you would need to manually add the PDF special (via a macro if you like) before and after your text for it to be reliable I think. Oct 31, 2018 at 13:36
  • It won't work correctly with other font sizes. Oct 31, 2018 at 17:05
  • @UlrikeFischer, is that better? Nov 1, 2018 at 11:48
  • Yes ;-). (I would probably change the special with a driver dependent command so that it works also with luatex.). But the real fix is naturally to correct the font. Nov 1, 2018 at 11:52

You must log in to answer this question.

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