Bug 392343

Summary: Text editor's Font-Style droplist and Bold button are broken
Product: [Applications] krita Reporter: Tyson Tan <tysontanx>
Component: Layers/VectorAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: danielpetrov, dimula73, eliasvaha, halla, mail, rebecca, tristanbaymusic
Priority: NOR Keywords: investigated, triaged
Version: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Appimage   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Tyson Tan 2018-03-26 01:45:09 UTC
krita-4.1.0-pre-alpha-56b4749-x86_64.appimage

Many fonts come with built-in font-styles, for example, the text editor's default Bitstream Vera Sans has 4: Oblique/Roman/Bold/Bold oblique. These font-styles are displayed on the drop-list on the right of the fonts. However, whatever I chose from that drop-list, they can neither be reflected in the editor window nor the actual text on canvas. Only the B/I/U buttons in the text editor's toolbar has effect, but those are not native thus not ideal. Besides, they cannot handle thin  style. And thus I cannot use a huge portion of the font's styles.
Comment 1 Julian Steinmann 2018-09-15 14:41:32 UTC
I can reproduce this behavior with Krita 4.2.0-alpha (commit a794d32).

Operating System: KDE neon Developer Edition
KDE-Plasma-Version: 5.13.90
Qt-Version: 5.11.1
KDE-Frameworks-Version: 5.51.0
Comment 2 Dmitry Kazakov 2018-10-07 16:17:21 UTC
Looks like we should wait until we start implementing our own renderer before we can fix this bug :(
Comment 3 Tyson Tan 2018-10-15 02:06:44 UTC
@Dmitry
Thanks for letting me know! :)
Comment 4 Tiar 2019-12-15 23:14:35 UTC
*** Bug 415176 has been marked as a duplicate of this bug. ***
Comment 5 Tyson Tan 2020-03-16 03:47:23 UTC
First of all, the "Bold" button in Text Editor is now broken in the 4.3.0 branch.

Second, we had workaround to use SOME of the native font variants in Krita's Text Edior, but it only worked in 4.2.x. It's also broken in the 4.3.0 branch.

=======================

For example, the font "Noto Sans CJK" from Manjaro Linux has 7 .ttc files, each for one STYLE.

/usr/share/fonts/noto-cjk/NotoSansCJK-Black.ttc
/usr/share/fonts/noto-cjk/NotoSansCJK-Bold.ttc
/usr/share/fonts/noto-cjk/NotoSansCJK-DemiLight.ttc
/usr/share/fonts/noto-cjk/NotoSansCJK-Light.ttc
/usr/share/fonts/noto-cjk/NotoSansCJK-Medium.ttc
/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc
/usr/share/fonts/noto-cjk/NotoSansCJK-Thin.ttc

But each of those .ttc files has 4 actual fonts:
Noto Sans CJK SC (Simplified Chinese)
Noto Sans CJK TC (Traditional Chinese)
Noto Sans CJK KR (Korean)
Noto Sans CJK JP (Japanese)

So, with the whole font package correctly installed, I have the 4 fonts in the FONT droplist:

Noto Sans CJK SC
Noto Sans CJK TC
Noto Sans CJK KR
Noto Sans CJK JP

And 7 STYLES in the STYLE droplist:

Black
Bold
DemiLight
Light
Medium
Regular
Thin

(I know, it's quite complicated and confusing, what kind of black magic is going on here and why they do this...)

=======================

As reported before, the STYLE droplist doesn't work. But I can still use some of the styles by typing the style name after the font name in Font droplist:

"Noto Sans CJK SC Black"

But for some reason, the Bold style doesn't work even when I used:

"Noto Sans CJK SC Bold"

=======================

The workaround above worked in 4.2.x including the latest 4.2.9 beta. But somewhere between Jan and Feb 2020, it was broken in the 4.3.0 branch. But if a .kra file has the workaround done in 4.2.x, it'll still work until you changed the fonts. Makes me feel it's really a UI problem...

With both the Bold button and all Styles unavailable, it hinders our text works greatly. Really not looking forward to switch between Krita and GIMP again :P
Comment 6 Tyson Tan 2020-03-19 16:53:41 UTC
Today I found out what broke the droplist workaround, as well as discovering a new workaround to make use of font styles.



### What broke the droplist workaround:

For some reason, now in 4.3.0prealpha, whenever I tried to input some letters inside the Text Editor's font name droplist, the moment I put the second letter, all new letters (the first and second letter I just input) get HIGHLIGHTED. So now if I input a third letter, the previous two letters are deleted.



### Workaround 1:

Press Left Arrow key to cancel the highlight state and move the input cursor to the end. Do this once every two letters are input.

To input "Bold":
1) Input "B" and "o"
2) Press Left arrow
3) Input "l"
4) Press Left arrow
5) Input "d"
6) Press Left arrow

