This is an automated email from the ASF dual-hosted git repository.
neilcsmith pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 8e4287fd29 Update rounding in terminal font metrics to address GH5980.
new ca2d1fd386 Merge pull request #6163 from
neilcsmith-net/terminal-metrics
8e4287fd29 is described below
commit 8e4287fd2913ee8eacb0368e6aacacc74075df5a
Author: Neil C Smith <[email protected]>
AuthorDate: Fri Jul 7 11:01:31 2023 +0100
Update rounding in terminal font metrics to address GH5980.
---
.../src/org/netbeans/lib/terminalemulator/MyFontMetrics.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git
a/ide/lib.terminalemulator/src/org/netbeans/lib/terminalemulator/MyFontMetrics.java
b/ide/lib.terminalemulator/src/org/netbeans/lib/terminalemulator/MyFontMetrics.java
index 2eececf595..39a66a9c31 100644
---
a/ide/lib.terminalemulator/src/org/netbeans/lib/terminalemulator/MyFontMetrics.java
+++
b/ide/lib.terminalemulator/src/org/netbeans/lib/terminalemulator/MyFontMetrics.java
@@ -123,7 +123,7 @@ class MyFontMetrics {
public MyFontMetrics(Component component, Font font) {
fm = component.getFontMetrics(font);
- width = fm.charWidth('a');
+ width = fm.charWidth('m');
height = fm.getHeight();
ascent = fm.getAscent();
leading = fm.getLeading();
@@ -178,19 +178,21 @@ class MyFontMetrics {
cell_width = 1;
} else {
- // round up pixel width to multiple of cell size
+ // round pixel width to multiple of cell size
// then distill into a width in terms of cells.
int mod = pixel_width % width;
int rounded_width = pixel_width;
- if (mod != 0) {
+ if (mod > (width / 2)) {
rounded_width = pixel_width + (width - mod);
+ } else {
+ rounded_width = pixel_width - mod;
}
cell_width = rounded_width / width;
if (cell_width == 0) {
cell_width = 1;
+ } else if (cell_width > 1) {
+ cwidth_cache.setMultiCell(true);
}
-
- cwidth_cache.setMultiCell(true);
}
cwidth_cache.cache[c] = (byte) cell_width;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists