更新时间:2023-11-29 15:13:22
如果你使用比例字体(这是默认的,真的,大部分都是),那么你会看到这种效果。如果您希望字符在多行上排成一行而不必大惊小怪,则需要使用非比例字体,其中每个字符的宽度相同。微软机器上的几个例子是Courier和Lucida Console。
还有其他解决方案(例如设置和使用标签)。
Using drawtext function how can we draw a string with each character of same width.
For Eg:
Sushant |Mandhare
Prashant |ABCXYZP
if both the above strings are of same length,since width of each character is different im not getting the separator one below the other
If you use a proportional font (which is the default and really, most of them) then you will see this effect. If you want the characters to line up on multiple lines without a lot of fuss, you need to use a non-proportional font, where each character is the same width. A couple of examples on Microsoft machines are "Courier" and "Lucida Console".
There are other solutions as well (eg. set and use tabs).