cart: empty [ Login ]

Remove default font resolvers

1 2  next > 
Chris Smith
2/14/2022 12:01 PM
Hi Wout &c, We're seeing a lot of our render time is taken up by calls to FontFromDirectoryFileLoader.Exists but I'm not sure why it's being called. When we initialise our wrapper around CadLib, we run the following to try to remove all the built in font resolvers:
C# Code:
DxfModel.GlobalShxFontFileLoaders.Clear(); DxfModel.ClearShxFontFileLoaders(); DxfModel.AddShxFontFileLoaders(new[] { new FontResolver(this.Logging, this.fontPaths) });
Here, FontResolver is our own class that only checks specific directories and caches the results statically. But I can still see FontFromDirectoryFileLoader.Exists being called in our profiler sessions (see attached picture). Is there anything further we can do to prevent the calls to FontFromDirectoryFileLoader? Cheers, Chris
fontresolvers.png
Wout
2/14/2022 12:14 PM
Hi, DxfModel.ClearShxFontFileLoaders() should remove all of them if you don't want them. - Wout
Chris Smith
2/14/2022 12:16 PM
Thanks Wout - we still seem to be seeing it called tho even after calling that method...
Wout
2/14/2022 12:16 PM
Hmm, the current directory is always searched for fonts it seems. - Wout
Chris Smith
2/14/2022 12:17 PM
Ah 😟 Is there any way to have it cache the results or something? so we don't keep seeing the calls to Exists?
Chris Smith
2/14/2022 12:23 PM
or maybe is there a way to pre-load the font onto the DxfText/DxfAttribute object so it doesn't need to go looking?
Wout
2/14/2022 12:34 PM
At the moment if the font was not found, it will keep looking afterwards. I can change it to cache the lookup result and reuse it so it doesn't keep looking. - Wout
Chris Smith
2/14/2022 12:38 PM
Ah great! So sounds like this is probably a case where our own font resolver didn't find anything - maybe we can just return our own default in that case also?
Wout
2/14/2022 1:07 PM
I've uploaded a new 4.0 version that remembers the SHX font lookup result. - Wout
Chris Smith
2/14/2022 1:11 PM
Thanks Wout - that's awesome! will check it out
1 2  next >