/// <summary>
    /// Loads the fonts from a file.
    /// </summary>
    /// <param name="strFilename">The filename from where the fonts are loaded.</param>
    /// <returns>true if loaded else false</returns>
    public static bool LoadFonts(string strFilename)
    {
      // Clear current set of fonts
      Dispose();
      lock (Renderlock)
      {
        int counter = 0;
        Log.Info("  Load fonts from {0}", strFilename);
        _listFonts.DisposeAndClear();

        // Load the debug font
        GUIFont fontDebug = new GUIFont("debug", "Arial", 12);
        fontDebug.ID = counter++;
        fontDebug.Load();
        _listFonts.Add(fontDebug);

        try
        {
          // Load the XML document
          XmlDocument doc = new XmlDocument();
          doc.Load(strFilename);
          // Check the root element
          if (doc.DocumentElement == null)
          {
            return false;
          }
          string strRoot = doc.DocumentElement.Name;
          if (strRoot != "fonts")
          {
            return false;
          }
          // Select the list of fonts
          XmlNodeList list = doc.DocumentElement.SelectNodes("/fonts/font");
          foreach (XmlNode node in list)
          {
            XmlNode nodeStart = node.SelectSingleNodeFast("startchar");
            XmlNode nodeEnd = node.SelectSingleNodeFast("endchar");
            XmlNode nodeName = node.SelectSingleNodeFast("name");
            XmlNode nodeFileName = node.SelectSingleNodeFast("filename");
            XmlNode nodeHeight = node.SelectSingleNodeFast("height");
            XmlNode nodeBold = node.SelectSingleNodeFast("bold");
            XmlNode nodeItalics = node.SelectSingleNodeFast("italic");
            if (nodeHeight != null && nodeName != null && nodeFileName != null)
            {
              bool bold = false;
              bool italic = false;
              if (nodeBold != null && nodeBold.InnerText != null && nodeBold.InnerText.Equals("yes"))
              {
                bold = true;
              }
              if (nodeItalics != null && nodeItalics.InnerText != null && nodeItalics.InnerText.Equals("yes"))
              {
                italic = true;
              }
              string strName = nodeName.InnerText;
              string strFileName = nodeFileName.InnerText;
              int iHeight = Int32.Parse(nodeHeight.InnerText);

              // height is based on 720x576
              float fPercent = (((float)GUIGraphicsContext.Height) * GUIGraphicsContext.ZoomVertical) / 576.0f;
              fPercent *= iHeight;
              iHeight = (int)fPercent;
              FontStyle style = new FontStyle();
              style = FontStyle.Regular;
              if (bold)
              {
                style |= FontStyle.Bold;
              }
              if (italic)
              {
                style |= FontStyle.Italic;
              }
              GUIFont font = new GUIFont(strName, strFileName, iHeight, style);
              font.ID = counter++;

              // .NET's LocalisationProvider should give the correct amount of chars.
              if (nodeStart != null && nodeStart.InnerText != "" && nodeEnd != null && nodeEnd.InnerText != "")
              {
                int start = Int32.Parse(nodeStart.InnerText);
                int end = Int32.Parse(nodeEnd.InnerText);
                font.SetRange(start, end);
              }
              else
              {
                font.SetRange(0, GUIGraphicsContext.CharsInCharacterSet);
              }

              font.Load();
              _listFonts.Add(font);
            }
          }

          // Select the list of aliases
          XmlNodeList listAlias = doc.DocumentElement.SelectNodes("/fonts/alias");
          foreach (XmlNode node in listAlias)
          {
            XmlNode nodeName = node.SelectSingleNodeFast("name");
            XmlNode nodeFontName = node.SelectSingleNodeFast("fontname");
            _dictFontAlias.Add(nodeName.InnerText, nodeFontName.InnerText);
          }

          return true;
        }
        catch (Exception ex)
        {
          Log.Info("GUIFontManager: Exception loading fonts {0} err:{1} stack:{2}", strFilename, ex.Message,
                   ex.StackTrace);
        }

        return false;
      }
    }
    /// <summary>
    /// Loads the fonts from a file.
    /// </summary>
    /// <param name="strFilename">The filename from where the fonts are loaded.</param>
    /// <returns>true if loaded else false</returns>
    public static bool LoadFonts(string strFilename)
    {
      // Clear current set of fonts
      Dispose();
      lock (Renderlock)
      {
        int counter = 0;
        Log.Info("Load fonts from: {0}", strFilename);
        ListFonts.DisposeAndClear();

        // Load the debug font
        var fontDebug = new GUIFont("debug", "Arial", 12) {ID = counter++};
        fontDebug.Load();
        ListFonts.Add(fontDebug);

        try
        {
          // Load the XML document
          var doc = new XmlDocument();
          doc.Load(strFilename);
          // Check the root element
          if (doc.DocumentElement == null)
          {
            return false;
          }
          string strRoot = doc.DocumentElement.Name;
          if (strRoot != "fonts")
          {
            return false;
          }
          // Select the list of fonts
          XmlNodeList list = doc.DocumentElement.SelectNodes("/fonts/font");
          if (list != null)
          {
            foreach (XmlNode node in list)
            {
              XmlNode nodeStart = node.SelectSingleNodeFast("startchar");
              XmlNode nodeEnd = node.SelectSingleNodeFast("endchar");
              XmlNode nodeName = node.SelectSingleNodeFast("name");
              XmlNode nodeFileName = node.SelectSingleNodeFast("filename");
              XmlNode nodeHeight = node.SelectSingleNodeFast("height");
              XmlNode nodeBold = node.SelectSingleNodeFast("bold");
              XmlNode nodeItalics = node.SelectSingleNodeFast("italic");
              if (nodeHeight != null && nodeName != null && nodeFileName != null)
              {
                bool bold = false;
                bool italic = false;
                if (nodeBold != null && nodeBold.InnerText.Equals("yes"))
                {
                  bold = true;
                }
                if (nodeItalics != null && nodeItalics.InnerText.Equals("yes"))
                {
                  italic = true;
                }
                string strName = nodeName.InnerText;
                string strFileName = nodeFileName.InnerText;
                int iHeight = Int32.Parse(nodeHeight.InnerText);

                // font height is based on legacy hard coded resolution of 720x576
                float baseSize = 576;

                // adjust for different DPI settings (96dpi = 100%)
                using (Graphics graphics = GUIGraphicsContext.form.CreateGraphics())
                {
                  // With DPIAware setting baseSize need to be kept
                  if (Environment.OSVersion.Version.Major >= 6 && graphics.DpiY != 96.0)
                  {
                    baseSize *= graphics.DpiY/96;
                  }
                }

                float fPercent = (GUIGraphicsContext.Height * GUIGraphicsContext.ZoomVertical) / baseSize;
                fPercent *= iHeight;
                iHeight = (int)fPercent;
                var style = FontStyle.Regular;
                if (bold)
                {
                  style |= FontStyle.Bold;
                }
                if (italic)
                {
                  style |= FontStyle.Italic;
                }
                var font = new GUIFont(strName, strFileName, iHeight, style) {ID = counter++};

                // .NET's LocalisationProvider should give the correct amount of chars.
                if (nodeStart != null && nodeStart.InnerText != "" && nodeEnd != null && nodeEnd.InnerText != "")
                {
                  int start = Int32.Parse(nodeStart.InnerText);
                  int end = Int32.Parse(nodeEnd.InnerText);
                  font.SetRange(start, end);
                }
                else
                {
                  font.SetRange(0, GUIGraphicsContext.CharsInCharacterSet);
                }

                font.Load();
                ListFonts.Add(font);
              }
            }
          }

          // Select the list of aliases
          DictFontAlias.Clear();
          XmlNodeList listAlias = doc.DocumentElement.SelectNodes("/fonts/alias");
          if (listAlias != null)
          {
            foreach (XmlNode node in listAlias)
            {
              XmlNode nodeName = node.SelectSingleNodeFast("name");
              XmlNode nodeFontName = node.SelectSingleNodeFast("fontname");
              DictFontAlias.Add(nodeName.InnerText, nodeFontName.InnerText);
            }
          }
          return true;
        }
        catch (Exception ex)
        {
          Log.Warn("GUIFontManager: Exception loading fonts {0} err:{1} stack:{2}", strFilename, ex.Message, ex.StackTrace);
        }

        return false;
      }
    }