Right Arrow alignment in text

Hello,
Had a quick question on a particular nuiances with how the text is rendered. Specifically with the right arrow. I’ve attached the script below. The alignment of the right arrow is clearly not centered with the text neither the capital “X” nor the “e” in this case? Just want to check if there is a quick fix to this?

Thank you.

import ROOT
ROOT.gROOT.SetBatch(True)

c = ROOT.TCanvas("c", "c", 800, 600)
c.SetGrid()
c.DrawFrame(0,0,0.3,0.3)

latex = ROOT.TLatex()
# latex.SetBorderSize(0)
latex.SetNDC()
latex.SetTextAlign(12)
latex.SetTextFont(42)
latex.SetTextSize(0.028)
latex.DrawLatex(0.3, 0.2, "X#rightarrow e^{+}e^{-}")
latex.Draw()

processLabelText = ROOT.TPaveText(0.3, 0.1, 0.4, 0.2, "NDC")
processLabelText.SetBorderSize(0)
processLabelText.SetFillStyle(0)
processLabelText.SetTextAlign(12)
processLabelText.SetTextFont(42)
processLabelText.SetTextSize(0.028)
processLabelText.SetTextColor(ROOT.kBlack)
processLabelText.AddText("X#rightarrow e^{+}e^{-}")
processLabelText.Draw()

c.Draw()
c.SaveAs("RightArrowTest.pdf")

Maybe @linev can help…

Hi,

There is nothing special done in TLatex concerning #rightarrow symbol -
it is how symbol defined in the font. The only you can do - adjust text position with the command:

processLabelText.AddText("X#lower[-0.2]{#rightarrow} e^{+}e^{-}")

One uses #lower[-0.2]{text} command for this.
See more info in the documentation:

Regards,
Sergey

Using ROOT 6.40.02 on Linux (Mint), the arrows look well-aligned (just very slightly below the horizontal line in the “e”, if we look that closely) with the original code, no addded adjustments:

@dastudillo

It also may depend from PDF viewer.

Indeed; my arrows look a bit different, for instance. But if I save as PNG or JPG the alignment still looks the same for me, so at least it’s consistent within the same system :slight_smile: ; here’s from the png:

Edit: by the way, the “+” exponents also have extra space in the original, so the arrow issue might also be related to their system or viewer.