Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i am fix call FontLoaderCallback add commit #528

Closed
CSerX opened this issue Jul 25, 2019 · 5 comments
Closed

i am fix call FontLoaderCallback add commit #528

CSerX opened this issue Jul 25, 2019 · 5 comments

Comments

@CSerX
Copy link

CSerX commented Jul 25, 2019

Never called FontLoaderCallback, i am fix it. I use this function to load self fonts.

Source/SvgFontManager.cs
@@ -50,10 +50,10 @@
         {
             if (name == null) return null;
             FontFamily ff = null;
-            if (SystemFonts.TryGetValue(name.ToLower(), out ff)) return ff;
+            if (SystemFonts.TryGetValue(name.ToLower(), out ff) && ff != null) return ff;
             if (FontLoaderCallback == null) return null;
             var ff2 = FontLoaderCallback(name);
-            SystemFonts.Add(name.ToLower(), ff2);
+            if (ff2 != null) SystemFonts.Add(name.ToLower(), ff2);
             return ff2;
         }
     }
@mrbean-bremen
Copy link
Member

mrbean-bremen commented Jul 25, 2019

Thanks - the diff had been garbled by the formatting, so I didn't understand this first...
Though I don't understand the change yet.

  if (SystemFonts.TryGetValue(name.ToLower(), out ff)) return ff;

This returns only, if a font was found - so the second check for ff is not needed, as far as I can see.
The second check to avoid adding a null font makes sense to me, but I still don't understand why FontLoaderCallback was not called in the first place.

@CSerX
Copy link
Author

CSerX commented Jul 26, 2019

I don't know why, result is true and ff is null.
And if FontLoaderCallback return null then it can't be added to SystemFonts.

@mrbean-bremen
Copy link
Member

Sorry for the delay!
Strange... I would really like to understand what is going on here before adding this - maybe there is a bug elsewhere. Can you check the value of SystemFonts before that call? Can it be that somehow there is a null as value in the dictionary?

@CSerX
Copy link
Author

CSerX commented Jul 31, 2019

Sorry, i am undestend. First check not needed, second is required. Beсause FontLoaderCallback can return null, after this dictionary contains null :) (i am debug after first execution)

@mrbean-bremen
Copy link
Member

Ok, thanks - that makes sense then! I'll add the second check in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants