On 2020-08-13 01:27, Richard Kimberly Heck wrote:
On 8/12/20 5:04 PM, Daniel wrote:
On 2020-08-12 22:39, Stephan Witt wrote:
Am 12.08.2020 um 22:06 schrieb Daniel <xraco...@gmx.de>:
On 2020-08-12 17:04, Richard Kimberly Heck wrote:
On 8/12/20 7:43 AM, Daniel wrote:
Does anyone know how to get the QFont from a "Font const & font"?
I tried
fi = font.fontInfo();
with
1. getFont(fi)
and also
2. getFont(fi.realize(sane_font))
But always get a SIGSEGV within LyX.
What exactly is the error with the latter?
Riki
I get the message below. I am still not ably to create a backtrace.
But the attached patch causes the issue for me when I open the text
properties dialog. Now, oddly enough only the first time I open it…
… this is the assertion for a non-realized font:
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal
SIGABRT
frame #0: 0x00007fff599df2c2
libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x00000001059c580d
libsystem_pthread.dylib`pthread_kill + 284
frame #2: 0x00007fff599496a6 libsystem_c.dylib`abort + 127
* frame #3: 0x000000010039218f LyX`lyx::lyx_exit(exit_code=1) at
LyX.cpp:275:2
frame #4: 0x0000000100593dd7
LyX`boost::assertion_failed(expr="false", function="void
lyx::doAssertWithCallstack(bool)",
file="/Users/stephan/git/lyx/src/support/lassert.cpp", line=44) at
boost.cpp:47:2
frame #5: 0x000000010106cc1b
LyX`lyx::doAssertWithCallstack(value=false) at lassert.cpp:44:3
frame #6: 0x000000010106d3a2 LyX`lyx::doAssert(expr="false",
file="/Users/stephan/git/lyx/src/frontends/qt/GuiFontLoader.cpp",
line=132) at lassert.cpp:53:2
frame #7: 0x0000000100ce6f75 LyX`lyx::frontend::(anonymous
namespace)::fontinfo(f=0x00007ffeefbf6178) at GuiFontLoader.cpp:132:9
frame #8: 0x0000000100ce7185
LyX`lyx::frontend::getFont(f=0x00007ffeefbf6178) at
GuiFontLoader.cpp:469:9
frame #9: 0x0000000100bd172a
LyX`lyx::frontend::GuiCharacter::paramsToDialog(this=0x000000011e12bef0,
font=0x000000011e12c0c0) at GuiCharacter.cpp:616:16
frame #10: 0x0000000100bd4655
LyX`lyx::frontend::GuiCharacter::initialiseParams(this=0x000000011e12bef0,
(null)="") at GuiCharacter.cpp:675:2
frame #11: 0x0000000100b33db0
LyX`lyx::frontend::Dialog::showData(this=0x000000011e12bef0, data="")
at Dialog.cpp:139:7
frame #12: 0x0000000100e9d971
LyX`lyx::frontend::GuiView::doShowDialog(this=0x000000011b965eb0,
qname=0x00007ffeefbf6538, qdata=0x00007ffeefbf6530,
inset=0x0000000000000000) at GuiView.cpp:4852:12
frame #13: 0x0000000100e9e0e3
LyX`lyx::frontend::GuiView::qt_static_metacall(_o=0x000000011b965eb0,
_c=InvokeMetaMethod, _id=16, _a=0x00007ffeefbf64d0) at
moc_GuiView.cpp:172:22
frame #14: 0x000000010553363a
QtCore`QMetaObject::activate(QObject*, int, int, void**) + 2298
frame #15: 0x0000000100e9d835
LyX`lyx::frontend::GuiView::triggerShowDialog(this=0x000000011b965eb0,
_t1=0x00007ffeefbf6538, _t2=0x00007ffeefbf6530,
_t3=0x0000000000000000) at moc_GuiView.cpp:259:5
frame #16: 0x0000000100e9d777
LyX`lyx::frontend::GuiView::showDialog(this=0x000000011b965eb0,
name="character", sdata="", inset=0x0000000000000000) at
GuiView.cpp:4834:2
frame #17: 0x0000000100e93c29
LyX`lyx::frontend::GuiView::dispatch(this=0x000000011b965eb0,
cmd=0x000000011ba08ac8, dr=0x00007ffeefbf9fd0) at GuiView.cpp:4412:5
frame #18: 0x0000000100b74135
LyX`lyx::frontend::GuiApplication::dispatch(this=0x0000000106a13930,
cmd=0x000000011ba08ac8, dr=0x00007ffeefbf9fd0) at
GuiApplication.cpp:2094:19
frame #19: 0x0000000100b6dd5d
LyX`lyx::frontend::GuiApplication::dispatch(this=0x0000000106a13930,
cmd=0x000000011ba08ac8) at GuiApplication.cpp:1409:3
The value of f in frame #7 is:
(lldb) print f
(const lyx::FontInfo) $0 = {
family_ = IGNORE_FAMILY
series_ = IGNORE_SERIES
shape_ = IGNORE_SHAPE
size_ = IGNORE_SIZE
style_ = IGNORE_STYLE
color_ = Color_ignore
background_ = Color_ignore
paint_color_ = (baseColor = Color_none, mergeColor = Color_ignore)
emph_ = FONT_OFF
underbar_ = FONT_IGNORE
strikeout_ = FONT_IGNORE
xout_ = FONT_IGNORE
uuline_ = FONT_IGNORE
uwave_ = FONT_IGNORE
noun_ = FONT_OFF
number_ = FONT_IGNORE
nospellcheck_ = FONT_OFF
}
Stephan
I don't know the solution to the problem. I thought
.realize(sane_font) is supposed to avoid that...
The problem, I think, is that the font has IGNORE lots of things in it.
FontInfo::realize does nothing with those but only with INHERIT. The
IGNORE stuff is perfectly valid here.
What are you trying to accomplish?
Very delicate the font stuff. I guess there could be a version of
realize that deals with ignore.
I was just playing around with the Text Properties dialog adding a text
properties indication, see patch attached which basically works but has
many flaws. I am just experimenting...
--
Daniel
diff --git a/po/de.gmo b/po/de.gmo
index 49c99e0895..7edfe8b56f 100644
Binary files a/po/de.gmo and b/po/de.gmo differ
diff --git a/po/ru.gmo b/po/ru.gmo
index a034bef156..ae2407728f 100644
Binary files a/po/ru.gmo and b/po/ru.gmo differ
diff --git a/po/sk.gmo b/po/sk.gmo
index 3c34f2ae2a..ca512b7cda 100644
Binary files a/po/sk.gmo and b/po/sk.gmo differ
diff --git a/src/FontInfo.cpp b/src/FontInfo.cpp
index 397f7271f0..2d0199b47d 100644
--- a/src/FontInfo.cpp
+++ b/src/FontInfo.cpp
@@ -268,56 +268,71 @@ void FontInfo::reduce(FontInfo const & tmplt)
/// Realize font from a template
-FontInfo & FontInfo::realize(FontInfo const & tmplt)
+FontInfo & FontInfo::realize(FontInfo const & tmplt, bool const &
realizeIgnore /* = false */)
{
if ((*this) == inherit_font) {
operator=(tmplt);
return *this;
}
- if (family_ == INHERIT_FAMILY)
+ if (family_ == INHERIT_FAMILY
+ || (realizeIgnore && family_ == IGNORE_FAMILY))
family_ = tmplt.family_;
- if (series_ == INHERIT_SERIES)
+ if (series_ == INHERIT_SERIES
+ || (realizeIgnore && series_ == IGNORE_SERIES))
series_ = tmplt.series_;
- if (shape_ == INHERIT_SHAPE)
+ if (shape_ == INHERIT_SHAPE
+ || (realizeIgnore && shape_ == IGNORE_SHAPE))
shape_ = tmplt.shape_;
- if (size_ == INHERIT_SIZE)
+ if (size_ == INHERIT_SIZE
+ || (realizeIgnore && size_ == IGNORE_SIZE))
size_ = tmplt.size_;
- if (style_ == INHERIT_STYLE)
+ if (style_ == INHERIT_STYLE
+ || (realizeIgnore && style_ == IGNORE_STYLE))
style_ = tmplt.style_;
- if (emph_ == FONT_INHERIT)
+ if (emph_ == FONT_INHERIT
+ || (realizeIgnore && emph_ == FONT_IGNORE))
emph_ = tmplt.emph_;
- if (underbar_ == FONT_INHERIT)
+ if (underbar_ == FONT_INHERIT
+ || (realizeIgnore && underbar_ == FONT_IGNORE))
underbar_ = tmplt.underbar_;
- if (strikeout_ == FONT_INHERIT)
+ if (strikeout_ == FONT_INHERIT
+ || (realizeIgnore && strikeout_ == FONT_IGNORE))
strikeout_ = tmplt.strikeout_;
- if (xout_ == FONT_INHERIT)
+ if (xout_ == FONT_INHERIT
+ || (realizeIgnore && xout_ == FONT_IGNORE))
xout_ = tmplt.xout_;
- if (uuline_ == FONT_INHERIT)
+ if (uuline_ == FONT_INHERIT
+ || (realizeIgnore && uuline_ == FONT_IGNORE))
uuline_ = tmplt.uuline_;
- if (uwave_ == FONT_INHERIT)
+ if (uwave_ == FONT_INHERIT
+ || (realizeIgnore && uwave_ == FONT_IGNORE))
uwave_ = tmplt.uwave_;
- if (noun_ == FONT_INHERIT)
+ if (noun_ == FONT_INHERIT
+ || (realizeIgnore && noun_ == FONT_IGNORE))
noun_ = tmplt.noun_;
- if (color_ == Color_inherit)
+ if (color_ == Color_inherit
+ || (realizeIgnore && color_ == Color_ignore))
color_ = tmplt.color_;
- if (background_ == Color_inherit)
+ if (background_ == Color_inherit
+ || (realizeIgnore && background_ == Color_ignore))
background_ = tmplt.background_;
- if (nospellcheck_ == FONT_INHERIT)
+ if (nospellcheck_ == FONT_INHERIT
+ || (realizeIgnore && nospellcheck_ == FONT_IGNORE))
nospellcheck_ = tmplt.nospellcheck_;
return *this;
diff --git a/src/FontInfo.h b/src/FontInfo.h
index 42eea31e92..6e9f97faa1 100644
--- a/src/FontInfo.h
+++ b/src/FontInfo.h
@@ -105,8 +105,8 @@ public:
Equal fields are reduced to INHERIT */
void reduce(FontInfo const & tmplt);
- /// Realize font from a template (INHERIT are realized)
- FontInfo & realize(FontInfo const & tmplt);
+ /// Realize font from a template (INHERIT, optionally IGNORE, are
realized)
+ FontInfo & realize(FontInfo const & tmplt, bool const & realizeIgnore =
false);
/// Is a given font fully resolved?
bool resolved() const;
diff --git a/src/frontends/qt/GuiCharacter.cpp
b/src/frontends/qt/GuiCharacter.cpp
index d1d4336fc2..a2b9bd269b 100644
--- a/src/frontends/qt/GuiCharacter.cpp
+++ b/src/frontends/qt/GuiCharacter.cpp
@@ -26,6 +26,7 @@
#include "ColorCache.h"
#include "ColorSet.h"
#include "Cursor.h"
+#include "GuiFontLoader.h"
#include "FuncRequest.h"
#include "Language.h"
#include "Paragraph.h"
@@ -430,6 +431,8 @@ void GuiCharacter::change_adaptor()
checkRestoreDefaults();
+ updatePreview(font_);
+
if (!autoapplyCB->isChecked())
return;
@@ -629,6 +632,8 @@ void GuiCharacter::paramsToDialog(Font const & font)
QString const lang = (font.language() == reset_language)
? "reset" : toqstr(font.language()->lang());
langCO->setCurrentIndex(findPos2nd(language, lang));
+
+ updatePreview(font);
}
@@ -648,8 +653,31 @@ void GuiCharacter::applyView()
font_.setLanguage(languages.getLanguage(
fromqstr(language[langCO->currentIndex()].second)));
+
+ updatePreview(font_);
}
+void GuiCharacter::updatePreview(Font const & font)
+{
+ FontInfo fi = font.fontInfo();
+ fi.setFamily(family[familyCO->currentIndex()].second);
+ fi.setSeries(series[seriesCO->currentIndex()].second);
+ fi.setShape(shape[shapeCO->currentIndex()].second);
+ fi.setSize(size[sizeCO->currentIndex()].second);
+ fi.setEmph(setMarkupState(emphCB->checkState()));
+ fi.setNoun(setMarkupState(nounCB->checkState()));
+ fi.setNoSpellcheck(setMarkupState(nospellcheckCB->checkState()));
+ setBar(fi, bar[ulineCO->currentIndex()].second);
+ setStrike(fi, strike[strikeCO->currentIndex()].second);
+
fi.setColor(lcolor.getFromLyXName(fromqstr(colorCO->itemData(colorCO->currentIndex()).toString())));
+
+ QString textcolor = toqstr(lcolor.getX11HexName(fi.color()));
+ QString backgroundcolor = toqstr(lcolor.getX11HexName(Color_background));
+ QString ftemp = tr("QLabel { color : %1; background-color : %2; }");
+ previewLA->setStyleSheet(ftemp.arg(textcolor, backgroundcolor));
+ previewLA->setFont(getFont(fi.realize(sane_font, true)));
+ previewLA->setText("Lorem ipsum");
+}
bool GuiCharacter::initialiseParams(string const &)
{
diff --git a/src/frontends/qt/GuiCharacter.h b/src/frontends/qt/GuiCharacter.h
index 40da643dff..eb91127513 100644
--- a/src/frontends/qt/GuiCharacter.h
+++ b/src/frontends/qt/GuiCharacter.h
@@ -76,6 +76,7 @@ private:
/// \name Dialog inherited methods
//@{
void applyView();
+ void updatePreview(Font const & font);
void updateContents();
bool initialiseParams(std::string const & data);
void clearParams() {}
diff --git a/src/frontends/qt/ui/CharacterUi.ui
b/src/frontends/qt/ui/CharacterUi.ui
index 841d03ec3b..b7da8fd52b 100644
--- a/src/frontends/qt/ui/CharacterUi.ui
+++ b/src/frontends/qt/ui/CharacterUi.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>545</width>
- <height>428</height>
+ <height>507</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,6 +17,82 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_7">
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="groupBox_4">
+ <property name="title">
+ <string>Language Settings</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_6">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="LanguageLA">
+ <property name="text">
+ <string>&Language:</string>
+ </property>
+ <property name="buddy">
+ <cstring>langCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="langCO">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Language</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="nospellcheckCB">
+ <property name="toolTip">
+ <string>If this is selected, the marked text will not be
spellchecked</string>
+ </property>
+ <property name="text">
+ <string>E&xclude from Spellchecking</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="autoapplyCB">
+ <property name="toolTip">
+ <string>Apply each change automatically</string>
+ </property>
+ <property name="text">
+ <string>Apply changes &immediately</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@@ -248,55 +324,6 @@
</item>
</layout>
</item>
- <item row="1" column="0">
- <widget class="QGroupBox" name="groupBox_4">
- <property name="title">
- <string>Language Settings</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout_6">
- <item row="0" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="LanguageLA">
- <property name="text">
- <string>&Language:</string>
- </property>
- <property name="buddy">
- <cstring>langCO</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="langCO">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Language</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="nospellcheckCB">
- <property name="toolTip">
- <string>If this is selected, the marked text will not be
spellchecked</string>
- </property>
- <property name="text">
- <string>E&xclude from Spellchecking</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
@@ -329,7 +356,7 @@
</layout>
</widget>
</item>
- <item row="3" column="0" colspan="2">
+ <item row="4" column="0" colspan="2">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
@@ -356,34 +383,57 @@
</layout>
</item>
<item row="2" column="0" colspan="2">
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QCheckBox" name="autoapplyCB">
- <property name="toolTip">
- <string>Apply each change automatically</string>
- </property>
- <property name="text">
- <string>Apply changes &immediately</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QFrame" name="horizontalFrame">
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,0">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="previewLA">
+ <property name="text">
+ <string>Preview goes here</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="margin">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>70</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
</item>
</layout>
</widget>
--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel