View Issue Details

IDProjectCategoryView StatusLast Update
0034931LazarusLCLpublic2019-01-23 20:53
ReporterPavol SAssigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Platformwin32OSWindowsOS Version10
Product Version2.0RC3Product Build 
Target VersionFixed in Version 
Summary0034931: HighDPI: TCheckBox wrong font scaling
Description1. Checkbox caption font text size is not properly calculated with scaled windows (150%).

2. When font style is set BEFORE parent(runtime created) there is NO scaling. Still width of control is calculated wrong. Btw: this behavior is for all controls.
TagsHighDPI
Fixed in Revision
LazTarget
WidgetsetWin32/Win64
Attached Files

Activities

Pavol S

2019-01-22 20:39

reporter  

runtime.png (9,284 bytes)
runtime.png (9,284 bytes)

Pavol S

2019-01-22 20:39

reporter  

designer.png (3,842 bytes)
designer.png (3,842 bytes)

Pavol S

2019-01-22 20:40

reporter  

font_bug.zip (66,381 bytes)

Pavol S

2019-01-23 06:23

reporter  

lbl.png (11,458 bytes)
lbl.png (11,458 bytes)

Pavol S

2019-01-23 06:27

reporter   ~0113589

Same problem is with TLabel (or any other control with Font)

  lb := TLabel.Create(Self);
  lb.Caption := 'Runtime created and font changed BEFORE set parent';
  lb.Top := 120;
  lb.Left := 16;
  lb.Font.Style := [fsBold]; // this disable font scaling
  lb.Parent := Self;

Juha Manninen

2019-01-23 07:55

developer   ~0113590

A workaround is to set Parent first. Is there a reason not to do so?

wp

2019-01-23 09:45

developer   ~0113592

I tested in a VM with Win7 at 150%, and the issue does not show up, neither 1) nor 2). Another surprise by Win10?

Pavol S

2019-01-23 13:40

reporter   ~0113595

@Juha Manninen there can be many situations where Parent is not set. For Example in custom components:

TCustomPanel = class(TPanel)
  ...
  constructor Create;
  begin
    for i := 0 to 10 do
    begin
      lbl := TLabel.Create;
      lbl.Parent := Self;
     // lbl.Font.Style := [fsBold]; // this destroy font scaling. Self has no parent yet
    end;
  end;
  procedure SetParent(NewParent);
  begin
    Inherited(NewParent);
    for each TLabel.Font.Style := [fsBold]; // only here we can set font style
  end;
end;

@wp this is related only for V2 (please change it in test project, my fault). Maybe win7 don't support it.

wp

2019-01-23 16:49

developer   ~0113598

Last edited: 2019-01-23 16:50

View 2 revisions

> this is related only for V2 (please change it in test project, my fault). Maybe win7 don't support it.

What do you mean? What is V2? Laz V2? I use trunk.

Pavol S

2019-01-23 17:40

reporter   ~0113599

@wp: It's DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
https://docs.microsoft.com/en-us/windows/desktop/hidpi/dpi-awareness-context and in Lazarus project you must switch to: Vista-8:on, 8.1/10+: per monitor/V2(True/PM) (Under Project/Project options/Application/ DPI awareness option)

Issue History

Date Modified Username Field Change
2019-01-22 20:39 Pavol S New Issue
2019-01-22 20:39 Pavol S File Added: runtime.png
2019-01-22 20:39 Pavol S File Added: designer.png
2019-01-22 20:40 Pavol S File Added: font_bug.zip
2019-01-23 06:23 Pavol S Tag Attached: HighDPI
2019-01-23 06:23 Pavol S File Added: lbl.png
2019-01-23 06:27 Pavol S Note Added: 0113589
2019-01-23 07:55 Juha Manninen Note Added: 0113590
2019-01-23 09:45 wp Note Added: 0113592
2019-01-23 13:40 Pavol S Note Added: 0113595
2019-01-23 16:49 wp Note Added: 0113598
2019-01-23 16:50 wp Note Edited: 0113598 View Revisions
2019-01-23 17:40 Pavol S Note Added: 0113599