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

Unexpected outcomes when using RTL in Löve12 #1942

Open
0azizi0 opened this issue Jun 10, 2023 · 5 comments
Open

Unexpected outcomes when using RTL in Löve12 #1942

0azizi0 opened this issue Jun 10, 2023 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@0azizi0
Copy link

0azizi0 commented Jun 10, 2023

It seems that Font:setFallbacks( ) is complicated in how it works in the background, I tested it more to see if it works perfectly with RTL languages when used together with LTR fonts. And I apologize for not testing it thoroughly the first time. The results as follows:

  • When RTL (Arabic for example) font used as the fallback, its words are displayed correctly, but organized wrongly from left to right and with no spaces between the words.

RTL fallback

It's supposed to look like this "اختبار العربية".

  • When LTR (English for example) font used as the fallback, its words are displayed and organized correctly, but with no spaces between them.

LTR fallback

  • A Third case is, if you print both texts in one string, the result will be different depending on who is the primary font or the fallback font, or who you started writing with.

This is the code, switch the order of the fonts and comment/uncomment the prints as you see fit.

local love = require("love")

local font = love.graphics.newFont("NotoSans-Regular.ttf", 30)
local fallback = love.graphics.newFont("NotoNaskhArabic-Regular.ttf", 30)
love.graphics.setFont(font)
font:setFallbacks(fallback)

function love.draw()
    love.graphics.print("اختبار العربية")
    love.graphics.print("Hello world")
    love.graphics.print("اختبار العربية Hello world")
end

There is another problem, it happens when using love.graphics.printf. It happens with RTL (Arabic in this case) and not LTR fonts. It displays the text like this when using a big limit:

Screenshot_20230610_214302

I used this code:

local love = require("love")

local font = love.graphics.newFont("NotoNaskhArabic-Regular.ttf", 30)
love.graphics.setFont(font)

function love.draw()
    love.graphics.printf("اختبار العربية", 0, 0, 900, "right") -- This line will display correctly in vscode
end

The fonts here to test with.

@slime73 slime73 added the bug Something isn't working label Jun 10, 2023
@slime73 slime73 added this to the 12.0 milestone Jun 10, 2023
@HDPLocust
Copy link

HDPLocust commented Jun 14, 2023

Huh, there is one BIG topic about this
https://faultlore.com/blah/text-hates-you/
So I guess love2d needs a big beautiful handmade font rendering framework to support this.
Or not.

@0azizi0
Copy link
Author

0azizi0 commented Jun 15, 2023

The current version (LÖVE 11.4) actually has good support for font and text rendering, it also supports unicode. What is missing from the current system is support for text direction and shaping, which can be done manually. With LÖVE 12, support for HarfBuzz was added and the mentioned shortcomings should be gone, it only needs testing and fixing to make sure it's working as intended.

@HDPLocust
Copy link

HDPLocust commented Jun 15, 2023

With LÖVE 12, support for HarfBuzz was added and the mentioned shortcomings should be gone, it only needs testing and fixing to make sure it's working as intended.

Woah, harfbuzz is good news

@slime73
Copy link
Member

slime73 commented Sep 9, 2023

48e23a0 seems to have fixed the printf wrapping issue.

@0azizi0
Copy link
Author

0azizi0 commented Sep 9, 2023

Yes it works. But there is a small issue, by wrapping it takes with it the last letter from the previous word:
Screenshot_20230909_211801

it's supposed to look like this:
Screenshot_20230909_212311

You can test it using the code above and change the limit to 100. Thanks (شكرا).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants