Improve label rendering with system font - #3107
Conversation
- Added DWriteTextRenderer implementation for Windows platform - Updated Device::getTextureDataForText to use DirectWrite instead of BitmapDC - Adjusted Label and Texture2D to enable stroke support on Windows - Removed legacy BitmapDC and SafeRelease helpers - Updated cpp-tests to validate DirectWrite text rendering with '&' character This patch modernizes Windows text rendering by switching from GDI to DirectWrite, providing consistent alignment, stroke, and shadow support across platforms.
There was a problem hiding this comment.
Code Review
This pull request introduces a new DirectWrite and Direct2D based text renderer for the Win32 platform, replacing the legacy GDI-based BitmapDC implementation. This change enables support for text stroke and shadow effects on Windows. The feedback provided addresses a potential memory leak in geometry combination, suggests optimizing the font-shrinking algorithm via binary search, and identifies several outdated log and assertion messages that need to be updated to reflect the new platform support.
|
/clang-format |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request replaces the legacy GDI-based text rendering on Windows with a modern DirectWrite and Direct2D implementation via the new DWriteTextRenderer class. This change enables support for text stroke on Win32 and improves rendering quality. However, several critical issues were identified in the implementation: the color conversion logic incorrectly swaps color channels, the shadow effect uses the wrong color, and there is a type mismatch in the pixel data copying logic. Furthermore, the static renderer instance is not thread-safe, and the COM initialization strategy may lead to crashes when text is rendered on worker threads. Improvements are also needed for the inefficient geometry combination logic and the removal of compiler-specific pragmas in favor of CMake configuration.
|
/clang-format |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements text stroke support for WASM and replaces the legacy GDI-based text rendering on Win32 with a modern DirectWrite/Direct2D implementation, enabling stroke and shadow effects on Windows. A bug was identified in the Win32 renderer where the shadow color is incorrectly derived from the font fill color instead of the intended shadow color.
|
/clang-format |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request replaces the legacy GDI-based text rendering on Windows with a new DirectWrite and Direct2D implementation via the DWriteTextRenderer class. It also removes the FontShadow feature from the engine across all platforms and introduces stroke support for the WebAssembly platform. The review feedback highlights a functional issue where the text brush color is not updated when a render target is reused, as well as a copy-paste error in the Lua bindings where a stroke property is incorrectly mapped to a shadow key. Other improvements include removing unused variables, addressing potential integer overflows during buffer resizing, and correcting outdated documentation regarding removed features.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request replaces the legacy GDI-based text rendering on Windows with a new DWriteTextRenderer utilizing DirectWrite and Direct2D, enabling features like text stroke and improved overflow handling. Concurrently, the FontShadow implementation has been removed across all platforms, and the WASM platform has been updated to support text strokes. Review feedback highlights a layering violation in the platform code, a performance optimization for the font-shrinking logic, and a minor documentation duplication.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors text rendering across all supported platforms by removing the FontShadow property from FontDefinition and its associated implementations. A major highlight is the introduction of DWriteTextRenderer for Windows platforms, which utilizes DirectWrite and Direct2D to replace the legacy GDI-based text rendering. Additionally, the PR updates Android, iOS, macOS, and WASM implementations to support text strokes while removing shadow support, and it consolidates Windows-specific utilities like ComPtr.h into a shared directory. I have no feedback to provide.
This patch modernizes Windows text rendering by switching from GDI to DirectWrite, providing consistent alignment, stroke support across platforms.
Describe your changes
Issue ticket number and link
Checklist before requesting a review
For each PR
Add Copyright if it missed:
-
"Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."I have performed a self-review of my code.
Optional:
For core/new feature PR
Axmol 3.x ------------------------------------------------------------
For each 3.x PR