Skip to content

Bug: Some characters width does not match that of the selected font #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
ronisbr opened this issue May 26, 2024 · 1 comment
Closed
2 tasks done
Assignees
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@ronisbr
Copy link

ronisbr commented May 26, 2024

Before You Begin

Before proceeding, please make sure to follow these steps:

  • I have checked for similar issues in the project's issue tracker.
  • I have searched closed issues to see if a similar problem was reported
    before.

Issue Details

First of all, thanks for this amazing software!

When I am trying to render some unicode characters, the width does not match that of the selected unicode font, leading to some strange misalignments.

Description

The issue can be reproduced using this table generated by PrettyTables.jl (Julia language):

┌───────────┬──────────┬────────────┬────────────
│    Col. 1 │   Col. 2 │     Col. 3 │      Col. ⋯
├───────────┼──────────┼────────────┼────────────
│  0.462689 │ 0.842059 │   0.559298 │    0.5792 ⋯
│  0.672944 │ 0.847467 │   0.301494 │    0.4264 ⋯
│  0.804947 │ 0.976035 │   0.785697 │     0.299 ⋯
│   0.56947 │ 0.210278 │ 0.00188285 │    0.1368 ⋯
│  0.191907 │ 0.932318 │   0.188641 │    0.4420 ⋯
│   0.29217 │ 0.441051 │   0.605416 │    0.8476 ⋯
│  0.619284 │ 0.897374 │  0.0310117 │    0.7502 ⋯
│     ⋮     │    ⋮     │     ⋮      │      ⋮    ⋱
└───────────┴──────────┴────────────┴────────────
                   97 columns and 93 rows omitted

I am rendering it using the following command:

ansitoimg tmp.txt output.svg

Expected Behavior

The rendered output should look like this one:

Captura de Tela 2024-05-26 às 16 35 55

Actual Behavior

We obtain the following output:

output

Notice how the last columns that has the character looks misaligned because it is not being rendered with the correct width.

I can reproduce this behavior with all plugins.

System Information

Please provide the following additional information about your system or
environment:

  • Operating System (OS): macOS
  • OS Version: 14.5
  • Browser (if applicable): N/A
  • Browser Version (if applicable): N/A
  • Project Version (if applicable): ?
@ronisbr ronisbr added the bug Something isn't working label May 26, 2024
@FredHappyface
Copy link
Member

Hi thanks for thsi

AnsiToImg cannot meaningfully control the font used when rendering text so this is likely caused by the OS/ playwright library (which uses the chromium browser to render svgs)

Android users will also have this issue and it's due to font-fallbacks. Tonsky who made fira code has some really good articles that explain this sort of stuff a lot better than I ever could! https://tonsky.me/blog/font-size/

Here's an example of a similar allignment issue nushell/nushell.github.io#83. In this case there is nothing the dev can do as it relies on android fixing the issue upstream

Hope the context helps!

@FredHappyface FredHappyface added the wontfix This will not be worked on label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants