charmbracelet / lipgloss

Style definitions for nice terminal layouts 👄
MIT License
8.09k stars 229 forks source link

Rendering Issues on Windows #30

Closed PrinnyRay closed 3 years ago

PrinnyRay commented 3 years ago

I found border rendering is very strange, I've tried on Windows Terminal and legacy CMD, both are missing some characters, am I missing some configs? 7cf793398ba9c0f97cad7e956f9ccf1 baff54d81acc85835c65aadec4cdad6 Here is my code: logo := "foo bar" fmt.Printf(lipgloss.NewStyle().BorderStyle(lipgloss.DoubleBorder()).Render(logo))

BTW, I love this lib and bubbletea. I'm trying to build a cli tool in go, your repo is the most elegant framework I've ever seen. Thanks for building this.

PrinnyRay commented 3 years ago

and example code looks like this... 8fd1cfa217d3fe449de60ebdbb8eb29

meowgorithm commented 3 years ago

Thank you for the kind words on Lip Gloss and Bubble Tea!

And oh my, this looks quite odd. We'll investigate this shortly and get back to you. Thanks for flagging this.

meowgorithm commented 3 years ago

Hi! I'm not able to produce this behavior on Windows (see the screenshot below showing Lip Gloss output in Windows Terminal, PowerShell standalone, and the legacy command console in Windows 10.

Are there any more details you can provide on your environment? In particular, Windows version, terminal font…and maybe locale?

windows
PrinnyRay commented 3 years ago

My envs are: Windows 10 Pro for Workstations, Ver.2004 Build.19041 Windows terminal Font is Consolas 12pt and YaHei UI Legacy CMD is SimSun(I think Western Letter fallback is Times New Roman) And Goland IDE integrated Terminal is Fira Code 14pt(with default SimSun fallback) They are all using Command Line de6737b09518910aa36b822f11e3eef

meowgorithm commented 3 years ago

I think this may be a font issue…but it's difficult to say. Could you try pasting this this into a text file:

╔═══════╗
║foo bar║
╚═══════╝

…and then running type filename.txt to print it to the console?

PrinnyRay commented 3 years ago

I got this。。 96ba9e1e4b23369b9b2917a96fce297 88f38a31d5a050b757ac28f25070413

This always happens when encoding are not matching. You remind me that I'm not using unicode console, I'll check it.

meowgorithm commented 3 years ago

Cool, let me know! The other thing to double check is that all your fonts (including the fallbacks are monospaced fonts (and not proportional ones). In both cases it looks like your Latin fonts (and maybe your CJK ones as well) are proportional fonts.

PrinnyRay commented 3 years ago

Solved. I changed the cmd encoding to utf-8 and layout looks perfect. 5ec04b148a08ddad8ec8015f4a5ae03 27a325752e0d86b646144a26ef0bc02 I guess the default charset for Windows with Simplified Chinese is GBK, and charset in windows is also called active console code page. For me it is 936 for default, that means I'm using GBK encoding.
Use chcp 65001 to change to utf-8 encoding according to this page. I think if you run chcp 936 before you run the program, you would get the same result.

meowgorithm commented 3 years ago

Awesome. This is really good to know. Thanks for the details on how you fixed it.

I’m going to close this issue, but feel free to open it back up if you notice any other odd behavior.