diff options
author | 2017-05-09 18:23:23 +0100 | |
---|---|---|
committer | 2017-05-09 18:23:23 +0100 | |
commit | fccc122027c2bc5c590e26dd1d93dac7754dcb4c (patch) | |
tree | da31bedc2c0d016ab1f9df22e710445e95a6b0ef | |
parent | 7b9cebcc4bbdd893d9e01848cd50733368e48775 (diff) |
Modify font metrics computation to match Android
On Android, font metrics top and bottom seem 15% larger than ascent and
descent. Paint_Delegate is modified to reflect this fact.
Test: layoutlib tests updated
Bug: 38117115
Change-Id: I4e9995ccbc991fbb857c8e3af45a908ad55db99e
13 files changed, 2 insertions, 2 deletions
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java index 1bb56e3be415..60e5cd99854a 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java @@ -596,10 +596,10 @@ public class Paint_Delegate { java.awt.FontMetrics javaMetrics = delegate.mFonts.get(0).mMetrics; if (fmi != null) { // Android expects negative ascent so we invert the value from Java. - fmi.top = - javaMetrics.getMaxAscent(); + fmi.top = (int)(- javaMetrics.getMaxAscent() * 1.15); fmi.ascent = - javaMetrics.getAscent(); fmi.descent = javaMetrics.getDescent(); - fmi.bottom = javaMetrics.getMaxDescent(); + fmi.bottom = (int)(javaMetrics.getMaxDescent() * 1.15); fmi.leading = javaMetrics.getLeading(); } diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/activity.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/activity.png Binary files differindex affc31ee48e2..773c5bee5df4 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/activity.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/activity.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/allwidgets.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/allwidgets.png Binary files differindex bd7835334a49..4391f47bd35f 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/allwidgets.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/allwidgets.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/allwidgets_tab.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/allwidgets_tab.png Binary files differindex 88fa9ddbd349..bb69ca885d69 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/allwidgets_tab.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/allwidgets_tab.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/array_check.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/array_check.png Binary files differindex ee72a6fe27e8..0835d5139f19 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/array_check.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/array_check.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/font_test.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/font_test.png Binary files differindex 736b2877355f..7e0c29afd41d 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/font_test.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/font_test.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners.png Binary files differindex a8567b3ef023..ffba2b504560 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners_translucent.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners_translucent.png Binary files differindex 5ae95ea34ad4..b73b359f1270 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners_translucent.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners_translucent.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners_translucent_land.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners_translucent_land.png Binary files differindex b2b6a970c29f..09fd2790f213 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners_translucent_land.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/four_corners_translucent_land.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/shadows_test.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/shadows_test.png Binary files differindex 4951629a50b6..f1eecf0e2ae8 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/shadows_test.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/shadows_test.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity-old-theme.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity-old-theme.png Binary files differindex e0abcf412844..b6f373760f5d 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity-old-theme.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity-old-theme.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity.png Binary files differindex 3d0fbd606188..fd6e6b687906 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity_noactionbar.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity_noactionbar.png Binary files differindex 86b00415c3ec..ef207272b464 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity_noactionbar.png +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/simple_activity_noactionbar.png |