Character size computation is affected by CSS transforms #2488
Labels
area/addon/canvas
area/addon/webgl
area/renderer-dom
good first issue
help wanted
type/bug
Something is misbehaving
Milestone
When a Terminal is opened in an element subject to CSS transformations such as
scale
orrotate
, the computation of the character size is affected by that transformation, which is wrong because the rendering should be transform-agnostic.As a result, this makes the integration of Xterm.js into reveal.js slides render incorrectly when the slides are scaled down to fit the browser viewport.
Changing the measurement method in
CharSizeService
to usegetComputedStyle
instead ofgetBoundingClientRect
makes the computation independent of CSS transforms.Details
Steps to reproduce
style="transform: rotate(90deg);"
to the<body>
tag indemo/index.html
Workaround
With the
rotate(90deg)
CSS transform Xterm.js renders character cells with the width and height swapped around:The cause is in the measurement methods in
CharSizeService
: it usesgetBoundingClientRect
, which returns the size of the bounding box after CSS transforms.xterm.js/src/browser/services/CharSizeService.ts
Lines 71 to 86 in 6311076
My understanding is that the rendering of the terminal should not be affected by said transforms. And indeed, replacing the
geometry
definition in the code above with (POC)yields a correct rendering:
Note that my proof-of-concept fix above may be insufficient in cases where the element or its parent are
display: none
.The text was updated successfully, but these errors were encountered: