/// <summary> /// Parses the specified directory for fonts. /// </summary> /// <param name="directory">The directory.</param> /// <param name="recurse">if set to <c>true</c> recurse.</param> /// <returns></returns> public static IEnumerable <FIGfontReference> Parse(string directory, bool recurse) { var entriesInDirectory = from e in Directory.GetFiles(directory) where FIGfont.CanHandleExtension(e) select new FileFIGfontReference(e, Path.GetFileNameWithoutExtension(e)) as FIGfontReference; if (recurse) { entriesInDirectory = entriesInDirectory.Concat(Directory.GetDirectories(directory).SelectMany(d => Parse(d, true))); } return(entriesInDirectory); }
/// <summary> /// Parses an assembly for fonts related to a sibling type. /// Type and embedded resources must be in the same project folder for this to work. /// </summary> /// <param name="siblingType">Type of the sibling.</param> /// <returns></returns> public static IEnumerable <FIGfontReference> Parse(Type siblingType) { var prefix = siblingType.Namespace + "."; foreach (var resourcePath in siblingType.Assembly.GetManifestResourceNames()) { if (!resourcePath.StartsWith(prefix)) { continue; } var resourceName = resourcePath.Substring(prefix.Length); if (!FIGfont.CanHandleExtension(resourceName)) { continue; } yield return(new EmbeddedFIGfontReference(resourceName, siblingType, Path.GetFileNameWithoutExtension(resourceName))); } }