bgrabitmap / bgrabitmap

📜 BGRABitmap graphics library made with Lazarus (Free Pascal).
https://bgrabitmap.github.io/
202 stars 33 forks source link

TextOut: taCenter broken #80

Closed circular17 closed 4 years ago

circular17 commented 5 years ago

https://forum.lazarus.freepascal.org/index.php/topic,47527.0.html

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:

    tmp: TBGRABitmap;
    tmp.TextOut(tmp.width div 2, y, MyText, color, taCenter);

You see that you see nothing....

Would be nice if you correct this!

Now I made some additional tests:

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

Winni

circular17 commented 5 years ago

Hmm I just tested on Linux and see no problem.

Have you tried a clean build of BGRABitmap and your program?

circular17 commented 4 years ago

Hi circular!

Didn't get lost in the matrix jungle.

Now I give you two minus signs. As present.

Here is the "evil" one:

function TBGRACustomTypeWriter.GetTextMatrix(ATextUTF8: string; X, Y: Single;
        AAlign: TBGRATypeWriterAlignment): TAffineMatrix;

You forgot two minus signs. The code sgould be:

if AAlign in[twaTop,twaMiddle,twaBottom] then tGlyph.X := -size.x/2 else
    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

circular17 commented 4 years ago

Thank you very much. I applied the change.