Skip to content

Style wide characters at charWidth*2 in DOM#440

Merged
Tyriar merged 6 commits intoxtermjs:masterfrom
Tyriar:439_wide_char_class
Jan 9, 2017
Merged

Style wide characters at charWidth*2 in DOM#440
Tyriar merged 6 commits intoxtermjs:masterfrom
Tyriar:439_wide_char_class

Conversation

@Tyriar
Copy link
Copy Markdown
Member

@Tyriar Tyriar commented Dec 31, 2016

Fixes #439


Adds a new util class that encapsulates measuring of characters and restricts it to only be performed during at start up and after a resize (which I think should also be called when char size is changed).

Before:

image

After:

image

It appears to work when resizing using crazy sizes too:

image

@Tyriar Tyriar requested a review from parisk December 31, 2016 23:22
@Tyriar Tyriar changed the title Wrap wide chars in a span/class Style wide characters at charWidth*2 in DOM Dec 31, 2016
@Tyriar Tyriar self-assigned this Jan 1, 2017
@jerch
Copy link
Copy Markdown
Member

jerch commented Jan 1, 2017

Note that some half width chars are rendered to wide with some fonts. Also fonts may differ in the wcwidth calculation for some glyphs. Thats the reason why I ended up with a precalculated dictionary of glyph widths for a critial subset of characters.

@Tyriar
Copy link
Copy Markdown
Member Author

Tyriar commented Jan 4, 2017

Viewport's usage of CharMeasure in this PR should actually make a significant performance impact as long running commands seem to spend ~20% time in getBoundingClientRect 😮

@Tyriar Tyriar added this to the 2.3.0 milestone Jan 4, 2017
Copy link
Copy Markdown
Contributor

@parisk parisk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, works great.

LGTM 👍 .

this.charMeasureElement.classList.add('xterm-char-measure-element');
this.charMeasureElement.innerHTML = 'W';
this.helperContainer.appendChild(this.charMeasureElement);
this.charSizeStyleElement = document.createElement('style');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea 👍 .

@Tyriar
Copy link
Copy Markdown
Member Author

Tyriar commented Jan 9, 2017

Tested after merge 👍

@Tyriar Tyriar merged commit e9da2a6 into xtermjs:master Jan 9, 2017
@Tyriar Tyriar deleted the 439_wide_char_class branch January 9, 2017 01:00
@Tyriar Tyriar modified the milestone: 2.3.0 Feb 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants