diff --git a/src/Cyotek.Drawing.BitmapFont/BitmapFontLoader.cs b/src/Cyotek.Drawing.BitmapFont/BitmapFontLoader.cs
index ef354b9..92f184d 100644
--- a/src/Cyotek.Drawing.BitmapFont/BitmapFontLoader.cs
+++ b/src/Cyotek.Drawing.BitmapFont/BitmapFontLoader.cs
@@ -145,10 +145,23 @@ public static BitmapFont LoadFontFromXmlFile(string fileName)
///
/// The array of parts.
/// The name of the value to return.
+ /// Default value(if the key doesnt exist or can't be parsed)
///
- internal static bool GetNamedBool(string[] parts, string name)
+ internal static bool GetNamedBool(string[] parts, string name, bool defaultValue = false)
{
- return GetNamedInt(parts, name) != 0;
+ var s = GetNamedString(parts, name);
+
+ bool result;
+ int v;
+ if (int.TryParse(s, out v))
+ {
+ result = v > 0;
+ } else
+ {
+ result = defaultValue;
+ }
+
+ return result;
}
///
@@ -156,10 +169,19 @@ internal static bool GetNamedBool(string[] parts, string name)
///
/// The array of parts.
/// The name of the value to return.
+ /// Default value(if the key doesnt exist or can't be parsed)
///
- internal static int GetNamedInt(string[] parts, string name)
+ internal static int GetNamedInt(string[] parts, string name, int defaultValue = 0)
{
- return Convert.ToInt32(GetNamedString(parts, name));
+ var s = GetNamedString(parts, name);
+
+ int result;
+ if (!int.TryParse(s, out result))
+ {
+ result = defaultValue;
+ }
+
+ return result;
}
///