MantisBT - NetSurf
View Issue Details
0002477NetSurfRISC OS-specificpublic2016-10-09 20:312018-08-29 15:00
Assigned To 
PlatformOSOS Version
Product Version3.5 
Target Version3.8Fixed in Version3.8 
Fixed in CI build #4305
Reported in CI build #3729
URL of problem page
Summary0002477: Scanning fonts fails on MathPhys despite previously being OK
DescriptionHaving not consciously changed my fonts (I only have 11 plus the ROM fonts) on my Risc PC, NetSurf now fails to start while scanning fonts. Perhaps I deleted the RUFL cache in !Scrap at some point, never mind.

I noticed this a while ago, but just moved the fonts out of the way to continue to use NetSurf, however with CI#3729 and putting the fonts back it's still there.

The rufl_test app seems happy with everything, and rufl_chars also. Dump attached from rufl_test in case that helps?
Steps To ReproduceRun NetSurf.
Additional InformationIt's also annoying that the Wimp's single tasking error box "The Unicode font library could not be initialized" opens centrally on screen and doesn't mention the font which was the problem, because it obscures the "Scanning fonts..." dialogue so you have to binary chop your !Fonts directory to find which one was the problem.
TagsNo tags attached.
Attached Fileszip (5,353) 2016-10-09 20:31
txt Log_from4303.txt (5,705) 2018-01-21 15:58

2016-10-09 20:58   
Spotted this in the log:

(0.640000) frontends/riscos/font.c:120 nsfont_init: Initialise RUfl
(2.180000) frontends/riscos/font.c:124 nsfont_init: rufl_init: rufl_FONT_MANAGER_ERROR: 0x21e: /Default encoding not found
(2.180000) frontends/riscos/gui.c:2124 die: The Unicode font library could not be initialized. Please report this to the developers.
2016-10-27 20:37   
Extra data point, since this is a Risc PC, if I softload RISC OS 5 NetSurf starts correctly (ie. with the same !Fonts) but with RISC OS 4.02 the above error happens. Presumably some difference in behaviour between the two font managers?
Vincent Sanders   
2016-11-22 22:21   
Unfortunately as this is a RISC OS specific issue and we currently have no active RISC OS developer we cannot guarantee a timely response to this issue.
2017-04-11 16:54   
Just tried this again with 3.7 CI#4060, but it still errors.
Having had a quick look at rufl_init() there are only 11 places where it can return rufl_FONT_MANAGER_ERROR.

I think the key piece of information (which I don't appear to have mentioned before, sorry) is that it's Font Manager 3.71. This seems to be key. If I go back to the ROM based Font Manager (3.40) then the RUFL cache is generated. I can then reboot so I'm back with Font Manager 3.71 again and the cache is loaded OK.

I can see in rufl_init.c there's all kinds of logic to work out which API to use. It would seem the non-unicode case is tripping up requesting the /Default encoding for some reason, which is presumably skipped entirely on old font managers.
John-Mark Bell   
2018-01-21 12:11   
Please try again with CI build 4300 or later, and attach the log file. Thanks.
2018-01-21 16:06   
Updated log attached (from CI #4303 as it happens).
John-Mark Bell   
2018-01-21 17:28   
OK, so xfont_find_font("MathPhys.Italic\ELatin1", 160, 160, 0, 0, &font, 0, 0) succeeds and returns a font handle.

However, calling xfont_scan_string(font, " ", font_RETURN_BBOX | font_GIVEN_FONT | font_GIVEN_LENGTH | font_GIVEN_BLOCK, 0x7fffffff, 0x7fffffff, &block, 0, 1, 0, &x_out, &y_out, 0) fails as the /Default encoding can't be found.

I don't happen to have MathPhys.Italic to hand, but I expect it's a symbol font (i.e. has Outlines and IntMetrics files, rather than IntMetric<N> and has no Encoding file of its own). With the Unicode FontManager (which you appear to be softloading, this causes the FontManager to attempt to load the /Default encoding from Font:Encodings./Default. This is present in the ROMFonts module on RISC OS 5. I suspect, however, it's not present in the RISC OS 4 ROMFonts module (and I also expect that you're not softloading the RISC OS 5 ROMFonts module).

So, you probably want to stick;content-type=text%2Fplain;hideattic=0 in !Fonts.Encodings (or softload the RISC OS 5 ROMFonts module).

We can probably make RUfl ignore this font completely in the case where the encoding can't be loaded, but that's a sticking plaster, not a fix.
John-Mark Bell   
2018-01-21 17:38   
If you can test with 4304 or later and post the log file, that'll help. It should probably work "fine", as I've made it ignore the lack of encoding file when attempting to read the font.
John-Mark Bell   
2018-01-21 19:29   
Actually, make that 4305 or later -- 4304 only covered half the wound.
2018-01-21 21:21   
You're right MathPhys is a symbol font, it comprises 5 files
  MathPhys.Encoding MathPhys.IntMetrics MathPhys.Outlines
  MathPhys.Italic.IntMetrics MathPhys.Italic.Outlines
and comes as part of TechWriter. You're right there's no /Default in my Encodings directory.

I notice NetSurf adds to Font$Path so I was able to get rid of the error with CI #4303 by just putting an Encodings./Default alongside the NSSymbol inside !NetSurf.Resources.

I also tried CI #4305 (having removed the /Default file) and that also got rid of the error - success!

So it seems there's two ways out:
a) add a Encodings./Default
b) swallow the error in RUfl
John-Mark Bell   
2018-01-22 01:02   

