xege icon indicating copy to clipboard operation
xege copied to clipboard

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

Open Yqloss opened this issue 11 months ago • 6 comments

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)

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

Yqloss avatar Jan 14 '25 03:01 Yqloss

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

yixy-only avatar Jan 14 '25 13:01 yixy-only

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

Yqloss avatar Jan 14 '25 13:01 Yqloss

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

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

yixy-only avatar Jan 14 '25 15:01 yixy-only

好的 谢谢

Yqloss avatar Jan 14 '25 16:01 Yqloss

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

Yqloss avatar Jan 14 '25 16:01 Yqloss

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

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

yixy-only avatar Jan 14 '25 17:01 yixy-only

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

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

现在有了GDI+的测量方式,是不是可以改改这个了

FeJS8888 avatar Aug 28 '25 10:08 FeJS8888