From f7ade654491251fa227ea8b2d8c1c7f4b127511e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 13 Aug 2026 23:16:20 +0200 Subject: [PATCH] Handle a border case of zero effective text height properly by making such texts non-scaling even with non-default font and borrowing the dimension from the default font --- src/laybasic/laybasic/layBitmapRenderer.cc | 8 ++++++++ src/laybasic/laybasic/layRedrawThreadCanvas.h | 2 +- src/laybasic/laybasic/layTextInfo.cc | 11 +++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/laybasic/laybasic/layBitmapRenderer.cc b/src/laybasic/laybasic/layBitmapRenderer.cc index 0065f836b..0b3e7b6a8 100644 --- a/src/laybasic/laybasic/layBitmapRenderer.cc +++ b/src/laybasic/laybasic/layBitmapRenderer.cc @@ -23,6 +23,7 @@ #include "layBitmapRenderer.h" #include "layBitmap.h" +#include "layFixedFont.h" namespace lay { @@ -398,6 +399,13 @@ BitmapRenderer::draw (const db::Shape &shape, const db::CplxTrans &trans, } } + if (h == 0.0) { + // for the special case of zero effective height, borrow the height + // from the default font in an unscaling fashion. + const lay::FixedFont &ff = lay::FixedFont::get_font (m_font_resolution); + h = ff.height (); + } + db::HAlign halign = shape.text_halign (); db::VAlign valign = shape.text_valign (); diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.h b/src/laybasic/laybasic/layRedrawThreadCanvas.h index 0751d4ab7..99586da9f 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.h +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.h @@ -97,7 +97,7 @@ public: virtual void prepare (unsigned int /*nlayers*/, unsigned int width, unsigned int height, double resolution, double font_resolution, const db::Vector * /*shift_vector*/, const std::vector * /*planes*/, const lay::Drawings * /*drawings*/) { m_resolution = resolution; - m_resolution = font_resolution; + m_font_resolution = font_resolution; m_width = width; m_height = height; } diff --git a/src/laybasic/laybasic/layTextInfo.cc b/src/laybasic/laybasic/layTextInfo.cc index b93fea985..17c3143cd 100644 --- a/src/laybasic/laybasic/layTextInfo.cc +++ b/src/laybasic/laybasic/layTextInfo.cc @@ -81,15 +81,22 @@ TextInfo::bbox (const db::DText &text, const db::DCplxTrans &vp_trans) const fx = -1.0; } + if (h == 0.0) { + // for the special case of zero effective height, borrow the height + // from the default font in an unscaling fashion. + const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution); + h = ff.height () / vp_trans.mag (); + } + db::DPoint dp1 (fx * offset, fy * offset + (fy - 1) * 0.5 * h); db::DPoint dp2 (fx * offset, fy * offset + (fy + 1) * 0.5 * h); if (font == db::DefaultFont) { - db::DBox b (dp1 * vp_trans.mag (), dp2 * vp_trans.mag ()); - const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution); + db::DBox b (dp1 * vp_trans.mag (), dp2 * vp_trans.mag ()); + // count the lines unsigned int lines = 1;