/// <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); } }
private IEnumerable <FontFamily> InstallCollectionInternal(Stream fontCollectionStream, CultureInfo culture, out IEnumerable <FontDescription> fontDescriptions) { long startPos = fontCollectionStream.Position; var reader = new BinaryReader(fontCollectionStream, true); var ttcHeader = TtcHeader.Read(reader); var result = new List <FontDescription>((int)ttcHeader.NumFonts); var installedFamilies = new HashSet <FontFamily>(); for (int i = 0; i < ttcHeader.NumFonts; ++i) { fontCollectionStream.Position = startPos + ttcHeader.OffsetTable[i]; var instance = FontInstance.LoadFont(fontCollectionStream); installedFamilies.Add(this.Install(instance, culture)); FontDescription fontDescription = instance.Description; result.Add(fontDescription); } fontDescriptions = result; return(installedFamilies); }
internal FileFontInstance(FontDescription description, string path, long offset) { this.Description = description; this.Path = path; this.font = new Lazy <Fonts.IFontInstance>(() => FontInstance.LoadFont(path, offset)); }
public FileFontInstance(string path, long offset) : this(FontDescription.LoadDescription(path), path, offset) { }
/// <summary> /// Installs the specified font stream. /// </summary> /// <param name="fontStream">The font stream.</param> /// <param name="fontDescription">The font description of the installed font.</param> /// <returns>the description of the font just loaded.</returns> public FontFamily Install(Stream fontStream, out FontDescription fontDescription) => this.InstallInternal(fontStream, CultureInfo.InvariantCulture, out fontDescription);
/// <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) => this.InstallInternal(path, CultureInfo.CurrentCulture, out fontDescription);
public FileFontInstance(string path) { this.Description = FontDescription.LoadDescription(path); this.font = new Lazy <Fonts.FontInstance>(() => FontInstance.LoadFont(path)); }
internal FileFontMetrics(FontDescription description, string path, long offset) { this.Description = description; this.Path = path; this.metrics = new Lazy <StreamFontMetrics>(() => StreamFontMetrics.LoadFont(path, offset)); }
public FileFontMetrics(string path, long offset) : this(FontDescription.LoadDescription(path), path, offset) { }