View Issue Details

IDProjectCategoryView StatusLast Update
0033990LazarusWidgetsetpublic2020-01-12 22:00
Reportercobata Assigned ToDmitry Boyarintsev  
Status closedResolutionfixed 
Product Version1.9 (SVN) 
Summary0033990: Difference between Cocoa and Carbon DPI, or Font size, or Line height...?
DescriptionPorting from Carbon to Cocoa...
Exists some difference between Cocoa and Carbon DPI, or Font size, or Line height...? It is more obvious on forms with more components and/ or TLabels with multiline text, for example.
The attached zip contains the project and sources.
Steps To ReproduceSee above.
Just open and build the project for Carbon on Lazarus 1.8.4 and for Cocoa on Lazarus Trunk 1.9.0 and run them.

Because the forms contain just 2 components, run the Carbon and Cocoa apps and place their main forms one over the other and switch continuously between the apps by clicking on their icons (to catch the differences).
TagsNo tags attached.
Fixed in Revision62528
Attached Files



2018-07-14 19:55

reporter (130,229 bytes)


2018-07-18 17:01

reporter   ~0109562


I read 0031037, which actually I found:,34896.0.html

Thanks to Alextp and the other devs...

I am doing cross-platform software: Vista_32/Delphi->Vista_32/Lazarus->Win10_64/Lazarus->macOS_Carbon (and NOW macOS_Cocoa)...

Actually, (till NOW) I solved the issue for my software, with the following code for the main form:

But NOW I found the reported difference, which is not too big, but I found it and please, do not rely on this -> there is something.

I built my software with and without the solution above, but I found no change.

1. Can I continue use my solution after your intervention?
2. Do you have idea what causes this difference?
3. Do you know some workaround?

Best Regards,

Chris Rorden

2018-07-19 16:17

reporter   ~0109571

With Cocoa, some native widgets are drawn at a specific size, so a TButton will have a fixed height on Cocoa regardless of what height or scaling you request. The benefit of this approach is you are using the native widgets, and these widgets appear identical to other native Mac applications (style consistency). If this is unacceptable, you may want to choose a themed widget (like tspeedbutton) instead: this may make your applications appear more similar between Linux/Windows/Mac at the cost of looking alien in MacOS.

The Font size difference between Cocoa and Carbon is described here
A good resource is here

For a cross-platform project, you may want to examine your auto-size anchor options


2018-07-22 11:56

reporter   ~0109629

With this set, on both Carbon and Cocoa:
On Carbon the Font Size is 12, but on Cocoa the Font Size is 16 - looking in the Font dialogs.
As I already said the Fonts look nearly the same, but they are not (12 vs 16). You can reset the Font Sizes to be equal (to 12), but then the visual difference is big.

When remove the condition on Cocoa:
The observations are the same.


2018-08-04 10:03

reporter   ~0109873

Is the last provided info useful?
Do you plan to fix this?


2019-07-18 09:58

reporter   ~0117299


Again, on this issue... The problem is not in Carbon as you describe in the documentation (above), or we talk for different/ more problems. I think that because, as I already said: I found the DPI problem (above) and I do intensive cross-platform development and in CARBON the things behave more like in Windows (ws)... The issue appears on COCOA mainly when on assigning Font (or Font properties) and for the same thing (for example a TLabel component) the input differs from the output: the read Font.size value differs from the written one. This does not appear for Carbon.

Please, take attention on this.
I do not know where is exactly the problem in Cocoa ws in Lazarus or Cocoa macOS.

Best Regards


2019-07-18 10:50

reporter   ~0117300

Last edited: 2019-07-18 12:05

View 3 revisions

Addition: the diff between the read and the write Font.size value (ex.: TLabel) appears after reading the value in the Font dialog/ after open the Font dialog in runtime (ex.: for TLabel) (and it appears with sign "-" if you print it).

Dmitry Boyarintsev

2019-07-19 15:48


forms.png (26,465 bytes)   
forms.png (26,465 bytes)   

Dmitry Boyarintsev

2019-07-19 16:31

developer   ~0117317

I've attached a screenshot from Cocoa, Carbon and Windows.
Could you please explain in details - your concern.

Cocoa and Carbon look alike to me. Yes, the "font" for label is different (but this is due to different APIs used to get "system default" font)

macOS systems vs Windows look different, is likely due to different DPI (96) (PPI 72) used.


2019-07-20 04:57

reporter   ~0117325

Last edited: 2019-07-20 05:13

View 2 revisions

Hi, Dmitry,

Thank you for your attention.
The difference in Font representation is small and as I already described above is not the problem.
The problem is that for the same component TLabel with Font.size = 12 (pt) on Carbon Font dialog opened for the TLabel to get/set shows size 12, but on Cocoa - 16 and when you try to set it to 12 the difference is big - its as first.
The second is that in case that you just open a Font dialog for a TLabel, just to get/ see the size value, but even do not try to set it and next to print the Font.size for that TLabel the printed value is with sign minus, which is not correct - and this is on Cocoa only.

Those are my concerns: I extensively work with the Font dialog to read/get and write/set the Font.size values and to write and read them to/from a file.

Thank you, Dmitry,
Best Regards

Dmitry Boyarintsev

2019-07-21 04:45

developer   ~0117332

