Skip to content

[Win32] Fix underline/strikeout styles lost for fallback fonts in GC#3357

Open
HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:fix/issue-2978-fallback-font-underline-strikeout
Open

[Win32] Fix underline/strikeout styles lost for fallback fonts in GC#3357
HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:fix/issue-2978-fallback-font-underline-strikeout

Conversation

@HeikoKlare
Copy link
Copy Markdown
Contributor

@HeikoKlare HeikoKlare commented Jun 2, 2026

Summary

When GDI+ cannot find a requested font family and falls back to constructing a substitute font from the LOGFONT fields, the underline and strikeout style flags (lfUnderline, lfStrikeOut) were silently ignored. Text drawn with such a fallback font would render without those decorations even when explicitly requested.

The fix maps lfUnderlineFontStyleUnderline and lfStrikeOutFontStyleStrikeout in the fallback-font style computation inside GC.createGdipFont().

A regression test (GCWin32Tests.fallbackFontPreservesUnderlineAndStrikeout) verifies the fix by comparing pixel counts of text rendered with plain, underline, and strikeout fonts through the fallback path; the decorated variants must produce
more pixels than the plain one.

See #2978

🤖 Generated with Claude Code

In GC.createGdipFont(), when the requested font family is not found in the
GDI+ font collection, a fallback font is constructed by reading the LOGFONT
from the original GDI HFONT and building a new GDI+ Font from it. The style
flags passed to the new Font() constructor were only derived from the Bold and
Italic LOGFONT fields; lfUnderline and lfStrikeOut were silently ignored.
As a result, text drawn with a fallback font that had underline or strikeout
requested would render without those decorations.

Fix by also mapping lfUnderline → FontStyleUnderline and
lfStrikeOut → FontStyleStrikeout in the fallback-font style computation.

Regression test: GCWin32Tests.fallbackFontPreservesUnderlineAndStrikeout

The test is in GCWin32Tests because it relies on Win32-specific font internals:
FontData.data (a LOGFONT) exposes lfUnderline and lfStrikeOut as direct fields,
which have no equivalent in the GTK or Cocoa font models (those platforms apply
underline/strikeout as text-level attributes via TextLayout/TextStyle, not as
font-level attributes). PlatformSpecificExecutionExtension ensures the class is
skipped automatically on non-Win32 platforms.

See eclipse-platform#2978

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Test Results (win32)

   30 files     30 suites   4m 44s ⏱️
4 704 tests 4 629 ✅ 75 💤 0 ❌
1 234 runs  1 210 ✅ 24 💤 0 ❌

Results for commit 549187e.

@HeikoKlare HeikoKlare marked this pull request as ready for review June 2, 2026 15:25
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.

1 participant