private static void CreateIcon(IconSet set, XElement root, XElement glyph) { XElement path = glyph.Descendants(XName.Get("path", SvgNs)).First(); string name = glyph.Attribute(XName.Get("id")).Value; string pathData = path.Attribute(XName.Get("d")).Value; Icon icon = new Icon(); icon.Id = set.Icons.Count; icon.Tags = new[] { name }; icon.Paths = new[] { pathData }; IconSelection selection = new IconSelection(); selection.Order = icon.Id; selection.Id = icon.Id; selection.PrevSize = 32; selection.Code = GetCodeForIcon(name); selection.TempChar = "" + ((char)selection.Code); selection.Ligatures = ""; set.Icons.Add(icon); set.Selection.Add(selection); }
private static IconSet CreateIconSet(string inputSvg) { IconSet set = new IconSet(); set.Id = 0; set.Metadata.Name = "alphaTab MusicFont"; set.Metadata.Url = "http://www.alphatab.net"; set.Metadata.Designer = ""; set.Metadata.DesignerUrl = ""; set.Metadata.License = ""; set.Metadata.LicenseUrl = ""; set.Height = 1024; set.PrevSize = 32; XDocument document = XDocument.Load(inputSvg); XElement root = document.Root; SvgNs = root.GetNamespaceOfPrefix("svg").NamespaceName; InkscapeNs = root.GetNamespaceOfPrefix("inkscape").NamespaceName; var glyphs = root.Elements(XName.Get("g", SvgNs)) .Where(g => g.Attribute(XName.Get("groupmode", InkscapeNs)).Value == "layer"); foreach (var glyph in glyphs) { CreateIcon(set, document.Root, glyph); } return set; }
private static IconSet CreateIconSet(string inputSvg) { IconSet set = new IconSet(); set.Id = 0; set.Metadata.Name = "alphaTab MusicFont"; set.Metadata.Url = "http://www.alphatab.net"; set.Metadata.Designer = ""; set.Metadata.DesignerUrl = ""; set.Metadata.License = ""; set.Metadata.LicenseUrl = ""; set.Height = 1024; set.PrevSize = 32; XDocument document = XDocument.Load(inputSvg); XElement root = document.Root; SvgNs = root.GetNamespaceOfPrefix("svg").NamespaceName; InkscapeNs = root.GetNamespaceOfPrefix("inkscape").NamespaceName; var glyphs = root.Elements(XName.Get("g", SvgNs)) .Where(g => g.Attribute(XName.Get("groupmode", InkscapeNs)).Value == "layer"); foreach (var glyph in glyphs) { CreateIcon(set, document.Root, glyph); } return(set); }