Recent

Author Topic: TLabel: Autosize error with some UTF8 glyphs  (Read 1732 times)

winni

  • Hero Member
  • *****
  • Posts: 3197
TLabel: Autosize error with some UTF8 glyphs
« on: October 18, 2019, 12:09:01 pm »
Hi!

I stumbled again over this error:

Label with autosize on

Code: Pascal  [Select][+][-]
  1. Label1.caption :=' ⃤';

This is

Code: Text  [Select][+][-]
  1. U+20E4  /  ⃤  /  E283A4  / 14844836  /  COMBINING ENCLOSING UPWARD POINTING TRIANGLE
  2.  

The glyph is positioned far too much left as shown in the attached screenshot.

The same error appears if I show the triangle in a TComponent.hint.

And if I do some canvas routines to draw text with tacenter the glyph appears  too much left.

Is this error known?

Winni

PS The forum editor does a better job!

« Last Edit: October 18, 2019, 12:12:17 pm by winni »

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #1 on: October 18, 2019, 12:25:45 pm »
Ooops,forgot:

Linux64 , fpc 3.04, Laz 2.04, gtk2

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #2 on: October 19, 2019, 05:37:34 pm »
Please test that glyph on the TextWidth call of the canvas and see what value it reports.
The only true wisdom is knowing you know nothing

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #3 on: October 19, 2019, 05:44:32 pm »
If this is a "combining" codepoint, should it then not have something to combine with? Maybe put a space in front of it?

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #4 on: October 19, 2019, 06:31:08 pm »
I am thinking that maybe a negative value is being returned for some reason with the TextWidth call ?

The only true wisdom is knowing you know nothing

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #5 on: October 19, 2019, 06:33:31 pm »
Hi!

The triangle has the width=0.Lol. Whatever happend there.
Made a mini log (jamie) and added a space in front (Martin_fr).
The result:

Code: Text  [Select][+][-]
  1. U+20E4:    ⃤
  2. Liberation Sans bold
  3. Font.size: 10
  4. Char(s) Width: 0
  5. Char(s) Height: 20
  6.  
  7.  
  8. Added leading #32 U+20E4:     ⃤
  9. Liberation Sans bold
  10. Font.size: 10
  11. Char(s) Width: 3
  12. Char(s) Height: 20
  13.  

If you put 3 or 4 spaces in Front and behind it is not cuted. But that is no solution.

Who determines the textextent.cx? First the TTF file and then it is resized. So where to search for the error?

Winni

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #6 on: October 19, 2019, 06:50:56 pm »
Hi!

I just tested 25..30 different TTF fonts.

But always the same result: The width of the triangle is zero.

Now I will  test some other applications.

Winni

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #7 on: October 19, 2019, 07:09:26 pm »
Hi!

Just tested some apps with the "Triangle-Zero-Length-Error".

Libre Office writer: Error
Thunderbird: Error
Kate: OK
Inkscape: Error
Forum Editor: OK

Lazarus is not alone!

Winni

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #8 on: October 19, 2019, 10:12:58 pm »
Hi!

Mystery solved. UTF-8 is not so easy. I found the related block for the    ⃤  .
It is "U+20D0..U+20FF Combining Diacritical Marks for Symbols".
All this glyphs have a width = 0. They are intended not to move forward while writing like
the "dead letters" on the keyboard.

In total there are more than 800 of this diacritical marksin UTF-8, not only for french but thai, mongolian, hebrew, arabian kyrilic and other languages.

So the label and the hint should be aware of the width=0 and place the char correct.

So kate and the forum editor are wrong. And the other apps are right.

Thanx for your help.

Winni


jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #9 on: October 20, 2019, 01:23:28 am »
Ok, so that makes sense but still, shouldn't it be to the left and not off the chart ?
The only true wisdom is knowing you know nothing

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #10 on: October 20, 2019, 01:56:01 am »
Hi!

Yes jamie, the glyphs should be at their positions. The french circonflex should be centered over a small letter and so on. If no other letter is present they should be adjusted left.

I have a guess. The very most of this diacritical marks are very small signs like
' ` ´
But the triangle has in - monospaced terms - the double width.

So perhaps someone in the LCL code relied that all those signs are only "dust" and not double width?!

Winni

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: TLabel: Autosize error with some UTF8 glyphs
« Reply #11 on: October 20, 2019, 10:21:38 am »
Mystery solved. UTF-8 is not so easy. I found the related block for the    ⃤  .
It is "U+20D0..U+20FF Combining Diacritical Marks for Symbols".
All this glyphs have a width = 0. They are intended not to move forward while writing like
the "dead letters" on the keyboard.

Hence I pointed out "combining".

It may depend on the font what exactly it can combine with... I would have expected it to combine with a space. But then it may not.

 

TinyPortal © 2005-2018