Webview vertically stretched text line spacing

Open
#2,124 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript
Domain
frontend

Research direction

Start with frontends/server/frontend/editor.js, especially computeFontSize() and drawText(), and trace how the generated index.js is built since the report says edits to editor.js did not take effect. Compare the webview line spacing with the ncurses client using the same font, then verify that text lines no longer have excess vertical space and that redraws leave no artifacts.

Written by the indexing model from the issue text.

Description

In the webview client, extra vertical space is being added to every text line. The screenshot below illustrates this. The left hand side shows the webview client, and the right hand side shows the ncurses client in an iTerm2 window. Both use the same font (Menlo at 12 pt).

Image

Despite not being a web dev - hence up-front apologies for any and all misinterpretations on my part! - I thought I'd give it a try; apparently hoping for some low hanging fruit. 😉

frontends/server/frontend/editor.js features the constant textOffsetY, which is used in two places:

computeFontSize()

Line 38 of frontends/server/frontend/editor.js reads:

    Math.round(textMetrics.fontBoundingBoxAscent + textOffsetY + (textMetrics.emHeightDescent || 0)),

This seems more complicated that it might perhaps need top be?

Why was using the bounding box not sufficient?

    Math.round(textMetrics.fontBoundingBoxAscent + textMetrics.fontBoundingBoxDescent),
drawText()

Line 48 of frontends/server/frontend/editor.js reads:

  y += Math.round(textOffsetY); // 少しずらしておかないと上の部分が現在行からはみ出して、その行だけ再描画しても描画跡が残ってしまう

The Japanese comment seems to say something along the lines of "if we don't move it, bad things will happen". I would presume this comment was addede by @cxxxr, the author of the commit introducing the code? I would also presume that the issue trying to be remediated here occurs when using CJK fonts?


I modified editor.js, and rebuilt lem, but my changes didn't take effect. It seems I would somehow need to regenerate index.js? How would I do that?

Many thanks in advance, and looking forward to your thoughts!

Dominant language
Common Lisp
Stars
3.1k
Forks
261
Avg merge
1d 6h
Merged PRs (30d)
133

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lem-project/lem

All issues in lem-project/lem

Similar issues

More Web Dev issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.