Recent

Author Topic: TextOut: taCenter broken  (Read 2852 times)

winni

  • Hero Member
  • *****
  • Posts: 3197
TextOut: taCenter broken
« on: November 25, 2019, 01:40:57 am »
@circular

I just updated BGRAbitmap from 9.9.3 --> 10060400

Suddenly a lot of text printed on BGRAbitmaps was gone.
As sometimes there were little lines at the right border I could find out that error quick:

taCenter as parameter for the TextOut is the reason.

The text is not printed in the center of the bitmap but starts at the right edge - sometimes leaving a little bit "dirt" at the border. The rest is writen into nowhere.

Just test:

Code: Pascal  [Select][+][-]
  1. tmp: TBGRABitmap;
  2.  
  3. tmp.TextOut(tmp.width div 2, y, MyText, color, taCenter);
  4.  

You see that you see nothing....

Would be nice if you correct this!

Winni

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TextOut: taCenter broken
« Reply #1 on: November 28, 2019, 09:45:47 pm »
Hi!

Now I made some additional tests:

* If I add a renderer and a shader to the BGRAbitmap then there is no problem with taCenter
* With TextOutAngle there is no  problem with taCenter

So it seems that only the plain textOut without renderer and without an angle has this problem.

Winni

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: TextOut: taCenter broken
« Reply #2 on: November 28, 2019, 11:58:00 pm »
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: TextOut: taCenter broken
« Reply #3 on: November 29, 2019, 07:39:49 pm »
Hmm I just tested on Linux and see no problem.

Have you tried a clean build of BGRABitmap and your program?
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TextOut: taCenter broken
« Reply #4 on: November 29, 2019, 08:55:54 pm »
Hi!

I was quiet shure but I just did a clean & build - no changes.

I just made a demo - see attachment. This is

Code: Pascal  [Select][+][-]
  1. tmp.TextOut (0,12,'Hello World' ,col, taCenter);

My setup:
Linux64 gtk2, Laz 2.06, fpc 3.04, BGRAbitmap 10.6

Winni

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: TextOut: taCenter broken
« Reply #5 on: November 29, 2019, 09:11:58 pm »
I don't have the bug on Linux 64 and Lazarus 2.0.2.

Could it be related to version of Lazarus ?

Anyone else on Linux having the bug with center?
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TextOut: taCenter broken
« Reply #6 on: November 29, 2019, 09:41:17 pm »
Hi!

The colorful world of Lazarus and BGRAbitmap:

I started Win7  in VBox.
There is installed:
Laz 2.0, fpc 3.04 and BGRABitmap 9.9.3

I made an online update to BGRABitmap 10.06 (and BGRAcontrol)
Compiled the IDE
Made a build for the project:

The same result as with linux: all moved to the right.

It seems that the text is displayed at

Center.x + TextWidth(string) div 2;

It should be

Center.x - TextWidth(string) div 2;

Winni


« Last Edit: November 29, 2019, 09:58:11 pm by winni »

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: TextOut: taCenter broken
« Reply #7 on: November 29, 2019, 10:27:01 pm »
Hmm, maybe if I try on some Windows computer, I could reproduce the bug.
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TextOut: taCenter broken
« Reply #8 on: November 29, 2019, 10:51:38 pm »
Hi circular!

I've got the "Bad Boy":

It is the Font.renderer !

I had to dive deep in my sources:

Without renderer everything works fine.
When I set the renderer.OutlineColor at once the text dissapears at the right side!

So you can stop the windows testing!

Winni



circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: TextOut: taCenter broken
« Reply #9 on: November 30, 2019, 03:23:56 pm »
Hmm ok, so do you have any idea where the bug happens? Which line of code?
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TextOut: taCenter broken
« Reply #10 on: November 30, 2019, 07:09:17 pm »
@circular

Debug, debug ...

Made a BGRAbitmap with a renderer and made a BGRA tour:

BGRAtextFX, BGRAvectorize and BGRAtypewriter.

Now i reached

procedure TBGRACustomTypeWriter.DrawText( ....

Here the x coordinate has still the correct value for taCenter:
Bmap.width = 300
center.x = 150

No I loose concentration and will continue later.

Winni

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TextOut: taCenter broken
« Reply #11 on: November 30, 2019, 10:50:56 pm »
Hi circular!

Something is going wrong here:

Code: Pascal  [Select][+][-]
  1. procedure TBGRACustomTypeWriter.DrawText(ADest: TBGRACanvas2D; ATextUTF8: string;  X, Y: Single; AAlign: TBGRATypeWriterAlignment);
  2.  

X and Y are still correct here, but then I do for tracing:

* fetch from the Canvas2D the points into an ArrayOfFPointF with
MyPoints := TheCanvas2D.currentPath;

* Convert the points to a string and add it to a StringList

* Save the StringList

No it comes to the nitty gritty:
My bitmap has a width of 300.
All points have an x between 300 and 600!!!

I guess the error could be inside the matrix operations for the Path, but I fear I get lost there.

Winni

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: TextOut: taCenter broken
« Reply #12 on: December 01, 2019, 01:42:47 am »
Hi circular!

Didn't get lost in the matrix jungle.

Now I give you two minus signs. As present.

Here is the "evil" one:

Code: Pascal  [Select][+][-]
  1. function TBGRACustomTypeWriter.GetTextMatrix(ATextUTF8: string; X, Y: Single;
  2.         AAlign: TBGRATypeWriterAlignment): TAffineMatrix;  

You forgot two minus signs. The code sgould be:

Code: Pascal  [Select][+][-]
  1. if AAlign in[twaTop,twaMiddle,twaBottom] then tGlyph.X := -size.x/2 else
  2.     if AAlign in[twaTopRight, twaRight, twaBottomRight] then tGlyph.X := -size.x;    

Since yesterday I know that textcolor inside pascal code in this editor together does not work so again her:

-size.x/2 
and
-size.x

Now I need a beer.

Winni

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: TextOut: taCenter broken
« Reply #13 on: December 01, 2019, 03:48:51 am »
I have been there one or two times catching a bug without knowing how to use a debugger  :-X

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: TextOut: taCenter broken
« Reply #14 on: December 01, 2019, 04:08:47 pm »
Thank you very much.

That seems indeed wrong.  :-[

That's changed on dev branch.  :)
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018