/// <inheritdoc /> public override FIGfont LoadFont() { var font = FIGfont.FromEmbeddedResource(_resourceName, _siblingType); font.Name = base.Name; return(font); }
/// <summary> /// Reads a <see cref="FIGfont"/> from an open <see cref="Stream"/>. /// </summary> /// <param name="stream">The stream.</param> /// <returns></returns> public static FIGfont FromStream(Stream stream) { var figFont = new FIGfont(); figFont.Read(stream); return(figFont); }
/// <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))); } }
/// <inheritdoc /> public override FIGfont LoadFont() { return(FIGfont.FromEmbeddedResource(_resourceName, _siblingType)); }
/// <summary> /// Initializes a new instance of the <see cref="FIGdriver"/> class. /// </summary> /// <param name="font">The font (optional, it may be added later).</param> /// <param name="createDrawingElement">It allows to create <see cref="DrawingElement"/> from external delegate. /// When this parameter is specified, the method <see cref="CreateDrawingElement"/> is not invoked.</param> public FIGdriver(FIGfont font = null, Func <FIGcharacter, char, DrawingElement> createDrawingElement = null) { _createDrawingElement = createDrawingElement; Font = font; }