Extend the text tool.
Open, Needs TriagePublic

Description

A continuation of T1004

In Krita 4.0, we released a text tool that can...

  • Handle richtext styling like fonts, bold, italic.
  • Handle Unicode goodness such as Middle-eastern and Asian scripts, as well as Emoji's (When you have an emoji font installed), and weird freaky unicode stuff like Zalgo: https://eeemo.net/
  • Left to Right and Right to Left are automatically recongised!
  • Copy-paste/find/replace/syntax highlighting, and more editor functions.

Original Requirements:

  • paragraphs (but not pages)
  • Multi language support:
    • right-to-left
    • left-to-right
    • top-to-bottom script layout
    • support for western scripts, semitic scripts and chinese/japanese. (Unicode support)
    • Mongolian, probably not so much. (Top to bottom, left to right, as opposed to CJK top to bottom, right to left)
  • fill irregular shapes (balloons and boxes)
  • styles: bold, italic, fonts
  • compatible with inkscape (svg)
  • can be put on a path
  • easily translatable using scripts that work on .kra files (Wolthera made a POT extractor for the comics manager in python, so this is easily possible.)
  • can be baked/rendered from a .kra file -- What does this mean?

What SVG features are still open:

SVG 1.1

  • Rotation attribute
  • Handling multiple inputs into dx/dy/x/y properly.
  • Text on path (this basically takes the previous two to be fixed and then have an arbitrary path used as input for this.
  • Text on path, stretched. This is a different beast from above as it requires deforming the path itself, instead of just rotating and positioning things.
  • XML white-space handling (Check svg2 too)
  • TextLength and lengthAdjust
  • Font stretch
  • Small caps (Font-variant, Check svg2 too)
  • Dominant baseline (Check svg2 too)
  • Alignment baseline (Check svg2 too)
  • Writing mode and glyph orientation. (Check svg2 too)

SVG 2

  • CSS whitespace: Pre/Preline/Normal/Prewrap/Nowrap.
  • Text-decoration line/text decoration-style/text-decoration-fill/text-decoration-stroke
  • Font-variant for all sorts of open type features. (This will require modifying QT itself to get access to Harfbuzz)
  • CSS writing mode values instead of svg 1.1 writing mode values.
  • Dominant baseline: Reset size/use-script/no change
  • Alignment baseline: 'auto', 'before-edge', and 'after-edge' removed.
  • Baseline-shift: 'baseline' property should be converted to '0' or just not defined at all.
  • Letterspacing: "SVG 2 removes percentage values from the letter-spacing property. "
  • Wordspacing: " In SVG 1.1, percentages define additional spacing as a percentage of the SVG viewport size. In SVG 2, following CSS Text Level 3, percentages define additional spacing as a percentage of the affected character's width. "
  • Kerning: "This property is replaced in SVG 2 by the CSS font-kerning property which solely controls turning on/off the use of the font kerning tables. "

Wrapping text:

  • Inline size: A given width(or height in case of vertical text) at which text wraps around.
  • Shape inside/shape subtract/shape padding/shape margin/shape image threshold: A crazy christmas tree way of defining text-layout areas. Will require...
    • A layout algorithm that can take several arbitrary shapes and lay out the text accross that. And handle justfied/center/right/left align
    • A way to define several arbitrary shapes.
    • See how we would want to use shape subtract.
    • An algorithm that can take arbitrary shapes and add/remove padding/margin to them.
    • A moment of wonderin whether we want to support shape image threshold at all... (And if so, how!)
  • Text-align: Left, Right, Justify, Center
  • Text-align last: The alignment of the last bit of text.
  • Line-break
  • Word-break
  • Hyphens
  • Word-wrap
  • Overflow wrap.
  • Text-overflow
  • Line-height

GUI

  • Wordspacing/LetterSpacing/Kerning all work and the gui for it should be merged to master.

Other:

  • There's still a weird thing where QT doesn't report the size of fonts properly. This is super-evident with things like Zalgo, but less so with things like italics on text. There's a hack for the latter in the code, so we need to be mindful of that.
  • We will need to sit down for things regarding Asian specific styling methods, like emphasis marks and ruby. SVG has nothing about this in its specs.
  • Think about text-styling and css stylesheets and when we want to use these.
hellozee claimed this task.Mar 13 2018, 2:49 PM
hellozee added subscribers: rempt, hellozee.

Working on the GUI widgets, strangely the gui reports the letter spacing as 100 whereas the value should be 0, either it is giving the value in percentage or I am doing something wrong.

Working on the GUI widgets, strangely the gui reports the letter spacing as 100 whereas the value should be 0, either it is giving the value in percentage or I am doing something wrong.

It is probably defaulting to percentual letterspacing, so check the font letterspacing type first: https://doc.qt.io/qt-5/qtextcharformat.html#fontLetterSpacingType

Hi :)
I'd like to thank you all for the work done on supporting SVG and RTL text. This is really appreciated.

I was testing one of the last nightly (or beta) builds and found out that the direction of Arabic text is LTR. The special SVG "direction" property is needed for the direction to be applied.

Another small issue: If you typed a LTR sentence and then hit Enter then typed a RTL sentence, (and you applied the direction property to the RTL one), you'll get this: :)

Font-variant for all sorts of open type features. (This will require modifying QT itself to get access to Harfbuzz)

This will be really beneficial for many software, but I'm not sure Qt will expose that stuff so easily...
As you know, Scribus went the long way and added support by using HarfBuzz directly.

That's all. Thanks!

woltherav added a comment.EditedMar 19 2018, 11:31 AM

Hi :)
I'd like to thank you all for the work done on supporting SVG and RTL text. This is really appreciated.

I was testing one of the last nightly (or beta) builds and found out that the direction of Arabic text is LTR. The special SVG "direction" property is needed for the direction to be applied.

Another small issue: If you typed a LTR sentence and then hit Enter then typed a RTL sentence, (and you applied the direction property to the RTL one), you'll get this: :)

Font-variant for all sorts of open type features. (This will require modifying QT itself to get access to Harfbuzz)

This will be really beneficial for many software, but I'm not sure Qt will expose that stuff so easily...
As you know, Scribus went the long way and added support by using HarfBuzz directly.

That's all. Thanks!

Could you please report a bug for these at bugs.kde.org? Phabricator comments are too difficult to track bugs in.

(Also, add a screenshot of what it looks like in the editor then)

Hi :)
I'd like to thank you all for the work done on supporting SVG and RTL text. This is really appreciated.

I was testing one of the last nightly (or beta) builds and found out that the direction of Arabic text is LTR. The special SVG "direction" property is needed for the direction to be applied.

Another small issue: If you typed a LTR sentence and then hit Enter then typed a RTL sentence, (and you applied the direction property to the RTL one), you'll get this: :)

Font-variant for all sorts of open type features. (This will require modifying QT itself to get access to Harfbuzz)

This will be really beneficial for many software, but I'm not sure Qt will expose that stuff so easily...
As you know, Scribus went the long way and added support by using HarfBuzz directly.

That's all. Thanks!

Could you please report a bug for these at bugs.kde.org? Phabricator comments are too difficult to track bugs in.

(Also, add a screenshot of what it looks like in the editor then)

Done in 392064 and 392065

hellozee removed hellozee as the assignee of this task.Apr 6 2018, 10:32 AM