@@ -1225,7 +1225,8 @@ LRESULT wmMeasureChild (long wParam, long lParam) {
12251225 * position. I have tested on Win7, Win8.1, Win10 and found
12261226 * that value of 5 works well in matching text to mnemonic.
12271227 */
1228- struct .itemWidth = DPIUtil .scaleUp (LEFT_TEXT_MARGIN + point .x - WINDOWS_OVERHEAD + (this .image != null ? this .image .getBounds ().width + IMAGE_TEXT_GAP : 0 ), menuZoom );
1228+ int horizontalSpaceImage = this .image != null ? this .image .getBounds ().width + IMAGE_TEXT_GAP : 0 ;
1229+ struct .itemWidth = DPIUtil .scaleUp (LEFT_TEXT_MARGIN + point .x - WINDOWS_OVERHEAD + horizontalSpaceImage , menuZoom );
12291230 OS .MoveMemory (lParam , struct , MEASUREITEMSTRUCT .sizeof );
12301231 return null ;
12311232 }
@@ -1275,9 +1276,7 @@ private Point calculateRenderedTextSize() {
12751276 Point points = gc .textExtent (textWithoutMnemonicCharacter );
12761277 gc .dispose ();
12771278
1278- if (getDisplay ().isRescalingAtRuntime ()) {
1279- return points ;
1280- } else {
1279+ if (!getDisplay ().isRescalingAtRuntime ()) {
12811280 int primaryMonitorZoom = this .getDisplay ().getDeviceZoom ();
12821281 int adjustedPrimaryMonitorZoom = DPIUtil .getZoomForAutoscaleProperty (primaryMonitorZoom );
12831282 if (primaryMonitorZoom != adjustedPrimaryMonitorZoom ) {
@@ -1293,8 +1292,8 @@ private Point calculateRenderedTextSize() {
12931292 // This is the only place, where the GC needs to use the native zoom to do that, therefore it is fixed only here
12941293 points = DPIUtil .scaleDown (DPIUtil .scaleUp (points , adjustedPrimaryMonitorZoom ), primaryMonitorZoom );
12951294 }
1296- return points ;
12971295 }
1296+ return points ;
12981297}
12991298
13001299private static final class MenuItemToolTip extends ToolTip {
0 commit comments