If the added letters match a style name, it will be activated.



### Workaround 2:

Tool options panel of the Text tool has a font droplist as well, and that droplist for some reason lists EVERY font style. In this way we can determine a font with its native style before we create the actual text.



### The missing Bold style:

Curiously though, this droplist in Tool options doesn't list any font's Bold style! I wonder whether the Bold ones were linked to/confused with the Bold  button in Text Editor's toolbar, which in turn broke both ways as a result?
Comment 7 Rebecca Breu 2020-03-21 19:55:10 UTC
*** Bug 419081 has been marked as a duplicate of this bug. ***
Comment 8 Rebecca Breu 2020-03-21 19:57:05 UTC
Bold is already broken in 4.2.8, see 419081. (I can confirm that as well).
Comment 9 Tyson Tan 2020-05-14 03:50:03 UTC
May I ask if we can, for the moment, just disable the "auto-completion" and "automatically selecting a font as you type" thing for the input box? It's very broken at the moment, inputting a font name is basically impossible and it really makes life so difficult around the text tool. Accessing font-style is also a nightmare because of it.
Comment 10 Bug Janitor Service 2021-09-24 04:46:55 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1065
Comment 11 Halla Rempt 2021-09-24 08:42:25 UTC
Git commit 371894feca52dec75ac2c33aebccbfe7ba75b6a7 by Halla Rempt, on behalf of Black Cat.
Committed on 24/09/2021 at 08:33.
Pushed by rempt into branch 'master'.

Fix applying font styles to text in vector text tool

* Apply font style as combination of font weight and italization
* Show correct font style and font properties (bold, italic, etc) on
  cursor change or font style update
* Fix text changing format and loosing whitespaces while switching
  from Rich Text to Svg Source tab

M  +6    -9    libs/flake/text/KoSvgTextShapeMarkupConverter.cpp
M  +12   -11   libs/widgetutils/kis_font_family_combo_box.cpp
M  +18   -4    plugins/tools/svgtexttool/SvgTextEditor.cpp

https://invent.kde.org/graphics/krita/commit/371894feca52dec75ac2c33aebccbfe7ba75b6a7
Comment 12 Halla Rempt 2021-09-24 08:43:16 UTC
Git commit af510b47afc7368a2d2a34cc8d2730070f09f27e by Halla Rempt, on behalf of Black Cat.
Committed on 24/09/2021 at 08:43.
Pushed by rempt into branch 'krita/5.0'.

Fix applying font styles to text in vector text tool

* Apply font style as combination of font weight and italization
* Show correct font style and font properties (bold, italic, etc) on
  cursor change or font style update
* Fix text changing format and loosing whitespaces while switching
  from Rich Text to Svg Source tab

(cherry picked from commit 371894feca52dec75ac2c33aebccbfe7ba75b6a7)

M  +6    -9    libs/flake/text/KoSvgTextShapeMarkupConverter.cpp
M  +12   -11   libs/widgetutils/kis_font_family_combo_box.cpp
M  +18   -4    plugins/tools/svgtexttool/SvgTextEditor.cpp

https://invent.kde.org/graphics/krita/commit/af510b47afc7368a2d2a34cc8d2730070f09f27e
Comment 13 Tyson Tan 2021-09-25 09:48:36 UTC
Thank you Artem and Halla! :D

One thing though: after this fix, the Style droplist can CHANGE the style, but it does not SHOW the current style -- it is stuck as "regular". Unlike the Size droplist which shows the current size of the cursor position.

Do I open a new bug, or do I reopen this bug?