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

ttf does not provide TTF_GlyphIsProvided #615

Open
boredcoder411 opened this issue Dec 13, 2024 · 12 comments
Open

ttf does not provide TTF_GlyphIsProvided #615

boredcoder411 opened this issue Dec 13, 2024 · 12 comments

Comments

@boredcoder411
Copy link

same as title, no TTF_GlyphIsProvided in the sdl2-ttf package

@shellohunter
Copy link

ttf_measure APIs missing too, such as: https://wiki.libsdl.org/SDL2_ttf/TTF_MeasureUTF8
those api are quite helpful when dealing with line wrapping.

is there any reason for dropping those APIs, or just because of short of hands?

@veeableful
Copy link
Contributor

Hi, sorry about the missing APIs 💦 I will add them once I'm available to do so.

@veeableful
Copy link
Contributor

Hi @boredcoder411 and @shellohunter, I have added the bindings to the master branch. Would you like to try it out?

@shellohunter
Copy link

measure APIs works as expected. thanks! will them be in next tag?

btw, I noticed that v0.5 is in beta, it would be nice if sdl2 enums have enum-like typedefs in golang, something like this:

type MouseButton uint8
const(
     MouseButtonLeft MouseButton = 0
     MouseButtonRight MouseButton = 1
)

language servers can make use of it, providing better auto-completion.

@veeableful
Copy link
Contributor

@shellohunter Yes! They will be in the next tag.

We have constants ButtonLeft and ButtonRight. Is that what is being referred to?

@shellohunter
Copy link

constants are just integers, what I mean is to add specific types to group constants like this: https://gobyexample.com/enums , then go can make basic type checking to prevent misuse, and it will be more comprehensive to LSP.

@veeableful
Copy link
Contributor

veeableful commented Dec 23, 2024

@shellohunter we do have the Button type. Is there something that you find missing?

If there is, please create another issue!

@shellohunter
Copy link

@veeableful just noticed they are already available in master branch. no issues anymore.

@lmorg
Copy link
Contributor

lmorg commented Feb 10, 2025

Just wanted to share that I'm very grateful for v0.5.0 and the GlyphsIsProvided API specifically too.

Thank you for all your dedication to this project

@lmorg
Copy link
Contributor

lmorg commented Feb 16, 2025

It looks like GlyphsIsProvided is already "deprecated" (in the sense that it's not recommended) in SDL because it's only a uint16. Instead they recommend GlyphsIsProvided32.

As per the documentation, the 16-bit version of that API doesn't account for a wide range of code points, including emoji (that latter being how I stumbled upon this problem).

Given Go runes are 32-bit, I wonder if it is worth switching the Go lang mapping for GlyphIsProvided to the C TTF_GlyphIsProvided32 so that Go defaults to the most up-to-date version of that API. And have the Go method accept a rune instead of uint32. This would mean we'd need to cast the rune (int32) to a uint32 but, unless I'm overlooking something obvious, that shouldn't be a problem. And it's likely an operation that the API consumer would want and do themselves anyway.

I appreciate this would be a breaking change but v0.5.0 is still in alpha so it's arguably a safe point to do so.

Are you happy for me to raise a PR to make this change, is this something you'd rather pick up, or do you disagree with this approach entirely?

@veeableful
Copy link
Contributor

Hi @lmorg, thank you bringing that up. I think keeping the function names predictable would be desirable so GlyphIsProvided would use TTF_GlyphIsProvided and GlyphIsProvided32 would use TTF_GlyphIsProvided32. I would certainly be happy to accept the PR!

This was referenced Feb 18, 2025
@lmorg
Copy link
Contributor

lmorg commented Feb 18, 2025

PR: #621

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

4 participants