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

fix: 解决文本垂直居中对齐出错问题 #144

Merged
merged 2 commits into from
Feb 3, 2024

Conversation

yixy-only
Copy link
Collaborator

在文字对齐方式设置为垂直居中时,如果文本输出方向并非为水平从左到右(即 角度为 0°),会出现文本对齐错误、文本发生偏移的情况。

@yixy-only
Copy link
Collaborator Author

yixy-only commented Jan 28, 2024

出错原因为:SetTextAlign() 没有垂直居中对齐的选项,只有水平居中对齐,因此要使用 TextOut() 实现文本垂直居中对齐输出,需要自行计算文本偏移。而代码中计算偏移时仅使文本朝 y 负方向偏移 1/2 的文本高度,没有考虑文本发生旋转,角度不为 0° 的情况。

@yixy-only
Copy link
Collaborator Author

image

@yixy-only yixy-only merged commit bc002a0 into wysaid:master Feb 3, 2024
1 check passed
@yixy-only yixy-only deleted the fixbug_text_vertical_align branch February 20, 2024 14:33
@yixy-only yixy-only self-assigned this Apr 25, 2024
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

Successfully merging this pull request may close these issues.

1 participant