issues
search
xtuzy
/
Yang.Maui.Helper
MIT License
6
stars
1
forks
source link
detail for TextWordBlock for Windows
#3
Open
xtuzy
opened
1 year ago
xtuzy
commented
1 year ago
测量大小 maui.graphics使用canvastextlayout的drawbounds获取文本大小,但看https://microsoft.github.io/Win2D/WinUI2/html/P_Microsoft_Graphics_Canvas_Text_CanvasTextLayout_LayoutBounds.htm ,layoutbounds和android从staticlayout获取的大小更相似
空白字符 canvastextlayout测单独的空白字符时,获得的宽为0, 从layoytbounds能获得高度数值,其值和其他字符都一样,搜索到
https://www.google.com/amp/s/www.freecodecamp.org/chinese/news/html-space-how-to-add-spaces/amp/
,可能考虑其它字符替代,需要看ios和android上测量得多少,或者使用包含空格的文本去减去其他字符获得
xtuzy
commented
1 year ago
FotSize=14, Font.Default时
Windows
space w = 0, h = 18.6210938
n w = 7.92285156, h = 18.6210938
m w = 12.0585938, h = 18.6210938
"n m" w=23.8164063, h=18.6210938 => calculate space w= 3.83496
Android
space w = 3.272727, h = 16.36364
n w=7.6363635 h=16.363636
m w = 12, h = 16.36364
"n m" w=22.90909 h=16.363636 => calculate space w= 3.2727265
iOS
space w=3.7871094 h=16.707031
n w=8.018555 h=16.707031
m w=12.03125 h=16.707031
"n m" w=23.836914 h=16.707031 => calculate space w= 3.787109