Exemplo n.º 1
0
        /// <inheritdoc />
        public override FIGfont LoadFont()
        {
            var font = FIGfont.FromEmbeddedResource(_resourceName, _siblingType);

            font.Name = base.Name;
            return(font);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <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)));
            }
        }
Exemplo n.º 5
0
 /// <inheritdoc />
 public override FIGfont LoadFont()
 {
     return(FIGfont.FromEmbeddedResource(_resourceName, _siblingType));
 }
Exemplo n.º 6
0
 /// <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;
 }