mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-15 15:09:29 +00:00
Resolves ArgmentNulLException When Loading BitmapFont From Disk. (#924)
* Correctly swap rayNear and rayFar distance * Retrieve bmfFile.Path when reading from stream This closes #923 * Return null if character not found. This is used for line feed characters.S
This commit is contained in:
committed by
GitHub
parent
f1fbf9c4b8
commit
3ca0a3ef2a
@@ -38,7 +38,7 @@ public sealed class BitmapFont
|
||||
}
|
||||
}
|
||||
|
||||
public BitmapFontCharacter GetCharacter(int character) => _characters[character];
|
||||
public BitmapFontCharacter GetCharacter(int character) => _characters.TryGetValue(character, out BitmapFontCharacter fontCharacter) ? fontCharacter : null;/* _characters[character];*/
|
||||
public bool TryGetCharacter(int character, out BitmapFontCharacter value) => _characters.TryGetValue(character, out value);
|
||||
|
||||
public SizeF MeasureString(string text)
|
||||
@@ -378,7 +378,7 @@ public sealed class BitmapFont
|
||||
{
|
||||
if (!pages.ContainsKey(bmfFile.Pages[i]))
|
||||
{
|
||||
string texturePath = Path.Combine(bmfFile.Path, bmfFile.Pages[i]);
|
||||
string texturePath = Path.Combine(Path.GetDirectoryName(bmfFile.Path), bmfFile.Pages[i]);
|
||||
using (Stream textureStream = File.OpenRead(texturePath))
|
||||
{
|
||||
Texture2D texture = Texture2D.FromStream(graphicsDevice, textureStream);
|
||||
|
||||
@@ -60,6 +60,8 @@ public static class BitmapFontFileReader
|
||||
_ => throw new InvalidOperationException("This does not appear to be a valid BMFont file!")
|
||||
};
|
||||
|
||||
bmfFile.Path = stream.Name;
|
||||
|
||||
return bmfFile;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user