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

This commit is contained in:
Matthias Koefferlein 2026-08-13 23:16:20 +02:00
parent d23f401244
commit f7ade65449
3 changed files with 18 additions and 3 deletions

View File

@ -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 ();

View File

@ -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<int> * /*planes*/, const lay::Drawings * /*drawings*/)
{
m_resolution = resolution;
m_resolution = font_resolution;
m_font_resolution = font_resolution;
m_width = width;
m_height = height;
}

View File

@ -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;