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

Font:getWidth behavior depends on usedpiscale #2168

Open
modcos opened this issue Mar 20, 2025 · 2 comments
Open

Font:getWidth behavior depends on usedpiscale #2168

modcos opened this issue Mar 20, 2025 · 2 comments

Comments

@modcos
Copy link

modcos commented Mar 20, 2025

In the latest versions of LÖVE, I noticed that the value of getWidth depends on usedpiscale, and it differs from previous versions of LÖVE. An example and results are shown below:

local s = {'Test', 'Hello'}

local function wrap(s)
      local font = love.graphics.getFont(96)
      local width = font:getWidth(s)
      print("Width:", width)

      local _, wrapped = font:getWrap(s, width)

      for _, v in ipairs(wrapped) do
            print(v)
      end
end

for _, v in ipairs(s) do
      wrap(v)
end

-- usedpiscale = true
Width: 23
Tes
t
Width: 30
Hello

-- usedpiscale = false
Width: 23
Test
Width: 29
Hello

@slime73
Copy link
Member

slime73 commented Mar 22, 2025

What platform and love version are you using? love 12 supports app-aware DPI scaling on Windows, whereas love 11 and older don't (the app's backbuffer is scaled up instead by the operating system, in love 11 on Windows when the display's DPI scale is not 100%).

@slime73 slime73 changed the title getWidth behavior depends on usedpiscale Font:getWidth behavior depends on usedpiscale Mar 22, 2025
@modcos
Copy link
Author

modcos commented Mar 22, 2025

I am using the latest build of LOVE - commit a9fca2e.

On my Windows 10 system, the scaling is set to 200%, and I get the result shown above when usedpiscale = true.

However, if I set the system scaling to 100% or 300%, I get the correct results.

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