c# - Cannot load a spriteFont in XNA4 -
im goofing around xna , i've come part need load font in. easy enough right?
font1 = content.load<spritefont>("arial");
is code i'm using load font.
<?xml version="1.0" encoding="utf-8"?> <!-- file contains xml description of font, , read xna framework content pipeline. follow comments customize appearance of font in game, , change characters available draw with. --> <xnacontent xmlns:graphics="microsoft.xna.framework.content.pipeline.graphics"> <asset type="graphics:fontdescription"> <!-- modify string change font imported. --> <fontname>arial</fontname> <!-- size float value, measured in points. modify value change size of font. --> <size>14</size> <!-- spacing float value, measured in pixels. modify value change amount of spacing in between characters. --> <spacing>0</spacing> <!-- usekerning controls layout of font. if value true, kerning information used when placing characters. --> <usekerning>true</usekerning> <!-- style controls style of font. valid entries "regular", "bold", "italic", , "bold, italic", , case sensitive. --> <style>regular</style> <!-- if uncomment line, default character substituted if draw or measure text contains characters not included in font. --> <!-- <defaultcharacter>*</defaultcharacter> --> <!-- characterregions control letters available in font. every character start end built , made available drawing. default range 32, (ascii space), 126, ('~'), covering basic latin character set. characters ordered according unicode standard. see documentation more information. --> <characterregions> <characterregion> <start> </start> <end>~</end> </characterregion> </characterregions> </asset> </xnacontent>
is spritefont file im using. located @ content/arial.spritefont.
regardless of font choose, unable load font.
error loading "arial". file not found.
the code have posted appears fine, providing setting content root directory (this line part of default template):
content.rootdirectory = "content";
and providing have correctly added .spritefont
file content project , building correctly. check arial.xnb
file being created in content
directory beside executable (in bin/debug
or bin/release
depending on build target).
if still have problems, try creating fresh xna project , seeing if can font work in that.
Comments
Post a Comment