fix viewport#19134
Merged
Merged
Conversation
cocos-robot
pushed a commit
to cocos-robot/engine
that referenced
this pull request
Jan 23, 2026
Code Size Check Report
Interface Check ReportThis pull request does not change any public interfaces ! |
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.
Re: #
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request:
Greptile Overview
Greptile Summary
This PR adds
Math.ceil()to round upcanvasSize.widthandcanvasSize.heightat the end of_calculateLabelFont()method. This ensures that canvas dimensions are always integers rather than fractional values.Key Changes:
text-processing.ts:257-258to ceil canvas dimensions after all overflow mode calculations completeImpact:
HTML Canvas elements require integer dimensions for proper rendering. Fractional pixel values from font calculations can cause viewport and rendering artifacts. This fix prevents such issues by ensuring dimensions are whole numbers before the canvas is used in
_updateLabelDimensions().Confidence Score: 5/5
Math.ceil()ensures dimensions are always valid integers without truncating content. The fix is applied after all size calculations, preserving existing logic while preventing fractional pixel issues. No breaking changes or side effects expected.Important Files Changed
Math.ceil()to ensure canvas dimensions are integers, preventing potential rendering issues from fractional pixel valuesSequence Diagram
sequenceDiagram participant Client as Label Component participant TP as TextProcessing participant Canvas as HTML Canvas Client->>TP: processingString() TP->>TP: _calculateLabelFont() Note over TP: Calculate canvasSize based on<br/>overflow mode (NONE, SHRINK, etc.) TP->>TP: Math.ceil(canvasSize.width) TP->>TP: Math.ceil(canvasSize.height) Note over TP: NEW: Ensure integer dimensions<br/>to fix viewport issues Client->>TP: generateRenderInfo() TP->>TP: _updateLabelDimensions() TP->>Canvas: canvas.width = canvasSize.width TP->>Canvas: canvas.height = canvasSize.height Note over Canvas: Canvas dimensions must be integers<br/>Fractional values can cause rendering issues