how to position rectangle around text? #6
Replies: 3 comments
-
I'm not sure I understand what you want to do. I don't know if you are trying to create a "selection highlight rectangle" behind the text, or some kind of box or arrow above or below it. Assuming the first:
If you are not familiar with some of these metrics, I highly recommend the document linked in the README. This is the most relevant part for your purposes: https://freetype.org/freetype2/docs/glyphs/glyphs-3.html. Now, the ascent metric is not super easy to access through etxt. The renderer actually stores the value cached, so I may want to add a method for it to make it more efficient and straightforward, but for the moment you have to do something like this: font := renderer.GetFont()
size := renderer.GetSizePxFract()
metrics := renderer.GetSizer().Metrics(font, size)
ascent := metrics.Ascent Regarding my contact, I don't want to share. Opening an issue even for a question like this is ok to me, but I've also opened discussions in case people want to ask small questions like these and opening an issue feels wrong for them. |
Beta Was this translation helpful? Give feedback.
-
There are many other ways to deal with this though. For example, if you start the About returning the text origin position from
|
Beta Was this translation helpful? Give feedback.
-
No problem, totally understand! It's just in your README you advise people to reach out to you and I couldn't figure out how to do that without going to an issue, which as you noted, feels weird for this kind of question. Really appreciate you firing up discussions for this codebase! |
Beta Was this translation helpful? Give feedback.
-
I'm sorry I am having a bear of a time figuring out how to properly position a highlight around a word at an arbitrary point in the text. The rect returned by
SelectionRect(someText).ImageRect()
is the correct size but anchored at 0,0 not the position of the text. I then triedbut that is positioning the highlight under the target text.
So I think I have two questions:
someText
?SelectionRect(someText).ImageRect()
be anchored to the word instead of at 0,0?Also, you might want to put some contact information in the README, or add your email to your account on github
Beta Was this translation helpful? Give feedback.
All reactions