Skip to content

Conversation

dotMorten
Copy link
Contributor

@dotMorten dotMorten commented Aug 29, 2025

Description of Change

The font alignment calculation was wrong, often causing the symbols to be offset when rendering using FontImageSource.

Issues Fixed

Fixes #30004

Below is an example of the adjustment. First column using <Label /> to render the Glyph, second is how MAUI currently renders it, and 3rd column with the fix applied. I applied a background to the two images, to make it clear that the generated image hasn't changed, only the alignment.
image

@Copilot Copilot AI review requested due to automatic review settings August 29, 2025 18:54
@dotMorten dotMorten requested a review from a team as a code owner August 29, 2025 18:54
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Aug 29, 2025
Copy link
Contributor

Hey there @@dotMorten! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes text centering issues in FontImageSource rendering on Windows that was causing glyph offsets. The fix updates the positioning calculation to properly center glyphs within the canvas.

  • Replaces incorrect DrawBounds-based positioning with proper canvas centering calculation
  • Uses LayoutBounds and DefaultFontSize for more accurate text positioning

…ceService.Windows.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@dotMorten
Copy link
Contributor Author

@clandrew @shawnhar This is the best I could come up with to fix the text centering issue, but you two might be the best ones to confirm the use of CanvasTextLayout and calculating centering. Would appreciate your input on this. I didn't really find anything else in the layout that gave the values needed to correctly center the symbol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community ✨ Community Contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"FontImageSource not center-aligned inside Image control in .NET MAUI"
1 participant