Skip to content

Conversation

@thethethetheraven
Copy link

this implements Font:getGlyphPosition as outlined in issue #1021.

@thethethetheraven
Copy link
Author

demo:

local utf8 = require "utf8"

local text = "hello, this is a program that uses Font:getGlyphPosition()."
local font = love.graphics.newFont(30)

local i = 1

function love.load()
	love.keyboard.setKeyRepeat(true)
end

function love.keypressed(k)
	if k == "right" then
		i = i + 1
	elseif k == "left" then
		i = i - 1
	end
	i = math.max(math.min(i, utf8.len(text)), 1)
end

function love.draw()
	love.graphics.setFont(font)
	love.graphics.setColor(0.8, 0.5, 0.8)
	love.graphics.rectangle("fill", font:getGlyphPosition(i, text, 400))
	love.graphics.setColor(1, 1, 1)
	love.graphics.printf(text, 0, 0, 400)
end

@EvelynMakesThings
Copy link

I'll write here to bump this request. This seems like good work! Not sure why some OpenGL related checks fail, however.

@thethethetheraven
Copy link
Author

thethethetheraven commented Nov 6, 2025

This seems like good work!

thank you!

Not sure why some OpenGL related checks fail, however.

it seems that a test I wrote fails on mac and windows. I don't have windows or a mac, so if someone could investigate, that would be helpful.

@EvelynMakesThings
Copy link

I'll test it on my windows pc when I get home, so later today. Wish me luck with the windows build process (linux user by heart)

@thethethetheraven
Copy link
Author

thethethetheraven commented Nov 6, 2025

Wish me luck with the windows build process

may you experience great success! I don't envy you.

(by the way, I did not intend to close and reopen the pull request. I'm fumbling with this user interface a bit)

@EvelynMakesThings
Copy link

I have successfully compiled it and run the love2d testing suite with no issues! No errors were encountered while building. this pr should work perfectly fine. Good work!

@thethethetheraven
Copy link
Author

hooray!

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

Successfully merging this pull request may close these issues.

2 participants