This is an automated email from the ASF dual-hosted git repository.

skygo 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 d2e893c  [NETBEANS-346] Tabs, characters, and the right Margin don't 
line up
     new 1a8548d  Merge pull request #2076 from eirikbakke/NETBEANS-346
d2e893c is described below

commit d2e893c3b30611beb823e7d7c758b90acd41f6be
Author: Eirik Bakke <[email protected]>
AuthorDate: Mon Apr 13 17:36:46 2020 -0400

    [NETBEANS-346] Tabs, characters, and the right Margin don't line up
---
 .../org/netbeans/modules/editor/lib2/view/FontInfo.java    | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git 
a/ide/editor.lib2/src/org/netbeans/modules/editor/lib2/view/FontInfo.java 
b/ide/editor.lib2/src/org/netbeans/modules/editor/lib2/view/FontInfo.java
index f188a2f..e9185d7 100644
--- a/ide/editor.lib2/src/org/netbeans/modules/editor/lib2/view/FontInfo.java
+++ b/ide/editor.lib2/src/org/netbeans/modules/editor/lib2/view/FontInfo.java
@@ -91,8 +91,18 @@ final class FontInfo {
         TextLayout rowHeightTextLayout = new TextLayout("A_|B", renderFont, 
frc);
         // Round the ascent to eliminate long mantissa without any visible 
effect on rendering.
         updateRowHeight(rowHeightTextLayout, rowHeightCorrection);
-        // Ceil fractions to whole numbers since this measure may be used for 
background rendering
-        charWidth = (float) Math.ceil(defaultCharTextLayout.getAdvance());
+        /* We originally did Math.ceil() when setting charWidth, but this was 
the cause of NETBEANS-346,
+        where the end-of-line marker (SimpleValueNames.TEXT_LIMIT_WIDTH) would 
appear in the wrong
+        position due to rounding errors, and similar misalignments in tabs vs. 
spaces, on certain editor
+        zoom levels. This was observed on Java 9 or above on both Windows and 
MacOS. Java 9 saw many
+        changes in font metrics implementations, including a new font shaping 
engine (HarfBuzz) and
+        fractional HiDPI support. Avoiding Math.ceil fixes the problem. The 
original Math.ceil was
+        introduced by Miloslav Metelka on 2011-08-18, with a comment "Ceil 
fractions to whole numbers
+        since this measure may be used for background rendering" in the commit 
titled "Improve
+        AnnotationView performance" for the similarly titled BugZilla bug 
#201102. So the Math.ceil was
+        intended to be an optimization rather than fixing a correctness bug, 
and it seems safe to remove
+        it. */
+        charWidth = defaultCharTextLayout.getAdvance();
         LineMetrics lineMetrics = renderFont.getLineMetrics(defaultCharText, 
frc);
         underlineAndStrike[0] = lineMetrics.getUnderlineOffset() * 
rowHeightCorrection;
         underlineAndStrike[1] = lineMetrics.getUnderlineThickness();


---------------------------------------------------------------------
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

Reply via email to