Closed mingtsay closed 1 year ago
Nice! looks good to me
Don't suppose you know how to make it work with emojis? For example if you take a look at examples/crazy-redraw.php
and replace:
$items[] = new LineBreakItem(array_rand(array_flip(['♥', '★', '^'])), rand(1, 3));
with:
$items[] = new LineBreakItem(array_rand(array_flip(['❤️', '★', '^'])), rand(1, 3));
It doesn't look good lol
Since full-width characters will break the UI, we should detect the visual width of the string using
mb_strwidth
instead ofmb_strlen
.mb_strlen
when you are detecting the string length for word counting.mb_strwidth
when you are detecting the string width on the screen.I replace all the
mb_strlen
intomb_strwidth
because none of them are used to detecting the string length for word counting. They all are used to get the string width on the screen.You may now use this commit to make CJK characters perfectly fit in the dialog. 😃
正體中文:由於
mb_strlen
是用來計算字串中的字元數量而非寬度,因此需將所有計算字串寬度的函數中的實作都改成使用mb_strwidth
才不會造成跑版。現有的mb_strlen
經人工檢視後發現,用途皆為計算寬度而非字數,因此我將該些實作全部從mb_strlen
改成mb_strwidth
,如此 CJK 字元以及其他全型字元將不會造成跑版。