Skip to content

.spritefont file not loaded #707

@totallyevil

Description

@totallyevil

ANDROID

ContentManager.Load(@"fonts/" + fontName);

fontName = "Arial"

In Assets/Content/fonts there exists "Arial.spritefont"

MG3D content manager does not load the spritefont.

If I use the XNB file from the WP7 project (Arial.xnb) placed in the exact same location, then MG3D can load the spritefont.

I posted this problem before. The solution then was to use the XNB copy of the asset (happens for some other content types).

The problem is line 290 of ContentManager.cs:

result = ReadRawAsset(assetName, originalAssetName);

This method (ReadRawAsset) throws NotImplementedException for type "SpriteFont". This means you can ONLY use XNB files for your spritefonts.

ContentManager.cs line 359:

        else if ((typeof(T) == typeof(SpriteFont)))
        {
            //result = new SpriteFont(Texture2D.FromFile(graphicsDeviceService.GraphicsDevice,assetName), null, null, null, 0, 0.0f, null, null);
            throw new NotImplementedException();
        }

It is not obvious to me why the XNB path is different than the spritefont path. Why not just use the ContentReader.ReadAsset like the XNB path is using, when processing the ReadRawAsset in ContentManager?

           ContentReader reader = new ContentReader(this, SpriteFontResourceAsAMemoryBuffer, this.graphicsDeviceService.GraphicsDevice,
                                                        mySpriteFontName, 5, null);

Yes, I did try this myself and have had no luck yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions