Conversation
This bug goes back 10 years to the original implementation. Fixes #1909
chearon
approved these changes
Sep 6, 2022
phipla
pushed a commit
to e-cervo/node-canvas
that referenced
this pull request
Oct 26, 2022
* master: (33 commits) v2.10.1-ecervo.1 fix a crash in getImageDate if the rectangle is outside the canvas remove deprecated constructor overload add review comments remove save() limit, improve save/restore perf, fix some props Update CHANGELOG.md reimplement accessors on prototype Update CHANGELOG.md Update CHANGELOG.md Update CHANGELOG.md fix Assertion failed: (object->InternalFieldCount() > 0), function Unwrap, file nan_object_wrap.h, line 32. bump version add node 16 & 18 to build v2.10.1 add line in CHANGELOG Parse rgba(r,g,b,0) correctly Fix actualBoundingBoxLeft/Right with center/right alignment (Automattic#2109) v2.10.0 fix: add user agent to remote images request Add roundRect() support ... # Conflicts: # .github/workflows/prebuild.yaml
Contributor
|
@zbjornson , @chearon , it seems like after this change actualBoundingBoxLeft was broken for textAlign = start. Because it returns value with opposite sign comparing to browser |
Collaborator
Author
|
@stepancar can you provide a repro in a new issue please? It seems to be correct: tests['measureText()'] = function (ctx) {
function drawWithBBox (text, x, y) {
ctx.fillText(text, x, y)
ctx.strokeStyle = 'red'
ctx.beginPath(); ctx.moveTo(0, y + 0.5); ctx.lineTo(200, y + 0.5); ctx.stroke()
const metrics = ctx.measureText(text)
ctx.strokeStyle = 'blue'
ctx.strokeRect(
// positive numbers for actualBoundingBoxLeft indicate a distance going left
x + metrics.actualBoundingBoxLeft + 0.5,
y - metrics.actualBoundingBoxAscent + 0.5,
metrics.width,
metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent
)
}
ctx.font = '20px Arial'
ctx.textBaseline = 'alphabetic'
ctx.textAlign = 'start'
drawWithBBox('start', 10, 150)
} |
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.

This bug goes back 10 years to the original implementation.
Fixes #1909