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

Text rendering functions that start with ege_ don't handle vertical text justify and stop working randomly. ege_开头的文本渲染函数没有处理垂直对齐并且随机失效 #256

Open
Yqloss opened this issue Jan 14, 2025 · 6 comments

Comments

@Yqloss
Copy link

Yqloss commented Jan 14, 2025

EGE Version EGE版本:ege24.04_all 官网推荐版
Windows Version Windows版本:Windows 11 Home
Compiler 编译器:w64devkit gcc 14.2.0
Compilation Parameters 编译参数:-std=gnu++20 -lgraphics -lgdiplus -luuid -lmsimg32 -lgdi32 -limm32 -lole32 -loleaut32 -lwinmm

ege::initgraph(640, 480, 0);
ege::settextjustify(ege::CENTER_TEXT, ege::CENTER_TEXT);
ege::line(100, 100, 150, 100); // connects centers of the two texts 连接两段文本的中心
ege::outtextxy(100, 100, L"Hello"); // left, normal rendering function 左边 普通渲染函数
ege::ege_outtextxy(150, 100, L"Hello"); // right, ege rendering function 右边 ege渲染函数
ege::getch();

Running the code I found the right text was lower than the left one, and the line was above the right text, which meant the vertical justify didn't even work. More magically, the right text was OFTEN not rendered. (Horizontal justify worked as expected)

运行程序可以发现右边的文字比左边的低,而且直线在右边文字的上方,说明垂直对齐根本没有生效。更神奇的是右边的文字有很大几率无法显示。(水平对齐是没问题的)

@yixy-only
Copy link
Collaborator

@Yqloss ege_ 的文本绘制确实没有设置垂直对齐,属于一直存在的 bug。设置后测试发现 GDI+ 的垂直对齐和测量文本宽高有缺陷,所以暂时搁置没有改。
不显示的情况应该是最近修复了,这个可能是刷新问题,考虑使用 initgraph(width, height, INIT_RENDERMANUAL)

@Yqloss
Copy link
Author

Yqloss commented Jan 14, 2025

是的,我之前用的就是INIT_RENDERMANUAL,后面在复现的时候去掉了这个发现有时候都画不出来了
那我就暂时用outtextxy凑合了

@yixy-only
Copy link
Collaborator

是的,我之前用的就是INIT_RENDERMANUAL,后面在复现的时候去掉了这个发现有时候都画不出来了
那我就暂时用outtextxy凑合了

outtextxy 输出位置是整数坐标,移动时会抖动。目前 ege_xyprintf 想要垂直对齐的话,可以根据文本倾斜角度计算位置偏移,然后调整文本位置。
@Yqloss

@Yqloss
Copy link
Author

Yqloss commented Jan 14, 2025

好的 谢谢

@Yqloss
Copy link
Author

Yqloss commented Jan 14, 2025

那可不可以把ege_开头的vertical justify用这种方法实现一下,毕竟还是以能用为主 @yixy-only

@yixy-only
Copy link
Collaborator

那可不可以把ege_开头的vertical justify用这种方法实现一下,毕竟还是以能用为主 @yixy-only

@Yqloss 底层 GDI+ 的实现是错的,返回的各种信息都不对。用户可以根据自己程序输出的内容慢慢调整,但输出内容对于库是不确定的, 直接偏移只能解决一小部分情况。目前需要解决的是如何才能获取准确的文本信息。

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