Skip to content

Commit a8ce35e

Browse files
committed
clean up
1 parent a1aafe5 commit a8ce35e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/engine/Source/Core/writeTextToCanvas.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import Frozen from "./Frozen.js";
33
import defined from "./defined.js";
44
import DeveloperError from "./DeveloperError.js";
55

6+
/**
7+
* Computes dimensions for text, based on current canvas state.
8+
*
9+
* Rounds metrics, excluding width, to whole pixels. This is purely to minimize
10+
* rendering differences with migration to in-browser measureText(), and may be
11+
* revised in the future. See: github.com/CesiumGS/cesium/pull/13081
12+
*/
613
function measureText(context2D, textString) {
714
const metrics = context2D.measureText(textString);
815
const isSpace = !/\S/.test(textString);
@@ -17,10 +24,6 @@ function measureText(context2D, textString) {
1724
};
1825
}
1926

20-
// Round metrics, excluding width, to whole pixels. This is purely to minimize
21-
// rendering differences with migration to in-browser measureText(), and may be
22-
// revised in the future. See: github.com/CesiumGS/cesium/pull/13081
23-
2427
// Baseline alignment requires `height = ascent + descent`. Rounding (if any)
2528
// must be done before summing, or glyph pairs like "ij" may be misaligned.
2629
const ascent = Math.round(metrics.actualBoundingBoxAscent);

0 commit comments

Comments
 (0)