bytecave wrote:This happens with several fonts, but doesn't repro reliably. Whether I extract my fonts to the TEMP folder or to the same current program folder, occasionally RegisterFontFile hangs and never returns. I've tried with PB 5.61 / 5.62, on 5 different Windows machines (3 WIn 8, 2 WIn 10), and eventually it hangs. You can put your tiny sample in a batch file and call it repeatedly until it hangs on RegisterFontFile. Exiting PB for a few hours and trying again later in the day often works. It's not random, but it repros reliably, *when* it repros at all.
Exactly, it happens very sporadically on two of my systems - however it seems I have found a system on which this can be reproduced on each build. On my MSI ge62 Apache Pro laptop with a fresh Windows 10 Pro install, x64 bit, it happens on every single run. This is a problem for me, as it completely breaks my application haha.
I think this can be considered a bug, no?
Thanks for confirming bytecave, I was almost going nuts!
Using native API on Windows does seem to work with the font:
Code: Select all
; int nResults = AddFontResourceEx(
; m_szFontFile, // font file name
; FR_PRIVATE, // font characteristics
; NULL);
;
;
#FR_PRIVATE = $10
ImportC "gdi32.lib"
AddFontResourceExW.i(lpszFilename.p-unicode, flags.l, *pdv)
EndImport
OpenConsole()
f.s = OpenFileRequester("Select font", "", "TrueType Font (*.ttf)|*.ttf", 0)
If(f <> "")
start_time.q = ElapsedMilliseconds()
result = AddFontResourceExW(f, #FR_PRIVATE, #Null)
end_time.q = ElapsedMilliseconds()
delta.q = end_time - start_time
seconds.d = delta / 1000.0
Debug "that took " + StrD(seconds, 2) + " seconds..."
If(result)
Debug "success! " + Str(result) + " fonts added"
Else
err = GetLastError_()
Debug "fail: " + Str(err)
EndIf
EndIf
whereas the same code with the PureBasic function halts code execution. I need a cross platform solution though, and not hack in a fix for Windows like this.