Skip to content

Correct font size calculation for Terminal in multi-monitor setups#2472

Merged
HeikoKlare merged 2 commits intoeclipse-platform:masterfrom
vi-eclipse:issue-2295-multi-monitor
Mar 5, 2026
Merged

Correct font size calculation for Terminal in multi-monitor setups#2472
HeikoKlare merged 2 commits intoeclipse-platform:masterfrom
vi-eclipse:issue-2295-multi-monitor

Conversation

@HeikoKlare
Copy link
Contributor

The StyleMap of the Terminal implementation uses a GC to calculate the extents of strings to be rendered. This GC is created on the current Display instance, which does not incorporate the zoom of the current usage context (i.e., the monitor on which the Terminal is displayed). But the monitor zoom has an effect on the effective font size, as font sizes in pixels are always integers such that the logical SWT point value can be rounded differently depending on the zoom. An effect of this are cut-off texts on secondary monitors on Windows, because without taking the zoom of the usage context into account the terminal font is erroneously not identified as a monospace font.

This change adapts the implementation of StyleMap and its callers to create a GC for text extent calculations for the actual usage context. It makes the Terminal font being properly identified as a monospace font, such that individual characters are rendered and texts are not cut off.

Contributes to #2295

Additional information

This change further improves and is thus only benefical in combination with:

To test this change, you should have two monitors on a Windows system with different zooms. Open a terminal on the secondary monitor. For example, the following screenshots are taken on the secondary monitor of a setup with 100% primary monitor zoom and 125% secondary monitor zoom.

With current master state:
image

With #2463:
image

With #2463 and this:
image

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

Test Results

 1 980 files  ±0   1 980 suites  ±0   1h 34m 6s ⏱️ - 1m 0s
 4 750 tests ±0   4 726 ✅ ±0   24 💤 ±0  0 ❌ ±0 
14 250 runs  ±0  14 068 ✅ ±0  182 💤 ±0  0 ❌ ±0 

Results for commit f9644cc. ± Comparison against base commit ce5c9cc.

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare force-pushed the issue-2295-multi-monitor branch 2 times, most recently from c8e8cba to 668821a Compare February 25, 2026 10:20
@HeikoKlare HeikoKlare marked this pull request as ready for review February 25, 2026 12:40
@HeikoKlare HeikoKlare force-pushed the issue-2295-multi-monitor branch from 668821a to 78a0d0c Compare March 2, 2026 12:50
@eclipse-platform-bot
Copy link
Contributor

eclipse-platform-bot commented Mar 2, 2026

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

terminal/tests/org.eclipse.terminal.test/META-INF/MANIFEST.MF

Warning

🚧 This PR cannot be modified by maintainers because edits are disabled or it is created from an organization repository. To obtain the required changes apply the git patch manually as an additional commit.

Git patch
From 41a90d4a30a9f4dadcb8016850d1773dc4ec1600 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Tue, 3 Mar 2026 19:40:55 +0000
Subject: [PATCH] Version bump(s) for 4.40 stream


diff --git a/terminal/tests/org.eclipse.terminal.test/META-INF/MANIFEST.MF b/terminal/tests/org.eclipse.terminal.test/META-INF/MANIFEST.MF
index 0fbd569bef..f741529424 100644
--- a/terminal/tests/org.eclipse.terminal.test/META-INF/MANIFEST.MF
+++ b/terminal/tests/org.eclipse.terminal.test/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.terminal.test;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.1.100.qualifier
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.33.0,4)",
-- 
2.53.0

Further information are available in Common Build Issues - Missing version increments.

@HeikoKlare HeikoKlare force-pushed the issue-2295-multi-monitor branch 3 times, most recently from 1785a90 to e152379 Compare March 4, 2026 08:35
The StyleMap of the Terminal implementation uses a GC to calculate the
extents of strings to be rendered. This GC is created on the current
Display instance, which does not incorporate the zoom of the current
usage context (i.e., the monitor on which the Terminal is displayed).
But the monitor zoom has an effect on the effective font size, as font
sizes in pixels are always integers such that the logical SWT point
value can be rounded differently depending on the zoom. An effect of
this are cut-off texts on secondary monitors on Windows, because without
taking the zoom of the usage context into account the terminal font is
erroneously not identified as a monospace font.

This change adapts the implementation of StyleMap and its callers to
create a GC for text extent calculations for the actual usage context.
It makes the Terminal font being properly identified as a monospace
font, such that individual characters are rendered and texts are not cut
off.

Contributes to
eclipse-platform#2295

# Conflicts:
#	terminal/bundles/org.eclipse.terminal.control/src/org/eclipse/terminal/internal/textcanvas/StyleMap.java
@HeikoKlare HeikoKlare force-pushed the issue-2295-multi-monitor branch from e152379 to f9644cc Compare March 4, 2026 20:07
@HeikoKlare HeikoKlare merged commit bf3898b into eclipse-platform:master Mar 5, 2026
18 checks passed
@HeikoKlare HeikoKlare deleted the issue-2295-multi-monitor branch March 5, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants