mirror of https://github.com/KLayout/klayout.git
WIP
This commit is contained in:
parent
c3010745ec
commit
2ee4d5414e
|
|
@ -50,6 +50,30 @@
|
||||||
namespace db
|
namespace db
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
|
#if defined(HAVE_QT)
|
||||||
|
|
||||||
|
static int fm_width (const QFontMetrics &fm, const QString &s)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= 0x60000
|
||||||
|
return fm.horizontalAdvance (s);
|
||||||
|
#else
|
||||||
|
return fm.width (s);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static int fm_width (const QFontMetrics &fm, const QChar &s)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= 0x60000
|
||||||
|
return fm.horizontalAdvance (s);
|
||||||
|
#else
|
||||||
|
return fm.width (s);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// DXFReader
|
// DXFReader
|
||||||
|
|
||||||
|
|
@ -1279,7 +1303,7 @@ DXFReader::deliver_text (db::Shapes &shapes, const std::string &s, const db::DCp
|
||||||
|
|
||||||
// The m_text_scaling divider is the letter width in percent of the height.
|
// The m_text_scaling divider is the letter width in percent of the height.
|
||||||
// 92 is the default letter pitch in percent of the text height.
|
// 92 is the default letter pitch in percent of the text height.
|
||||||
int pixel_size_ref = int (floor (0.5 + 100.0 * fm.width (QChar::fromLatin1 ('X')) / (0.92 * m_text_scaling)));
|
int pixel_size_ref = int (floor (0.5 + 100.0 * fm_width (fm, QChar::fromLatin1 ('X')) / (0.92 * m_text_scaling)));
|
||||||
|
|
||||||
// split text into lines
|
// split text into lines
|
||||||
QStringList lines = QString::fromUtf8 (s.c_str ()).split (QString::fromUtf8 ("\n"));
|
QStringList lines = QString::fromUtf8 (s.c_str ()).split (QString::fromUtf8 ("\n"));
|
||||||
|
|
@ -1302,7 +1326,7 @@ DXFReader::deliver_text (db::Shapes &shapes, const std::string &s, const db::DCp
|
||||||
lines.clear ();
|
lines.clear ();
|
||||||
for (QStringList::const_iterator l = ll.begin (); l != ll.end (); ++l) {
|
for (QStringList::const_iterator l = ll.begin (); l != ll.end (); ++l) {
|
||||||
|
|
||||||
if (fm.width (*l) * h / pixel_size_ref > w) {
|
if (fm_width (fm, *l) * h / pixel_size_ref > w) {
|
||||||
|
|
||||||
// wrapping required
|
// wrapping required
|
||||||
QString line;
|
QString line;
|
||||||
|
|
@ -1321,7 +1345,7 @@ DXFReader::deliver_text (db::Shapes &shapes, const std::string &s, const db::DCp
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
double wc = fm.width (ls) * h / pixel_size_ref;
|
double wc = fm_width (fm, ls) * h / pixel_size_ref;
|
||||||
if (wl + wc > w) {
|
if (wl + wc > w) {
|
||||||
lines.push_back (line);
|
lines.push_back (line);
|
||||||
line.clear ();
|
line.clear ();
|
||||||
|
|
@ -1351,9 +1375,9 @@ DXFReader::deliver_text (db::Shapes &shapes, const std::string &s, const db::DCp
|
||||||
double x0 = 0.0;
|
double x0 = 0.0;
|
||||||
if (ha == HAlignLeft || ha == NoHAlign) {
|
if (ha == HAlignLeft || ha == NoHAlign) {
|
||||||
} else if (ha == HAlignCenter) {
|
} else if (ha == HAlignCenter) {
|
||||||
x0 -= fm.width (*l) * 0.5 * h / pixel_size_ref;
|
x0 -= fm_width (fm, *l) * 0.5 * h / pixel_size_ref;
|
||||||
} else {
|
} else {
|
||||||
x0 -= fm.width (*l) * h / pixel_size_ref;
|
x0 -= fm_width (fm, *l) * h / pixel_size_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath pp;
|
QPainterPath pp;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@ contains(QT_CONFIG, opengl) {
|
||||||
SUBDIRS = lay_plugin unit_tests
|
SUBDIRS = lay_plugin unit_tests
|
||||||
}
|
}
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||||
|
QT += openglwidgets
|
||||||
|
}
|
||||||
|
|
||||||
unit_tests.depends += lay_plugin
|
unit_tests.depends += lay_plugin
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,13 @@ public:
|
||||||
QFontMetrics fm (font ());
|
QFontMetrics fm (font ());
|
||||||
m_line_height = std::max (fm.height (), m_pixmap_size + 4);
|
m_line_height = std::max (fm.height (), m_pixmap_size + 4);
|
||||||
m_font_height = fm.height () * 3 / 2;
|
m_font_height = fm.height () * 3 / 2;
|
||||||
|
#if QT_VERSION >= 0x60000
|
||||||
|
m_first_column_width = fm.horizontalAdvance (QString::fromUtf8 ("LAYERNAME"));
|
||||||
|
m_column_width = m_pixmap_size + 4 + m_spacing + fm.horizontalAdvance (QString::fromUtf8 ("1.00G "));
|
||||||
|
#else
|
||||||
m_first_column_width = fm.width (QString::fromUtf8 ("LAYERNAME"));
|
m_first_column_width = fm.width (QString::fromUtf8 ("LAYERNAME"));
|
||||||
m_column_width = m_pixmap_size + 4 + m_spacing + fm.width (QString::fromUtf8 ("1.00G "));
|
m_column_width = m_pixmap_size + 4 + m_spacing + fm.width (QString::fromUtf8 ("1.00G "));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize sizeHint () const
|
QSize sizeHint () const
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue