如何对齐 GnomeCanvas 文本项内的文本

发布于 2024-07-10 15:40:57 字数 243 浏览 5 评论 0原文

我想要一个 GnomeCanvas 文本项,并根据其内容(和内容语言)决定是将文本向右还是向左对齐。 我找到了一种通过更改 anchor 属性来实现的方法,但使用此方法需要我自己管理锚点位置(向右对齐时将其更改为文本边界框的右侧) ,看来一定有更简单的方法。

编辑:我看到还有 justification 属性,它允许我将文本向右对齐。 但是,我仍然需要根据语言设置锚点,而不是设置适用于任何语言的边界框。

I would like to have a GnomeCanvas text item and according to its content (and the content language) decide whether to align the text to the right or to the left.
I found one way to do it by changing the anchor property, but using this method would require me to manage the anchor position myself (change it to the right of the text bounding box when aligning to the right), and it seems there must be a simpler way.

EDIT: I see there is also the justification property, which allows me to align the text to the right. However, I still need to set the anchor point according to the language, instead of setting a bounding box that would apply to any language.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谎言月老 2024-07-17 15:40:57

大约一个月没有其他答复。 我想我的第一个理解是正确的,并且画布没有其他方法。 我的解决方案是将锚点更改为东并相应地更改锚点。

Its about a month without another answer. I guess my first understanding was correct and there isn't another way with the canvas. My solution would then be to change the anchor to east and change the anchor point accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文