get QFont from _font

Daniel xracoonx at gmx.de
Thu Aug 13 15:50:14 UTC 2020


On 2020-08-13 16:53, Richard Kimberly Heck wrote:
> On 8/13/20 4:48 AM, Daniel wrote:
>> 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 <xracoonx at 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...
> 
> I thought that was probably it.
> 
> So yes, you'd need a version of realize that deals with IGNORE. (I
> believe IGNORE only makes sense in the dialog, which is why realize
> doesn't deal with it.) Also, you would probably want to get the font in
> effect at the current cursor position, and realize against that. I
> believe that GuiCharacter should have access to a BufferView, which has
> a Cursor, which can get you the Font.

I'll take a look.

Jürgen, you have put some lifeblood in the Text Properties dialog. Would 
a preview of the selected text properties be something you think would 
be worth having in the dialog?
-- 
Daniel



More information about the lyx-devel mailing list