GUI_DispStringInRectEx does not work as intended if ((TextAlign & GUI_TA_VCENTER) && (MaxLen < strlen(acText))).
How to reproduce:
Here's the output if (MaxLen == strlen(acText)):
[img]http://s17.postimg.org/4m379k7yz/ss3.jpg[/img]
Here's the actual output:
[img]http://s4.postimg.org/kqhogef09/ss1.jpg[/img]
Here's the expected output:
[img]http://s8.postimg.org/eehb7yd6p/ss2.jpg[/img]
Actually this is not exactly the expected output. There's also a bug in the text alignment. As you see on the third screenshot "Tex" is not properly aligned to center. emWin does count last character's whitespace pixels while it's calculating a string's rectangle. There's a new function named GUI_GetTrailingBlankCols introduced recently. If emWin uses this function to calculate correct size of the string it'll be perfect.
I know i'm talking about a few pixels but it's very important if your application works on a very low resolution screen.
Update: After further investigation, i found that this function needs a null character at acText[MaxLen]. As a workaround i had to buffer my partial string. But as i was printing this string directly from flash memory, now i had to allocate a buffer.
How to reproduce:
Here's the output if (MaxLen == strlen(acText)):
[img]http://s17.postimg.org/4m379k7yz/ss3.jpg[/img]
Here's the actual output:
[img]http://s4.postimg.org/kqhogef09/ss1.jpg[/img]
Here's the expected output:
[img]http://s8.postimg.org/eehb7yd6p/ss2.jpg[/img]
Actually this is not exactly the expected output. There's also a bug in the text alignment. As you see on the third screenshot "Tex" is not properly aligned to center. emWin does count last character's whitespace pixels while it's calculating a string's rectangle. There's a new function named GUI_GetTrailingBlankCols introduced recently. If emWin uses this function to calculate correct size of the string it'll be perfect.
I know i'm talking about a few pixels but it's very important if your application works on a very low resolution screen.
Update: After further investigation, i found that this function needs a null character at acText[MaxLen]. As a workaround i had to buffer my partial string. But as i was printing this string directly from flash memory, now i had to allocate a buffer.
The post was edited 3 times, last by kneeangel ().