[Win32] Fix underline/strikeout styles lost for fallback fonts in GC#3357
Open
HeikoKlare wants to merge 1 commit into
Open
Conversation
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>
Contributor
Test Results (win32) 30 files 30 suites 4m 44s ⏱️ Results for commit 549187e. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When GDI+ cannot find a requested font family and falls back to constructing a substitute font from the
LOGFONTfields, 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
lfUnderline→FontStyleUnderlineandlfStrikeOut→FontStyleStrikeoutin the fallback-font style computation insideGC.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 producemore pixels than the plain one.
See #2978
🤖 Generated with Claude Code