if Font dialog is the issue, then it certainty can be be.

could you please provide an example?
preferably with screen shots, indicating the difference between Carbon and Cocoa.


2019-07-21 09:48

reporter   ~0117333

Today I will prepare an example...
I thought the same that the problem is in the Font dialog, but that I saw in the code, it just uses Font.Assign() for the SET and in Font (classes hierarchy) the .size and the .height props are set with formula, taking in account the DPIs, from where the sign MINUS appears for the .size (I am not compared the diffs between Carbon Font (classes) and Cocoa Font (classes), but it is like the .height value is assigning to the .size OR vice versa, or the DPI params are swapped...


2019-07-21 16:12

reporter (2,064 bytes)


2019-07-21 16:12


1.png (210,791 bytes)   
1.png (210,791 bytes)   


2019-07-21 16:13


2.png (221,731 bytes)   
2.png (221,731 bytes)   


2019-07-21 16:17

reporter   ~0117338

See the attachments on Cocoa: On Carbon (compiled on Laz 1.8.4) FontDialog get/ set the correct values.


2019-10-04 11:54

reporter   ~0118316

Dmitry, do you need additional info?


2019-12-24 09:58

reporter   ~0120051

Merry Cristmas and Happy new year!

Dmitry Boyarintsev

2019-12-24 18:17

developer   ~0120052

Merry Christmas! I'm afraid there's no movement in the area to resolve ppi conflict between nacOS and LCL

CudaText man

2019-12-24 19:57

reporter   ~0120054

Your description of issue is vague, I dont understand what is the issue. Attach simple demo with source to show the problem, it must differ on Carbon/ Cocoa.

Dmitry Boyarintsev

2019-12-24 20:25

developer   ~0120055

The problem is with system font dialog sizes not matching the ones assigned by LCL

Dmitry Boyarintsev

2020-01-12 00:58

developer   ~0120347

please test and close if ok


2020-01-12 21:51

reporter   ~0120377

I wish you a very happy new year, Dmitry!

I tested it on 62536 and it seems OK.

The Cocoa WS status seems pretty good, when is planed to be officially released as stable?


2020-01-12 21:52

reporter   ~0120378


Dmitry Boyarintsev

2020-01-12 22:00

developer   ~0120381

yes, the fix is already scheduled for the next release

Issue History

Date Modified Username Field Change
2018-07-14 19:55 cobata New Issue
2018-07-14 19:55 cobata File Added:
2018-07-18 17:01 cobata Note Added: 0109562
2018-07-19 16:17 Chris Rorden Note Added: 0109571
2018-07-22 11:56 cobata Note Added: 0109629
2018-08-04 10:03 cobata Note Added: 0109873
2019-07-18 09:58 cobata Note Added: 0117299
2019-07-18 10:50 cobata Note Added: 0117300
2019-07-18 11:08 cobata Note Edited: 0117300 View Revisions
2019-07-18 12:05 cobata Note Edited: 0117300 View Revisions
2019-07-19 15:48 Dmitry Boyarintsev File Added: forms.png
2019-07-19 16:31 Dmitry Boyarintsev Note Added: 0117317
2019-07-20 04:57 cobata Note Added: 0117325
2019-07-20 05:13 cobata Note Edited: 0117325 View Revisions
2019-07-21 04:45 Dmitry Boyarintsev Note Added: 0117332
2019-07-21 04:45 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2019-07-21 04:45 Dmitry Boyarintsev Status new => feedback
2019-07-21 04:45 Dmitry Boyarintsev LazTarget => -
2019-07-21 09:48 cobata Note Added: 0117333
2019-07-21 09:48 cobata Status feedback => assigned
2019-07-21 16:12 cobata File Added:
2019-07-21 16:12 cobata File Added: 1.png
2019-07-21 16:13 cobata File Added: 2.png
2019-07-21 16:17 cobata Note Added: 0117338
2019-10-04 11:54 cobata Note Added: 0118316
2019-12-24 09:58 cobata Note Added: 0120051
2019-12-24 18:17 Dmitry Boyarintsev Note Added: 0120052
2019-12-24 19:57 CudaText man Note Added: 0120054
2019-12-24 20:25 Dmitry Boyarintsev Note Added: 0120055
2020-01-12 00:58 Dmitry Boyarintsev Status assigned => resolved
2020-01-12 00:58 Dmitry Boyarintsev Resolution open => fixed
2020-01-12 00:58 Dmitry Boyarintsev Fixed in Revision => 62528
2020-01-12 00:58 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2020-01-12 00:58 Dmitry Boyarintsev Note Added: 0120347
2020-01-12 21:51 cobata Note Added: 0120377
2020-01-12 21:52 cobata Status resolved => closed
2020-01-12 21:52 cobata Note Added: 0120378
2020-01-12 22:00 Dmitry Boyarintsev Status closed => assigned
2020-01-12 22:00 Dmitry Boyarintsev Resolution fixed => reopened
2020-01-12 22:00 Dmitry Boyarintsev Status assigned => resolved
2020-01-12 22:00 Dmitry Boyarintsev Resolution reopened => fixed
2020-01-12 22:00 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2020-01-12 22:00 Dmitry Boyarintsev Note Added: 0120381
2020-01-12 22:00 Dmitry Boyarintsev Status resolved => closed