Bug 289745 - KFontChooser does not correctly save & load fonts
Summary: KFontChooser does not correctly save & load fonts
Status: RESOLVED DUPLICATE of bug 305747
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kdeui (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-24 14:58 UTC by Davorin Učakar
Modified: 2012-09-08 08:41 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.1


Attachments
test case to reproduce the bug (917 bytes, application/octet-stream)
2012-03-06 21:24 UTC, Dominik Haumann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Davorin Učakar 2011-12-24 14:58:27 UTC
Version:           unspecified (using Devel) 
OS:                Linux

[KatePart from KDE 4.7.95]
Settings dialog resets to wrong font face, but only for some fonts.

Reproducible: Didn't try

Steps to Reproduce:
Set LucidaTypewriter font, set "Sans" style and close settings. Open settings again and click OK. Font switches to "Sans Bold" style.

Actual Results:  
Settings dialog initially selects "Sans Bold" style, disregarding the actual settings.

Expected Results:  
Settings dialog should initialy select the font style that is actually set, not reset to some random one.

I only exeprianced the described problem for LucidaTypewriter font. In other cases (both TTF and bitmap fonts like DejaVu and Misc Fixed) everything works fine.
Comment 1 Travis Evans 2012-02-26 20:08:12 UTC
Confirmed in Kate on KDE 4.8.0, and I recall experiencing this in KDE 3.5 as well.

To reproduce:
1. Install Bitstream Vera fonts
2. Go into KAte's settings dialog and set the font style to, e.g., Bitstream Vera Sans Mono, style Roman.
3. Click OK.
4. Later, go back into the settings dialog. The style incorrectly reverts back to Oblique without even touching anything.
Comment 2 Dominik Haumann 2012-02-26 20:55:07 UTC
Another way to reproduce in dolphin:
1. "Configure Dolphin..."
2. switch to "View Modes"
3. Choose "Font: Custom Font" and click "Choose..."
4. Choose "Bitstream Very Sans Mono", "Roman", "10"
5. OK, Apply, Ok to close the settings again.

6. "Configure Dolphin..."
7. switch to "View Modes" and click "Choose..." again
8. selected is "Bitsream Vera Sans Mono", "Bold Oblique", "10".

Instead of "Bold Oblique", it should be "Roman".

In Kate, we use KConfigBase::writeEntry() to write the QFont to disk.
The string is: "Bitstream Vera Sans Mono,11,-1,5,50,0,0,0,0,0"

When loading it again with KConfigBase::readEntry(), the text is still
"Bitstream Vera Sans Mono,11,-1,5,50,0,0,0,0,0"

So saving & loading through the QVariant part seems to work correctly. The bug is probably somewhere after this step, maybe in KFontChooser itself?
Comment 3 Dominik Haumann 2012-03-06 21:24:14 UTC
Created attachment 69334 [details]
test case to reproduce the bug

Attached is a small demo application. It basically does the following:
1. read the font as we do in Kate: KConfig -> QVariant -> QFont
2. call KFontChooser::setFont()
3. get font with KFontChooser::font()

The test app compares 2 and 3. And the font style in 3 is incorrect.

KFontChooser::setFont() calls d->setupDisplay(); which in turn calls style = dbase.styleString(selFont).toLower();
Maybe this is where the result is already wrong.

@Preston, Bernd: Since you are the authors, can you please have a look as soon as possible?
Comment 4 Christoph Feck 2012-08-26 12:17:05 UTC
*** Bug 305747 has been marked as a duplicate of this bug. ***
Comment 5 Camilla Boemann 2012-08-26 12:42:11 UTC
I and Chusslove have analysed this and he is working on a fix
Comment 6 Christoph Feck 2012-08-27 19:40:56 UTC

*** This bug has been marked as a duplicate of bug 305747 ***