Runtime errors with custom fonts


#1

Hey there,
I was trying to use some fonts from Mozilla’s Fira and happened to get errors during runtime - the moment I opened the game.

The following fonts were used:

  • Fira Ultra-Light
  • Fira Light
  • Fira Regular
  • Fira Mono Regular
  • Fira Mono Medium
  • Fira Mono Bold

In the editor, all of them have shown an exclamation mark with red background:

The errors I was given were:

[Game]: Error: Unexpected exception. Xenko.Core.Serialization.Contents.ContentManagerException: Unexpected exception while loading asset [Fonts/Fira Mono Bold]. Reason: FreeType error: Invalid stream operation.. Check inner-exception for details. ---> SharpFont.FreeTypeException: FreeType error: Invalid stream operation.
   at SharpFont.Face..ctor(Library library, Byte[] file, Int32 faceIndex)
   at SharpFont.Library.NewMemoryFace(Byte[] file, Int32 faceIndex)
   at Xenko.Graphics.Font.FontManager.LoadFontInMemory(String fontPath)
   at Xenko.Graphics.Font.FontManager.GetOrCreateFontFace(String fontFamily, FontStyle fontStyle)
   at Xenko.Graphics.Font.FontManager.GetFontInfo(String fontFamily, FontStyle fontStyle, Single& lineSpacing, Single& baseLine, Single& maxWidth, Single& maxHeight)
   at Xenko.Graphics.Font.RuntimeRasterizedSpriteFont.set_FontSystem(FontSystem value)
   at Xenko.Graphics.Font.RuntimeRasterizedSpriteFontSerializer.Serialize(RuntimeRasterizedSpriteFont& font, ArchiveMode mode, SerializationStream stream)
   at Xenko.Core.Serialization.MemberReuseSerializer`1.SerializeExtended(T& obj, ArchiveMode mode, SerializationStream stream, DataSerializer`1 dataSerializer)
   at Xenko.Core.Serialization.Contents.DataContentSerializerHelper`1.Serialize(ContentSerializerContext context, SerializationStream stream, T obj)
   at Xenko.Core.Serialization.Contents.ContentManager.DeserializeObject(Queue`1 serializeOperations, Reference parentReference, String url, Type objType, Object obj, ContentManagerLoaderSettings settings)
   --- End of inner exception stack trace ---
   at Xenko.Core.Serialization.Contents.ContentManager.DeserializeObject(Queue`1 serializeOperations, Reference parentReference, String url, Type objType, Object obj, ContentManagerLoaderSettings settings)
   at Xenko.Core.Serialization.Contents.ContentManager.DeserializeObject(String initialUrl, String newUrl, Type type, Object obj, ContentManagerLoaderSettings settings)
   at Xenko.Core.Serialization.Contents.ContentManager.Load(Type type, String url, ContentManagerLoaderSettings settings)
   at Xenko.Core.Serialization.Contents.ContentManager.Load[T](String url, ContentManagerLoaderSettings settings)
   at Xenko.Engine.SceneSystem.LoadContent()
   at Xenko.Games.GameSystemCollection.LoadContent()
   at Xenko.Engine.Game.LoadContentInternal()
   at Xenko.Games.GameBase.InitializeBeforeRun()
Xenko.Core.Serialization.Contents.ContentManagerException: Unexpected exception while loading asset [Fonts/Fira Mono Bold]. Reason: FreeType error: Invalid stream operation.. Check inner-exception for details. ---> SharpFont.FreeTypeException: FreeType error: Invalid stream operation.
   at SharpFont.Face..ctor(Library library, Byte[] file, Int32 faceIndex)
   at SharpFont.Library.NewMemoryFace(Byte[] file, Int32 faceIndex)
   at Xenko.Graphics.Font.FontManager.LoadFontInMemory(String fontPath)
   at Xenko.Graphics.Font.FontManager.GetOrCreateFontFace(String fontFamily, FontStyle fontStyle)
   at Xenko.Graphics.Font.FontManager.GetFontInfo(String fontFamily, FontStyle fontStyle, Single& lineSpacing, Single& baseLine, Single& maxWidth, Single& maxHeight)
   at Xenko.Graphics.Font.RuntimeRasterizedSpriteFont.set_FontSystem(FontSystem value)
   at Xenko.Graphics.Font.RuntimeRasterizedSpriteFontSerializer.Serialize(RuntimeRasterizedSpriteFont& font, ArchiveMode mode, SerializationStream stream)
   at Xenko.Core.Serialization.MemberReuseSerializer`1.SerializeExtended(T& obj, ArchiveMode mode, SerializationStream stream, DataSerializer`1 dataSerializer)
   at Xenko.Core.Serialization.Contents.DataContentSerializerHelper`1.Serialize(ContentSerializerContext context, SerializationStream stream, T obj)
   at Xenko.Core.Serialization.Contents.ContentManager.DeserializeObject(Queue`1 serializeOperations, Reference parentReference, String url, Type objType, Object obj, ContentManagerLoaderSettings settings)
   --- End of inner exception stack trace ---
   at Xenko.Core.Serialization.Contents.ContentManager.DeserializeObject(Queue`1 serializeOperations, Reference parentReference, String url, Type objType, Object obj, ContentManagerLoaderSettings settings)
   at Xenko.Core.Serialization.Contents.ContentManager.DeserializeObject(String initialUrl, String newUrl, Type type, Object obj, ContentManagerLoaderSettings settings)
   at Xenko.Core.Serialization.Contents.ContentManager.Load(Type type, String url, ContentManagerLoaderSettings settings)
   at Xenko.Core.Serialization.Contents.ContentManager.Load[T](String url, ContentManagerLoaderSettings settings)
   at Xenko.Engine.SceneSystem.LoadContent()
   at Xenko.Games.GameSystemCollection.LoadContent()
   at Xenko.Engine.Game.LoadContentInternal()
   at Xenko.Games.GameBase.InitializeBeforeRun()