From af3eb0acbfc933b187fc7dad5d252185c0375a5e Mon Sep 17 00:00:00 2001 From: Matvey Soloviev Date: Tue, 21 Jul 2020 16:57:44 -0400 Subject: [PATCH] Mild tweaks to baseline calculation for LaTeX math --- imagewidgets.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/imagewidgets.cpp b/imagewidgets.cpp index 05daf2a..c1c05a6 100644 --- a/imagewidgets.cpp +++ b/imagewidgets.cpp @@ -131,10 +131,14 @@ CLatexWidget::CLatexWidget(Glib::RefPtr wnd, Glib::ustring text, Gd 18 / 3.f, clr); + float h = r->getHeight(), w = r->getWidth(); - SetSize(r->getWidth()+4,r->getHeight()+2); + SetSize(w+4,h+2); - baseline=(int)(round(1.5+(r->getHeight())*(1.0-r->getBaseline()))); + baseline=(int)(round((2.5+(h)*(1.0f-r->getBaseline())))); + + // workaround for not entirely correct baseline arithmetic + if(h<12) baseline-=1; Graphics2D_cairo g2(image_ctx); r->draw(g2,2,1);