Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/melonjs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Fixed
- `NineSliceSprite` blinks with `flicker()`, as a `Sprite` does; it ignored it
- Text: a stroked multi-line label with `textBaseline: "hanging"` keeps the top of its outline on macOS, where Helvetica's hanging metrics made the ink padding exactly as tall as the ink, shearing its first row off the canvas ([#1870](https://github.com/melonjs/melonJS/issues/1870))
- glTF: a model compressed with Draco or meshopt, which the loader cannot decode, says so in the console, naming the extension, instead of failing on an accessor error that did not mention it

## [20.16.0] (melonJS 2) - _2026-11-17_
Expand Down
13 changes: 9 additions & 4 deletions packages/melonjs/src/renderable/text/textmetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ import setContextStyle, { strokeReach } from "./textstyle.js";
* @import Renderable from "../renderable.js";
*/
/**
* One pixel of slack on top of the reported ink extent.
* Two pixels of slack on top of the reported ink extent.
*
* `actualBoundingBox*` describes the OUTLINE, and the rasterizer paints past
* it: antialiasing and pixel snapping both put ink outside what the metrics
* promise. Measured against two engines, the painted ink reached a full pixel
* beyond the reported bound — enough to shear the top row off a stroke. Over-
* padding costs nothing but invisible canvas headroom.
* beyond the reported bound — enough to shear the top row off a stroke. One
* more is needed when the padding rounds to the demand exactly: on macOS,
* Helvetica under the "hanging" baseline reports an ascent of -0.05px at
* 20px, so `ceil(ascent + stroke)` leaves 0.05px of headroom and the painted
* ink — ascent plus the stroke's reach plus its own spill — starts on the
* canvas' first row. A second pixel absorbs that worst case. Over-padding
* costs nothing but invisible canvas headroom.
* @ignore
* @internal
*/
const INK_SLACK = 1;
const INK_SLACK = 2;

/**
* The share of the em to pad by when the ink extent cannot be measured at all.
Expand Down
Loading