Author Topic: BUG?? TCanvas.TextOut (Brush=psSolid) doesn't paint background! (M1 > x86_64)  (Read 336 times)


  • Full Member
  • ***
  • Posts: 164
  • Pascal dev
Do the following in e.g. the OnPaint handler of a TPaintBox:

Code: [Select]
  with PaintBox1.Canvas do begin
    Brush.Color := clWhite;
    Brush.Style := bsSolid;
    FillRect(0,0, PaintBox1.Width, PaintBox1.Height); // paint the whole thing white
    Brush.Color := clLime;  // bright green background for text
    TextOut(10, 10, 'Green-highlighted text'); // write this text with green bg, brush style is still bsSolid, not bsClear

The above should produce a white rectangle with a bit of text with a green background.

But when I compile and run the above, the text has white background, as if Brush = bsClear!

This happens when I run Lazarus on a MacBook M2, Sonoma, compiling for x86_64. I just did a fresh install of FPC/Lazarus using the Stable version option (3.2.2 and 3) using fpcupdeluxe for x86_64. (Install fpcup x86_64, then install FPC and Laz together, stable version for both)

When I do the exact same thing on an Intel MacBook running Sierra, the result is correct. (The text has green background color)

When I copy the program compiled on the Intel/Sierra machine to the M2 machine, the result is also correct.

If I install the aarch64 version of FPC/Laz on the M2 machine, and compile the program for the ARM architecture, the result is correct.

As a final check, if I take the program compiled on M2 for x86_64 (which shows the bug) and run it on an Intel Mac, the bug shows there as well.

So, based on the data points above, the problem seems to be in the macos x86_64 compiler only, and the problem seems to only manifest itself when the compiling takes place on an Apple silicon machine. If the compiling (same FPC version, 3.2.2) is done on an Intel machine, the program works correctly on both Intel and M2 machines.

The Sonoma M2 machine has Xcode 15.2 installed and the older Sierra Intel machine has Xcode 8.0

I tried to search for this bug but I didn't find anything, which seems strange to me...unless I'm doing something dumb, this is a bug that should have been spotted long ago... am I missing something here? I then tried my luck calling Canvas.Refresh , Canvas.Unlock , etc. but nothing seems to work... help please?
« Last Edit: March 03, 2024, 02:37:17 pm by Manlio »
manlio mazzon gmail


TinyPortal © 2005-2018