Skip to content

Commit 2b5e1f3

Browse files
committed
changelog
1 parent c2602f0 commit 2b5e1f3

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
1313
* Fix BMP issues. (#1497)
1414
* Update typings to support jpg and addPage on NodeCanvasRenderingContext2D (#1509)
1515
* Fix assertion failure when using Visual Studio Code debugger to inspect Image prototype (#1534)
16+
* Tweak text baseline positioning to be as close as possible to browser canvas (#1562)
1617

1718
2.6.1
1819
==================

src/CanvasRenderingContext2d.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -2405,13 +2405,11 @@ inline double getBaselineAdjustment(PangoLayout* layout, short baseline) {
24052405
PangoLayout* measureLayout = pango_layout_copy(layout);
24062406
pango_layout_set_text(measureLayout, "gjĮ測試ÅÊ", -1);
24072407
pango_layout_line_get_extents(pango_layout_get_line(measureLayout, 0), NULL, &logical_rect);
2408-
2409-
// extract the scale value from the current transform so that we know how many pixels we
2410-
// need for our extra canvas in the drawImage operation.
2411-
24122408
double scale = 1.0 / PANGO_SCALE;
24132409
double ascent = scale * pango_layout_get_baseline(measureLayout);
24142410
double descent = scale * logical_rect.height - ascent;
2411+
// 0.072 is a constant that has been chosen comparing the canvas output
2412+
// if some code change, this constant can be changed too to keep results aligned
24152413
double correction_factor = scale * logical_rect.height * 0.072;
24162414

24172415
switch (baseline) {

0 commit comments

Comments
 (0)