Manually draw pixel-perfect glyphs for Box Drawing and Block Elements characters
See original GitHub issueDetails
- Browser and browser version: Chrome 76.0.3809.132 (64 bit), FireFox 69.0 (64 bit)
- OS version: Windows 7 Pro 64 bit
- xterm.js version: ^3.14.5
Steps to reproduce
index.html:
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="node_modules/xterm/dist/xterm.css" />
<script src="node_modules/xterm/dist/xterm.js"></script>
</head>
<body>
<div id="terminal"></div>
<script>
var options = {
rows: 30,
cols: 80,
fontFamily: '"Courier New", "DejaVu Sans Mono", "Everson Mono", FreeMono, "Andale Mono", monospace',
fontSize: 12,
convertEol: true
};
var term = new Terminal(options);
term.open(document.getElementById('terminal'));
term.write(' βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\n');
term.write(' β β\n');
term.write(' β βββββββββββββββββ¦βββββββββ€βββββββββ β\n');
term.write(' β β β β β β\n');
term.write(' β β β β β β\n');
</script>
</body>
</html>
There are several related issues but it does not help:
https://github.com/xtermjs/xterm.js/issues/475 https://github.com/xtermjs/xterm.js/issues/992
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:29 (18 by maintainers)
Top Results From Across the Web
Glyphs 3 Handbook
Glyphs 3 is a professional Mac application for creating OpenType fonts. It allows you to draw, edit and test letter shapes in a...
Read more >Box-drawing character - Wikipedia
Box -drawing characters, also known as line-drawing characters, are a form of semigraphics widely used in text user interfaces to draw various geometricΒ ......
Read more >The Basics of Drawing Type & Creating Your Own ...
Learn how to create your own handwritten script font in this typography drawing tutorial. Need ready-to-use fonts?
Read more >Terminal Appearance in Visual Studio Code
These include box drawing characters ( U+2500-U+257F ), block elements ... support these characters as well as having the characters draw pixel perfect...
Read more >Draw pixel-perfect art - Adobe Support
Align new/transformed objects with the pixel grid Β· Pixel Snapping Options dialog box Β· Draw an object aligned to the pixel grid Β·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@meganrogge and I just finished this, hereβs the result:
Canvas (1.1 line height, 1 letter spacing):
Webgl (same):
The setting is
customGlyphs
and is enabled by defaultIβve done some experimenting with manually drawing certain characters. Demo page: https://roguelike.solutions/xterm/xtermtest.html
Code is rough, but available here: https://github.com/xtermjs/xterm.js/compare/master...guregu:box-drawing
Currently, itβs two parts, one is
boxDrawingLineSegments
which borrows an algorithm from iTerm2. It defines 7 kind of arbitrary vertical and horizontal anchor points per character cell and strokes lines or curves corresponding to them. This works for almost all of the box-drawing lines, but doesnβt work for the dotted line characters which require more anchor points. Having precise control over drawing the lines also means we donβt need to clip horizontally to avoid spillover. Iβm trying to think of a better way to represent these that will also work with the dotted lines. Perhaps instead of splitting cells into 7 somewhat-arbitrary points, instead we can define the locations like βleftβ, βcenterβ, βcenter minus n devicePixelRatio pixelsβ, etc. Also, iTerm2 is GPL2 and I tried to write it to be as original as possible and avoid license issues, but Iβm not sure where the figurative line is drawn here. This is another reason to use a fancier original algorithm. Consider the current implementation a proof of concept.Next is
boxDrawingBoxes
(needs a better name π ) which splits a character cell into eighths and fills in rectangles corresponding to them. This is sufficient to draw the solid block characters, including new ones from the Symbols for Legacy Computing block. This should be enough to support the quadrant characters too, but in order to support sextants it will need to split characters into sixths. Allowing a divisor to be defined would be enough to support most block-like characters.I donβt yet support the polygon characters from the Symbols for Legacy Computing block, but using similar techniques should work for them. Iβm not sure how to go about drawing the shade characters like β β β, but maybe they could be special-cased. Thereβs also the question of how far we want to go with this.
To clean the code up, maybe we could define an interface for drawing segments, and its implementors could be lines, curves, n-th boxes, etc. This is all very experimental, but if it seems like a good idea Iβd be happy to contribute (and add support for the WebGL renderer).