Skip to content
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

RTL languages messes the layout! #167

Open
AYehia0 opened this issue Jan 26, 2023 · 2 comments
Open

RTL languages messes the layout! #167

AYehia0 opened this issue Jan 26, 2023 · 2 comments

Comments

@AYehia0
Copy link

AYehia0 commented Jan 26, 2023

I am trying to render arabic text which is rtl, the problem is that it always messes the layout of the viewport.

  • The EN version :
    2023-01-26-14-10.png

  • The AR version :
    2023-01-26-14-11.png

I have a list of text, rendering happens line by line as follows :

content := ""
for _, ayah := range entries {

	text := lipgloss.NewStyle().
		Bold(true).
		Foreground(lipgloss.AdaptiveColor{Dark: "#ffffff", Light: "#000000"}).
		Width(keyWidth).
		Render(goarabic.RemoveTashkeel(wrap.String(ayah.Text, keyWidth)))

	row := lipgloss.JoinHorizontal(lipgloss.Center, text)
	content += fmt.Sprintf("%s\n\n", row)
}

titleText := lipgloss.NewStyle().Bold(true).
	Background(titleColor.Background).
	Foreground(titleColor.Foreground).
	Border(lipgloss.NormalBorder()).
	Padding(0, 1).
	Italic(true).
	BorderBottom(true).
	BorderTop(false).
	BorderRight(false).
	BorderLeft(false).
	Render(title)

return lipgloss.NewStyle().
	Width(width).
	Height(height).
	Render(lipgloss.JoinVertical(
		lipgloss.Top,
		titleText,
		content,
	))

I also tried to :

  • align text to the left and right.
  • use the highPerformanceRendering (doesn't show the 2 viewports)
@meowgorithm
Copy link
Member

This is most likely a multi-layered issue, but we really do need better RTL support in Lip Gloss. It's hard to say exactly where the problem for this lies, but my guess is that go-runewidth isn't returning the correct width for Arabic glyphs. Also bear in mind that some terminals do a better job with Arabic than others (Kitty, in my experience, is excellent whilst many others seems to struggle). What terminal are you using in your screenshot?

Another note here: I've seen some frameworks, like QT, provide the option mirror the UI for RTL. So that's potentially a parallel feature that could make sense in either Lip Gloss or Bubble Tea.

@AYehia0
Copy link
Author

AYehia0 commented Feb 9, 2023

I have tested almost all the available terminals out there for linux ofc, the one in the screenshot is termite, but there almost no difference between them all.
here is kitty :
image

I don't know if go-runewidth returns wrong length, but the weird thing is that the windows terminal (the newer version), just displays the text almost perfectly :
image

I don't know what could possibly be the solution :'(

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

No branches or pull requests

2 participants