Пример #1
0
        private FontFamily InstallInternal(string path, CultureInfo culture, out FontDescription fontDescription)
        {
            var instance = new FileFontInstance(path);

            fontDescription = instance.Description;
            return(this.Install(instance, culture));
        }
Пример #2
0
        /// <summary>
        /// Installs a font from the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="fontDescription">The font description of the installed font.</param>
        /// <returns>the description of the font just loaded.</returns>
        public FontFamily Install(string path, out FontDescription fontDescription)
        {
            var instance = new FileFontInstance(path);

            fontDescription = instance.Description;
            return(this.Install(instance));
        }
Пример #3
0
        private IEnumerable <FontFamily> InstallCollectionInternal(string fontCollectionPath, CultureInfo culture, out IEnumerable <FontDescription> fontDescriptions)
        {
            FileFontInstance[] fonts = FileFontInstance.LoadFontCollection(fontCollectionPath);

            var description = new FontDescription[fonts.Length];
            var families    = new HashSet <FontFamily>();

            for (int i = 0; i < fonts.Length; i++)
            {
                description[i] = fonts[i].Description;
                FontFamily family = this.Install(fonts[i], culture);
                families.Add(family);
            }

            fontDescriptions = description;
            return(families);
        }
Пример #4
0
        /// <summary>
        /// Reads a <see cref="FontInstance"/> from the specified stream.
        /// </summary>
        /// <param name="path">The file path.</param>
        /// <returns>a <see cref="FontInstance"/>.</returns>
        public static FileFontInstance[] LoadFontCollection(string path)
        {
            using (FileStream fs = File.OpenRead(path))
            {
                long startPos  = fs.Position;
                var  reader    = new BinaryReader(fs, true);
                var  ttcHeader = TtcHeader.Read(reader);
                var  fonts     = new FileFontInstance[(int)ttcHeader.NumFonts];

                for (int i = 0; i < ttcHeader.NumFonts; ++i)
                {
                    fs.Position = startPos + ttcHeader.OffsetTable[i];
                    var description = FontDescription.LoadDescription(fs);
                    fonts[i] = new FileFontInstance(description, path, (long)ttcHeader.OffsetTable[i]);
                }

                return(fonts);
            }
        }