Open regorxxx opened 2 years ago
Edit: See my next comment, turns out the font simply wasn't installed properly on the system.
Around 3 months ago I decided to update my fb2k components and in doing so Columns UI updated (probably to v2.0.0-alpha.1 or greater). SMP v1.6.1 has been the latest version for a year, so it's CUI changes which have caused the following bug: After updating, one of my SMP scripts started to crash each time it came to display some text (without me having made any modifications to my script in a long time). I'm getting the same error as above but on Windows (so this isn't exclusive to WINE):
Error: Spider Monkey Panel v1.6.1 (LoadImageAsync_ArtGallery: LoadImageAsync_ArtGallery by user)
CalcTextWidth failed:
font argument is null
File: album_art.js
Line: 424, Column: 21
Stack trace:
draw_text_box@album_art.js:424:21
on_paint@album_art.js:463:9
After digging around, I've noticed what the issue is: The bug can be eliminated simply by changing the font used to something different via CUI's settings (fb2k Preferences > Display > Columns UI > Colours and fonts > Fonts tab > Element: "Common (list items)", Mode: "Custom" > Font: <some_different_font>). No change to the code required.
I'm not sure why, but font Open Sans 8pt Bold
used to work fine but SMP seemingly can't read it correctly from CUI any more (hence null
). Changing the font to, for example, Verdana, causes the crash to stop.
Ideally I could still use that font as it affects my entire theme. There is a workaround however by explicitly setting the font via code. In my case, even though I'm using font size 8 via CUI's prefs, I need to specify font size 11
via my script to match what it previously looked like:
let g_is_default_ui = window.InstanceType;
let g_font = null;
get_font();
function get_font()
{
// `if` which fails to recognise "Open Sans".
if (g_is_default_ui) {
g_font = window.GetFontDUI(FontTypeDUI.defaults);
} else {
g_font = window.GetFontCUI(FontTypeCUI.items);
}
// Set font explicitly.
if (g_font == null) { g_font = gdi.Font("Open Sans", 11, 1); }
}
Why would Open Sans be accepted via code but not when set via CUI? I think this is a problem with SMP not CUI as other CUI UI elements can use the font without issue.
Although the code change above works to (temporarily) solve the issue, I'm also using the "Library Tree" script which included with SMP and it too isn't picking up the Open Sans font (it's displaying something else, probably Segoe UI). Other included scripts are likely affected too.
In short, there are two temporary fixes:
foobar2000 1.6.16 Columns UI 2.0.0-beta.1 Spider Monkey Panel 1.6.1 Windows 11 Pro 10.0.22621
Because the Open Sans font worked for CUI UI elements, and too for SMP when explicitly set via code, I didn't think would be an issue with the font itself... Turns out I was wrong. Checking Windows' Fonts showed that Open Sans was nowhere to be seen. I quickly reinstalled the font and it appeared in Windows' list of fonts and also resolved the bug (I had forgotten it was even a third-party font).
Not sure how it was displaying the font if the font wasn't installed, but now that it is installed properly again, everything is back to normal.
SMP blank panel crashes when default font on Wine is not Segoe UI, even if the font is installed.
https://hydrogenaud.io/index.php/topic,120979.msg1011968.html#msg1011968 Tested on Spider Monkey Panel v1.6.2-dev+7c0928b, and wine 7.11 (mdac28 wsh57)
(PD: there is also a foobar crash on the same message I have no idea what's going on. The this.g_theme null is #172, which I managed to "solve" by recreating the entire buttons theme using SMP methods)