The underlying issue here is that you're attempting to use a Unicode-capable FontManager without a corresponding ROMFonts module.

When non-Unicode-capable FontManagers deal with symbol fonts, they will use the Encoding file in the font directory, if present, or default to assuming a 1:1 mapping between glyph index and codepoint. The Unicode FontManager behaves differently in the latter case: it relies on there being a /Default encoding to map between glyph index and codepoint (full details can be found in $2.3 of

It is also worth noting that RUfl decides that the FontManager in this case is not Unicode-capable. The reason for this is that the test it uses to determine Unicode-awareness is to call XFont_FindFont with "Homerton.Medium\EUTF8" -- if this fails, then it decides it's dealing with a non-Unicode-capable FontManager. For this test to work, the Unicode FontManager requires the presence of a UTF8 encoding file. This is found in the ROMFonts module, too, so is also missing here.

We're not going to add these encoding files to the NetSurf distribution as they belong to the FontManager/ROMFonts combination -- they're not specific to NetSurf (or RUfl), and we assume that OS components are installed correctly. While I've made RUfl more tolerant of mismatched FontManager/ROMFonts, it's not a real fix (as the net effect is that all symbol fonts with no explicit Encoding file will be ignored).
2018-01-22 08:41   
I think the extra robustness in RUfl will catch casual FontManager soft loaders (it's been long enough that I've now forgotten why I was softloading it on the Risc PC, probably something for !Pluto email) from falling, and I can add an updated ROMFonts to do it properly.

Thanks for investigating. Good to close.
Vincent Sanders   
2018-08-29 15:00   
Thank you for your report, this has been resolved in the 3.8 release

Issue History
2016-10-09 20:31SprowNew Issue
2016-10-09 20:31SprowFile Added:
2016-10-09 20:58SprowNote Added: 0001411
2016-10-27 20:37SprowNote Added: 0001414
2016-11-22 22:21Vincent SandersNote Added: 0001442
2016-11-22 22:21Vincent SandersStatusnew => acknowledged
2017-04-11 16:54SprowNote Added: 0001538
2018-01-21 12:11John-Mark BellNote Added: 0001713
2018-01-21 12:30John-Mark BellStatusacknowledged => feedback
2018-01-21 15:58SprowFile Added: Log_from4303.txt
2018-01-21 16:06SprowNote Added: 0001717
2018-01-21 16:06SprowStatusfeedback => new
2018-01-21 17:28John-Mark BellNote Added: 0001719
2018-01-21 17:38John-Mark BellNote Added: 0001720
2018-01-21 17:42John-Mark BellStatusnew => feedback
2018-01-21 19:29John-Mark BellNote Added: 0001723
2018-01-21 21:21SprowNote Added: 0001724
2018-01-21 21:21SprowStatusfeedback => new
2018-01-22 01:02John-Mark BellNote Added: 0001726
2018-01-22 08:41SprowNote Added: 0001728
2018-01-22 10:32John-Mark BellStatusnew => resolved
2018-01-22 10:32John-Mark BellResolutionopen => fixed
2018-01-22 10:32John-Mark BellFixed in Version => 3.8
2018-01-22 10:32John-Mark BellTarget Version => 3.8
2018-01-22 10:32John-Mark BellFixed in CI build # => 4305
2018-08-29 15:00Vincent SandersStatusresolved => closed
2018-08-29 15:00Vincent SandersNote Added: 0001831