xfangfang / borealis

Hardware accelerated, Nintendo Switch inspired UI library for PC, Android, iOS, PSV, PS4 and Nintendo Switch
Apache License 2.0
31 stars 21 forks source link

feat: SDLImeManager support #25

Closed zeromake closed 1 year ago

zeromake commented 1 year ago

@xfangfang 整好了,这里只有系统字体加载和输入支持相关的内容

xfangfang commented 1 year ago

好的感谢~

xfangfang commented 1 year ago

@zeromake 我刚刚测试了一下,在Mac上加载苹方会导致程序崩溃。

奔溃的位置在: https://github.com/xfangfang/borealis/blob/dc429312914ec4855046ff5f92acaf78002ed32c/library/include/borealis/extern/nanovg-gl/stb_truetype.h#L1585

format 值是 14导致的崩溃

但是问题是出在label测量这个字符 "" 尺寸时出现的,这个是 switch 那个手柄按键的字体,不知道为啥会这样。


考虑到应用自带的字体已经能基本满足使用了,所以我先把苹方注释掉了。

zeromake commented 1 year ago

@xfangfang 我在 mac 上用 "" 看了一下没有出现问题,是不是 label 用法不对

10:20:59.471[INFO] Set app locale: 
10:20:59.471[INFO] Using platform SDL
10:20:59.575[INFO] sdl: GL Vendor: ATI Technologies Inc.
10:20:59.576[INFO] sdl: GL Renderer: AMD Radeon RX 580 OpenGL Engine
10:20:59.576[INFO] sdl: GL Version: 4.1 ATI-4.8.101
10:20:59.711[INFO] joystick num: 0
10:20:59.711[WARNING] Could not load the font "regular"
10:20:59.711[ERROR] regular font was located but couldn't be loaded
10:20:59.711[WARNING] Cannot find custom font, (Searched at: ./resources/font/font.ttf)
10:20:59.711[INFO] Using internal font: ./resources/font/switch_font.ttf
10:20:59.733[INFO] Using zh-Hans font: /System/Library/Fonts/PingFang.ttc
10:20:59.742[INFO] Using korean font: /System/Library/Fonts/AppleSDGothicNeo.ttc
10:20:59.742[WARNING] Could not load the font "switch"
10:20:59.742[ERROR] switch font was located but couldn't be loaded
10:20:59.742[WARNING] Cannot find custom icon, (Searched at: ./resources/font/icon.ttf)
10:20:59.742[INFO] Using internal icon: font/switch_icons.ttf
截屏2023-08-15 10 23 40 截屏2023-08-15 10 23 47

难道是 cmake 编译效果不一样?我等等用 cmake 编一个

xfangfang commented 1 year ago

我试了一下 borealis demo还是存在问题,位置和原因是一样的,咱们的log也是一样的。 这次出现问题的是 Highlight button 前面的字符。

直接把 STBTT_assert(0); 注释掉倒是也可以。

不太清楚具体的原因,难不成是苹方字体不是同一个?

这是我系统内的字体(24小时有效):https://wormhole.app/oOByD#MNU7jaAxBlskYc_CO1bssw

zeromake commented 1 year ago

@xfangfang

苹方字体不是同一个

大概是的,系统还是 12.6,顺便一提这个下载一直是 0% ……

zeromake commented 1 year ago

@xfangfang 可以考虑把 zh-Hans font 加载放到 internal icon 之后,让 icon 先用 internal icon

xfangfang commented 1 year ago

换了个国内的 CDN https://image.xfangfang.cn/personal/PingFang.ttc

zeromake commented 1 year ago

@xfangfang 重现了,我晚上看看怎么回事吧,你先把 PingFang 干掉吧

zeromake commented 1 year ago

@xfangfang 是 stb_truetype 的 bug,应该是这个字体太新了,我提到 #1511

xfangfang commented 1 year ago

感谢~ 那我要用的话,先把这个字体注释掉