Commit 785dba0
committed
[Win32] Ensure GC.textExtent/stringExtent returns large enough results
The GC.textExtent()/stringExtent() operations return values in logical
SWT points. On Windows, this involves a conversion from the actual pixel
values according to the current zoom factor. This conversion includes a
rounding to integer values which can lead to a value that is slightly
smaller than the actual pixel value. The expectation of consumers is,
however, that the result effectively represents the size of a bounding
box, i.e., that the whole string fully fits into a rectangle of the
returned size.
To ensure that the results of GC.textExtent()/stringExtent() are always
large enough so that the text fits into an accordingly sized rectangle
on every zoom, this change adapts the performed rounding operations to
always round up the values. This makes the behavior consistent to
rounding behavior of the Control.computeSize() methods with a similar
semantics.
Contributes to
eclipse-platform/eclipse.platform#22951 parent 3e1cc4f commit 785dba0
2 files changed
Lines changed: 8 additions & 3 deletions
File tree
- bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt
- graphics
- internal
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5877 | 5877 | | |
5878 | 5878 | | |
5879 | 5879 | | |
5880 | | - | |
| 5880 | + | |
5881 | 5881 | | |
5882 | 5882 | | |
5883 | 5883 | | |
| |||
5922 | 5922 | | |
5923 | 5923 | | |
5924 | 5924 | | |
5925 | | - | |
| 5925 | + | |
5926 | 5926 | | |
5927 | 5927 | | |
5928 | 5928 | | |
| |||
5957 | 5957 | | |
5958 | 5958 | | |
5959 | 5959 | | |
5960 | | - | |
| 5960 | + | |
5961 | 5961 | | |
5962 | 5962 | | |
5963 | 5963 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
140 | 145 | | |
141 | 146 | | |
142 | 147 | | |
| |||
0 commit comments