VectSharp  2.2.1
A light library for C# vector graphics
FontLibrary.cs
1 /*
2  VectSharp - A light library for C# vector graphics.
3  Copyright (C) 2020-2022 Giorgio Bianchini
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, version 3.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 using System;
19 using System.Collections.Generic;
20 using System.Text;
21 using System.Linq;
22 using System.IO;
23 
24 namespace VectSharp
25 {
26  /// <summary>
27  /// Represents a font library with methods to create <see cref="FontFamily"/> objects from a string or from <see cref="FontFamily.StandardFontFamilies"/>.
28  /// </summary>
29  public interface IFontLibrary
30  {
31  /// <summary>
32  /// Create a new font family from the specified family name or true type file. If the family name or the true type file are not valid, an exception might be raised.
33  /// </summary>
34  /// <param name="fontFamily">The name of the font family to create, or the path to a TTF file.</param>
35  /// <returns>If the font family name or the true type file is valid, a <see cref="FontFamily"/> object corresponding to the specified font family.</returns>
36  FontFamily ResolveFontFamily(string fontFamily);
37 
38  /// <summary>
39  /// Create a new font family from the specified family name or true type file. If the family name or the true type file are not valid, try to instantiate the font family using
40  /// the <paramref name="fallback"/>. If none of the fallback family names or true type files are valid, an exception might be raised.
41  /// </summary>
42  /// <param name="fontFamily">The name of the font family to create, or the path to a TTF file.</param>
43  /// <param name="fallback">Names of additional font families or TTF files, which will be tried if the first <paramref name="fontFamily"/> is not valid.</param>
44  /// <returns>A <see cref="FontFamily"/> object corresponding to the first of the specified font families that is valid.</returns>
45  FontFamily ResolveFontFamily(string fontFamily, params string[] fallback);
46 
47  /// <summary>
48  /// Create a new font family from the specified standard font family name.
49  /// </summary>
50  /// <param name="standardFontFamily">The standard name of the font family.</param>
51  /// <returns>A <see cref="FontFamily"/> object corresponding to the specified font family.</returns>
53 
54  /// <summary>
55  /// Create a new font family from the specified family name or true type file. If the family name or the true type file are not valid, try to instantiate the font family using
56  /// the <paramref name="fallback"/>. If none of the fallback family names or true type files are valid, instantiate a standard font family using the <paramref name="finalFallback"/>.
57  /// </summary>
58  /// <param name="fontFamily">The name of the font family to create, or the path to a TTF file.</param>
59  /// <param name="fallback">Names of additional font families or TTF files, which will be tried if the first <paramref name="fontFamily"/> is not valid.</param>
60  /// <param name="finalFallback">The standard name of the font family that will be used if none of the fallback families are valid.</param>
61  /// <returns>A <see cref="FontFamily"/> object corresponding to the first of the specified font families that is valid.</returns>
62  FontFamily ResolveFontFamily(string fontFamily, FontFamily.StandardFontFamilies finalFallback, params string[] fallback);
63  }
64 
65  /// <summary>
66  /// Abstract class with a default implementation of font family fallbacks.
67  /// </summary>
68  public abstract class FontLibrary : IFontLibrary
69  {
70  /// <inheritdoc/>
71  public abstract FontFamily ResolveFontFamily(string fontFamily);
72 
73  /// <inheritdoc/>
74  public abstract FontFamily ResolveFontFamily(FontFamily.StandardFontFamilies standardFontFamily);
75 
76  /// <inheritdoc/>
77  public virtual FontFamily ResolveFontFamily(string fontFamily, params string[] fallback)
78  {
79  bool found = false;
80 
81  FontFamily tbr = null;
82 
83  try
84  {
85  tbr = ResolveFontFamily(fontFamily);
86  if (tbr.TrueTypeFile != null)
87  {
88  found = true;
89  }
90  }
91  catch
92  {
93  tbr = null;
94  found = false;
95  }
96 
97  if (!found)
98  {
99  for (int i = 0; i < fallback.Length; i++)
100  {
101  try
102  {
103  tbr = ResolveFontFamily(fontFamily);
104  if (tbr.TrueTypeFile != null)
105  {
106  found = true;
107  }
108  }
109  catch
110  {
111  tbr = null;
112  found = false;
113  }
114 
115  if (found)
116  {
117  return tbr;
118  }
119  }
120  }
121  else
122  {
123  return tbr;
124  }
125 
126  throw new FontFamilyCreationException(fontFamily);
127  }
128 
129  /// <inheritdoc/>
130  public virtual FontFamily ResolveFontFamily(string fontFamily, FontFamily.StandardFontFamilies finalFallback, params string[] fallback)
131  {
132  bool found = false;
133 
134  FontFamily tbr = null;
135 
136  try
137  {
138  tbr = ResolveFontFamily(fontFamily);
139  if (tbr.TrueTypeFile != null)
140  {
141  found = true;
142  }
143  }
144  catch
145  {
146  tbr = null;
147  found = false;
148  }
149 
150  if (!found)
151  {
152  for (int i = 0; i < fallback.Length; i++)
153  {
154  try
155  {
156  tbr = ResolveFontFamily(fontFamily);
157  if (tbr.TrueTypeFile != null)
158  {
159  found = true;
160  }
161  }
162  catch
163  {
164  tbr = null;
165  found = false;
166  }
167 
168  if (found)
169  {
170  return tbr;
171  }
172  }
173  }
174  else
175  {
176  return tbr;
177  }
178 
179  return ResolveFontFamily(finalFallback);
180  }
181  }
182 
183  /// <summary>
184  /// A font library that can be used to cache and resolve font family names.
185  /// </summary>
187  {
188  private Dictionary<string, string> KnownFonts = new Dictionary<string, string>();
189  private Dictionary<string, string> NotLoadedFonts = new Dictionary<string, string>();
190  private Dictionary<string, FontFamily> LoadedFonts = new Dictionary<string, FontFamily>();
191  private Dictionary<FontFamily.StandardFontFamilies, FontFamily> Fallbacks = new Dictionary<FontFamily.StandardFontFamilies, FontFamily>();
192  private DefaultFontLibrary defaultLibrary = new DefaultFontLibrary();
193 
194  /// <summary>
195  /// Create a new <see cref="SimpleFontLibrary"/> instance.
196  /// </summary>
197  /// <param name="standardFontLibrary">An existing font library that will be used to resolve the standard font families.</param>
198  public SimpleFontLibrary(IFontLibrary standardFontLibrary)
199  {
200  for (int i = 0; i < 14; i++)
201  {
203  FontFamily resolved = standardFontLibrary.ResolveFontFamily(stdFF);
204 
205  Fallbacks[stdFF] = resolved;
206  LoadedFonts[FontFamily.StandardFamilies[i]] = resolved;
208  KnownFonts[resolved.FamilyName] = FontFamily.StandardFamilies[i];
209  KnownFonts[resolved.TrueTypeFile.GetFontFamilyName()] = FontFamily.StandardFamilies[i];
211  KnownFonts[resolved.TrueTypeFile.GetFontName()] = FontFamily.StandardFamilies[i];
212  }
213  }
214 
215  /// <summary>
216  /// Create a new <see cref="SimpleFontLibrary"/> instance, using the default font library to resolve the standard font families.
217  /// </summary>
219  {
220 
221  }
222 
223  /// <summary>
224  /// Create a new <see cref="SimpleFontLibrary"/> instance, with the specified replacements for the standard font families.
225  /// </summary>
226  /// <param name="timesRoman">The font family to use for the Times-Roman standard font.</param>
227  /// <param name="timesBold">The font family to use for the Times-Bold standard font.</param>
228  /// <param name="timesItalic">The font family to use for the Times-Italic standard font.</param>
229  /// <param name="timesBoldItalic">The font family to use for the Times-BoldItalic standard font.</param>
230  /// <param name="helvetica">The font family to use for the Helvetica standard font.</param>
231  /// <param name="helveticaBold">The font family to use for the Helvetica-Bold standard font.</param>
232  /// <param name="helveticaOblique">The font family to use for the Helvetica-Oblique standard font.</param>
233  /// <param name="helveticaBoldOblique">The font family to use for the Helvetica-BoldOblique standard font.</param>
234  /// <param name="courier">The font family to use for the Courier standard font.</param>
235  /// <param name="courierBold">The font family to use for the Courier-Bold standard font.</param>
236  /// <param name="courierOblique">The font family to use for the Courier-Oblique standard font.</param>
237  /// <param name="courierBoldOblique">The font family to use for the Courier-BoldOblique standard font.</param>
238  /// <param name="symbol">The font family to use for the Symbol standard font.</param>
239  /// <param name="zapfdingbats">The font family to use for the Zapfdingbats standard font.</param>
240  public SimpleFontLibrary(FontFamily timesRoman, FontFamily timesBold, FontFamily timesItalic, FontFamily timesBoldItalic,
241  FontFamily helvetica, FontFamily helveticaBold, FontFamily helveticaOblique, FontFamily helveticaBoldOblique,
242  FontFamily courier, FontFamily courierBold, FontFamily courierOblique, FontFamily courierBoldOblique,
243  FontFamily symbol, FontFamily zapfdingbats)
244  {
245  Fallbacks[FontFamily.StandardFontFamilies.TimesRoman] = timesRoman;
246  Fallbacks[FontFamily.StandardFontFamilies.TimesBold] = timesBold;
247  Fallbacks[FontFamily.StandardFontFamilies.TimesItalic] = timesItalic;
248  Fallbacks[FontFamily.StandardFontFamilies.TimesBoldItalic] = timesBoldItalic;
249 
250  Fallbacks[FontFamily.StandardFontFamilies.Helvetica] = helvetica;
251  Fallbacks[FontFamily.StandardFontFamilies.HelveticaBold] = helveticaBold;
252  Fallbacks[FontFamily.StandardFontFamilies.HelveticaOblique] = helveticaOblique;
253  Fallbacks[FontFamily.StandardFontFamilies.HelveticaBoldOblique] = helveticaBoldOblique;
254 
255  Fallbacks[FontFamily.StandardFontFamilies.Courier] = courier;
256  Fallbacks[FontFamily.StandardFontFamilies.CourierBold] = courierBold;
257  Fallbacks[FontFamily.StandardFontFamilies.CourierOblique] = courierOblique;
258  Fallbacks[FontFamily.StandardFontFamilies.CourierBoldOblique] = courierBoldOblique;
259 
260  Fallbacks[FontFamily.StandardFontFamilies.Symbol] = symbol;
261  Fallbacks[FontFamily.StandardFontFamilies.ZapfDingbats] = zapfdingbats;
262 
263  for (int i = 0; i < 14; i++)
264  {
266  FontFamily resolved = Fallbacks[stdFF];
267  resolved.IsStandardFamily = true;
268  resolved.FileName = FontFamily.StandardFamilies[i];
269  resolved.FamilyName = FontFamily.StandardFamilies[i].Replace("-", " ");
270 
271  LoadedFonts[FontFamily.StandardFamilies[i]] = resolved;
273  KnownFonts[resolved.FamilyName] = FontFamily.StandardFamilies[i];
274  KnownFonts[resolved.TrueTypeFile.GetFontFamilyName()] = FontFamily.StandardFamilies[i];
276  KnownFonts[resolved.TrueTypeFile.GetFontName()] = FontFamily.StandardFamilies[i];
277  }
278  }
279 
280 
281  /// <summary>
282  /// Create a new <see cref="SimpleFontLibrary"/> instance, with the specified replacements for the standard font families.
283  /// </summary>
284  /// <param name="timesRoman">The font family to use for the Times-Roman standard font.</param>
285  /// <param name="timesBold">The font family to use for the Times-Bold standard font.</param>
286  /// <param name="timesItalic">The font family to use for the Times-Italic standard font.</param>
287  /// <param name="timesBoldItalic">The font family to use for the Times-BoldItalic standard font.</param>
288  /// <param name="helvetica">The font family to use for the Helvetica standard font.</param>
289  /// <param name="helveticaBold">The font family to use for the Helvetica-Bold standard font.</param>
290  /// <param name="helveticaOblique">The font family to use for the Helvetica-Oblique standard font.</param>
291  /// <param name="helveticaBoldOblique">The font family to use for the Helvetica-BoldOblique standard font.</param>
292  /// <param name="courier">The font family to use for the Courier standard font.</param>
293  /// <param name="courierBold">The font family to use for the Courier-Bold standard font.</param>
294  /// <param name="courierOblique">The font family to use for the Courier-Oblique standard font.</param>
295  /// <param name="courierBoldOblique">The font family to use for the Courier-BoldOblique standard font.</param>
296  /// <param name="symbol">The font family to use for the Symbol standard font.</param>
297  /// <param name="zapfdingbats">The font family to use for the Zapfdingbats standard font.</param>
298  public SimpleFontLibrary(string timesRoman, string timesBold, string timesItalic, string timesBoldItalic,
299  string helvetica, string helveticaBold, string helveticaOblique, string helveticaBoldOblique,
300  string courier, string courierBold, string courierOblique, string courierBoldOblique,
301  string symbol, string zapfdingbats)
302  {
306  Fallbacks[FontFamily.StandardFontFamilies.TimesBoldItalic]= FontFamily.DefaultFontLibrary.ResolveFontFamily(timesBoldItalic);
307 
309  Fallbacks[FontFamily.StandardFontFamilies.HelveticaBold]= FontFamily.DefaultFontLibrary.ResolveFontFamily(helveticaBold);
310  Fallbacks[FontFamily.StandardFontFamilies.HelveticaOblique]= FontFamily.DefaultFontLibrary.ResolveFontFamily(helveticaOblique);
311  Fallbacks[FontFamily.StandardFontFamilies.HelveticaBoldOblique]= FontFamily.DefaultFontLibrary.ResolveFontFamily(helveticaBoldOblique);
312 
315  Fallbacks[FontFamily.StandardFontFamilies.CourierOblique]= FontFamily.DefaultFontLibrary.ResolveFontFamily(courierOblique);
316  Fallbacks[FontFamily.StandardFontFamilies.CourierBoldOblique]= FontFamily.DefaultFontLibrary.ResolveFontFamily(courierBoldOblique);
317 
319  Fallbacks[FontFamily.StandardFontFamilies.ZapfDingbats]= FontFamily.DefaultFontLibrary.ResolveFontFamily(zapfdingbats);
320 
321  for (int i = 0; i < 14; i++)
322  {
324  FontFamily resolved = Fallbacks[stdFF];
325  resolved.IsStandardFamily = true;
326  resolved.FileName = FontFamily.StandardFamilies[i];
327  resolved.FamilyName = FontFamily.StandardFamilies[i].Replace("-", " ");
328 
329  LoadedFonts[FontFamily.StandardFamilies[i]] = resolved;
331  KnownFonts[resolved.FamilyName] = FontFamily.StandardFamilies[i];
332  KnownFonts[resolved.TrueTypeFile.GetFontFamilyName()] = FontFamily.StandardFamilies[i];
334  KnownFonts[resolved.TrueTypeFile.GetFontName()] = FontFamily.StandardFamilies[i];
335  }
336  }
337 
338 
339  /// <summary>
340  /// Add the specified font family to the library with the specified name.
341  /// </summary>
342  /// <param name="fontFamilyName">The name of the font family.</param>
343  /// <param name="fontFamily">The font family to add.</param>
344  public void Add(string fontFamilyName, FontFamily fontFamily)
345  {
346  this.LoadedFonts[fontFamilyName] = fontFamily;
347  this.KnownFonts[fontFamilyName] = fontFamilyName;
348 
349  if (fontFamily.TrueTypeFile != null)
350  {
351  this.KnownFonts[fontFamily.TrueTypeFile.GetFontFamilyName()] = fontFamilyName;
352  this.KnownFonts[fontFamily.TrueTypeFile.GetFullFontFamilyName()] = fontFamilyName;
353  this.KnownFonts[fontFamily.TrueTypeFile.GetFontName()] = fontFamilyName;
354  }
355  }
356 
357  /// <summary>
358  /// Add the specified font family to the library.
359  /// </summary>
360  /// <param name="fontFamily">The font family to add.</param>
361  public void Add(FontFamily fontFamily)
362  {
363  if (fontFamily.TrueTypeFile != null)
364  {
365  this.Add(fontFamily.TrueTypeFile.GetFullFontFamilyName(), fontFamily);
366  }
367  }
368 
369  /// <summary>
370  /// Add the font family contained in the specified True Type Font file to the library.
371  /// </summary>
372  /// <param name="fileName">The path to the TTF file containing the font family.</param>
373  public void Add(string fileName)
374  {
376 
377  if (fontFamily.TrueTypeFile != null)
378  {
379  this.Add(fontFamily.TrueTypeFile.GetFullFontFamilyName(), fontFamily);
380  }
381  }
382 
383  /// <summary>
384  /// Add the font family contained in the specified True Type Font file to the library, with the specified name. The font family is not loaded until it is requested for the first time.
385  /// </summary>
386  /// <param name="fontFamily">The name of the font family.</param>
387  /// <param name="fileName">The path to the TTF file containing the font family.</param>
388  public void Add(string fontFamily, string fileName)
389  {
390  this.KnownFonts[fontFamily] = fontFamily;
391  this.NotLoadedFonts[fontFamily] = fileName;
392  }
393 
394  /// <inheritdoc/>
395  public override FontFamily ResolveFontFamily(FontFamily.StandardFontFamilies standardFontFamily)
396  {
397  return Fallbacks[standardFontFamily];
398  }
399 
400  /// <inheritdoc/>
401  public override FontFamily ResolveFontFamily(string fontFamily)
402  {
403  if (KnownFonts.TryGetValue(fontFamily, out string knownFontName))
404  {
405  if (LoadedFonts.TryGetValue(knownFontName, out FontFamily tbr))
406  {
407  return tbr;
408  }
409  else
410  {
411  if (NotLoadedFonts.TryGetValue(knownFontName, out string ttfFile))
412  {
413  tbr = defaultLibrary.ResolveFontFamily(ttfFile);
414 
415  if (tbr.TrueTypeFile != null)
416  {
417  string familyName = tbr.TrueTypeFile.GetFontFamilyName();
418 
419  this.LoadedFonts[familyName] = tbr;
420  this.KnownFonts[familyName] = familyName;
421  this.KnownFonts[tbr.TrueTypeFile.GetFontName()] = familyName;
422  }
423 
424  return tbr;
425  }
426  else
427  {
428  return defaultLibrary.ResolveFontFamily(fontFamily);
429  }
430  }
431  }
432  else
433  {
434  return defaultLibrary.ResolveFontFamily(fontFamily);
435  }
436  }
437  }
438 
439  /// <summary>
440  /// An exception that occurs while creating a <see cref="FontFamily"/>.
441  /// </summary>
442  public class FontFamilyCreationException : Exception
443  {
444  /// <summary>
445  /// The name of the font family that was being created.
446  /// </summary>
447  public string FontFamily { get; }
448 
449  /// <summary>
450  /// Create a new <see cref="FontFamilyCreationException"/> instance.
451  /// </summary>
452  /// <param name="fontFamily">The name of the font family that was being created.</param>
453  public FontFamilyCreationException(string fontFamily) : base("The font family \"" + fontFamily + "\" could not be created!")
454  {
455  this.FontFamily = fontFamily;
456  }
457  }
458 
459  /// <summary>
460  /// A default font library that resolves standard families using the embedded fonts.
461  /// </summary>
463  {
464  /// <inheritdoc/>
465  public override FontFamily ResolveFontFamily(string fontFamily)
466  {
467  lock (FontFamily.fontFamilyLock)
468  {
469  bool isStandardFamily;
470 
471  if (FontFamily.StandardFamilies.Contains(fontFamily))
472  {
473  isStandardFamily = true;
474  }
475  else
476  {
477  isStandardFamily = false;
478  }
479 
480  if (isStandardFamily)
481  {
482  Stream ttfStream = FontFamily.GetManifestResourceStream(FontFamily.StandardFontFamilyResources[Array.IndexOf(FontFamily.StandardFamilies, fontFamily)]);
483 
484  FontFamily tbr = new FontFamily(ttfStream);
485  tbr.IsStandardFamily = true;
486  tbr.FileName = fontFamily;
487  tbr.FamilyName = tbr.FileName.Replace("-", " ");
488 
489  if (fontFamily == "Times-Italic" || fontFamily == "Times-BoldItalic" || fontFamily == "Helvetica-Oblique" || fontFamily == "Helvetica-BoldOblique" || fontFamily == "Courier-Oblique" || fontFamily == "Courier-BoldOblique")
490  {
491  tbr.IsItalic = true;
492  tbr.IsOblique = (fontFamily == "Courier-Oblique" || fontFamily == "Courier-BoldOblique");
493  }
494  else
495  {
496  tbr.IsItalic = false;
497  tbr.IsOblique = false;
498  }
499 
500  return tbr;
501  }
502  else
503  {
504  try
505  {
506  FontFamily tbr = new FontFamily(TrueTypeFile.CreateTrueTypeFile(fontFamily));
507  tbr.FileName = fontFamily;
509  return tbr;
510  }
511  catch
512  {
513  FontFamily tbr = new FontFamily();
514  tbr.FileName = fontFamily;
515  tbr.FamilyName = fontFamily;
516  return tbr;
517  }
518  }
519  }
520  }
521 
522  /// <inheritdoc/>
523  public override FontFamily ResolveFontFamily(FontFamily.StandardFontFamilies standardFontFamily)
524  {
525  lock (FontFamily.fontFamilyLock)
526  {
527  Stream ttfStream = FontFamily.GetManifestResourceStream(FontFamily.StandardFontFamilyResources[(int)standardFontFamily]);
528  FontFamily tbr = new FontFamily(ttfStream);
529 
530 
531  tbr.IsStandardFamily = true;
532 
533  tbr.FileName = FontFamily.StandardFamilies[(int)standardFontFamily];
534  tbr.FamilyName = tbr.FileName.Replace("-", " ");
535 
536  if (tbr.FileName == "Times-Italic" || tbr.FileName == "Times-BoldItalic" || tbr.FileName == "Helvetica-Oblique" || tbr.FileName == "Helvetica-BoldOblique" || tbr.FileName == "Courier-Oblique" || tbr.FileName == "Courier-BoldOblique")
537  {
538  tbr.IsItalic = true;
539  tbr.IsOblique = (tbr.FileName == "Courier-Oblique" || tbr.FileName == "Courier-BoldOblique");
540  }
541  else
542  {
543  tbr.IsItalic = false;
544  tbr.IsOblique = false;
545  }
546 
547  return tbr;
548  }
549  }
550  }
551 }
VectSharp.TrueTypeFile
Represents a font file in TrueType format. Reference: http://stevehanov.ca/blog/?id=143,...
Definition: TrueType.cs:31
VectSharp.SimpleFontLibrary.ResolveFontFamily
override FontFamily ResolveFontFamily(string fontFamily)
Create a new font family from the specified family name or true type file. If the family name or the ...
Definition: FontLibrary.cs:401
VectSharp.SimpleFontLibrary.SimpleFontLibrary
SimpleFontLibrary(FontFamily timesRoman, FontFamily timesBold, FontFamily timesItalic, FontFamily timesBoldItalic, FontFamily helvetica, FontFamily helveticaBold, FontFamily helveticaOblique, FontFamily helveticaBoldOblique, FontFamily courier, FontFamily courierBold, FontFamily courierOblique, FontFamily courierBoldOblique, FontFamily symbol, FontFamily zapfdingbats)
Create a new SimpleFontLibrary instance, with the specified replacements for the standard font famili...
Definition: FontLibrary.cs:240
VectSharp.FontFamilyCreationException.FontFamilyCreationException
FontFamilyCreationException(string fontFamily)
Create a new FontFamilyCreationException instance.
Definition: FontLibrary.cs:453
VectSharp.SimpleFontLibrary.Add
void Add(string fontFamily, string fileName)
Add the font family contained in the specified True Type Font file to the library,...
Definition: FontLibrary.cs:388
VectSharp.SimpleFontLibrary
A font library that can be used to cache and resolve font family names.
Definition: FontLibrary.cs:187
VectSharp.IFontLibrary.ResolveFontFamily
FontFamily ResolveFontFamily(string fontFamily, FontFamily.StandardFontFamilies finalFallback, params string[] fallback)
Create a new font family from the specified family name or true type file. If the family name or the ...
VectSharp
Definition: Brush.cs:26
VectSharp.FontLibrary.ResolveFontFamily
virtual FontFamily ResolveFontFamily(string fontFamily, params string[] fallback)
Create a new font family from the specified family name or true type file. If the family name or the ...
Definition: FontLibrary.cs:77
VectSharp.FontFamily.IsItalic
bool IsItalic
Whether this font is italic or oblique or not. This is set based on the information included in the O...
Definition: Font.cs:596
VectSharp.IFontLibrary.ResolveFontFamily
FontFamily ResolveFontFamily(FontFamily.StandardFontFamilies standardFontFamily)
Create a new font family from the specified standard font family name.
VectSharp.FontFamily.DefaultFontLibrary
static IFontLibrary DefaultFontLibrary
The default font library used to resolve font family names.
Definition: Font.cs:425
VectSharp.IFontLibrary
Represents a font library with methods to create FontFamily objects from a string or from FontFamily....
Definition: FontLibrary.cs:30
VectSharp.FontFamily.IsStandardFamily
bool IsStandardFamily
Whether this is one of the 14 standard font families or not.
Definition: Font.cs:494
VectSharp.SimpleFontLibrary.SimpleFontLibrary
SimpleFontLibrary()
Create a new SimpleFontLibrary instance, using the default font library to resolve the standard font ...
Definition: FontLibrary.cs:218
VectSharp.FontFamilyCreationException
An exception that occurs while creating a FontFamily.
Definition: FontLibrary.cs:443
VectSharp.IFontLibrary.ResolveFontFamily
FontFamily ResolveFontFamily(string fontFamily, params string[] fallback)
Create a new font family from the specified family name or true type file. If the family name or the ...
VectSharp.IFontLibrary.ResolveFontFamily
FontFamily ResolveFontFamily(string fontFamily)
Create a new font family from the specified family name or true type file. If the family name or the ...
VectSharp.SimpleFontLibrary.ResolveFontFamily
override FontFamily ResolveFontFamily(FontFamily.StandardFontFamilies standardFontFamily)
Create a new font family from the specified standard font family name.
Definition: FontLibrary.cs:395
VectSharp.FontFamily.ResolveFontFamily
static FontFamily ResolveFontFamily(string fontFamily)
Create a new font family from the specified family name or true type file. If the family name or the ...
VectSharp.SimpleFontLibrary.SimpleFontLibrary
SimpleFontLibrary(string timesRoman, string timesBold, string timesItalic, string timesBoldItalic, string helvetica, string helveticaBold, string helveticaOblique, string helveticaBoldOblique, string courier, string courierBold, string courierOblique, string courierBoldOblique, string symbol, string zapfdingbats)
Create a new SimpleFontLibrary instance, with the specified replacements for the standard font famili...
Definition: FontLibrary.cs:298
VectSharp.FontFamily.StandardFontFamilyResources
static string[] StandardFontFamilyResources
The names of the resource streams pointing to the included TrueType font files for each of the standa...
Definition: Font.cs:483
VectSharp.SimpleFontLibrary.Add
void Add(string fontFamilyName, FontFamily fontFamily)
Add the specified font family to the library with the specified name.
Definition: FontLibrary.cs:344
VectSharp.FontLibrary.ResolveFontFamily
abstract FontFamily ResolveFontFamily(string fontFamily)
Create a new font family from the specified family name or true type file. If the family name or the ...
VectSharp.SimpleFontLibrary.SimpleFontLibrary
SimpleFontLibrary(IFontLibrary standardFontLibrary)
Create a new SimpleFontLibrary instance.
Definition: FontLibrary.cs:198
VectSharp.FontFamily
Represents a typeface.
Definition: Font.cs:421
VectSharp.FontFamily.FamilyName
string FamilyName
Name of the font family, including any variantes.
Definition: Font.cs:580
VectSharp.DefaultFontLibrary
A default font library that resolves standard families using the embedded fonts.
Definition: FontLibrary.cs:463
VectSharp.FontFamily.IsOblique
bool IsOblique
Whether this font is oblique or not. This is set based on the information included in the OS/2 table ...
Definition: Font.cs:601
VectSharp.FontLibrary.ResolveFontFamily
virtual FontFamily ResolveFontFamily(string fontFamily, FontFamily.StandardFontFamilies finalFallback, params string[] fallback)
Create a new font family from the specified family name or true type file. If the family name or the ...
Definition: FontLibrary.cs:130
VectSharp.TrueTypeFile.GetFullFontFamilyName
string GetFullFontFamilyName()
Obtains the full font family name from the TrueType file.
Definition: TrueType.cs:1873
VectSharp.FontFamily.StandardFontFamilies
StandardFontFamilies
The 14 standard font families.
Definition: Font.cs:500
VectSharp.FontFamily.StandardFamilies
static string[] StandardFamilies
The names of the 14 standard families that are guaranteed to be displayed correctly.
Definition: Font.cs:478
VectSharp.TrueTypeFile.GetFontName
string GetFontName()
Obtains the PostScript font name from the TrueType file.
Definition: TrueType.cs:1901
VectSharp.FontLibrary.ResolveFontFamily
abstract FontFamily ResolveFontFamily(FontFamily.StandardFontFamilies standardFontFamily)
Create a new font family from the specified standard font family name.
VectSharp.SimpleFontLibrary.Add
void Add(string fileName)
Add the font family contained in the specified True Type Font file to the library.
Definition: FontLibrary.cs:373
VectSharp.FontLibrary
Abstract class with a default implementation of font family fallbacks.
Definition: FontLibrary.cs:69
VectSharp.DefaultFontLibrary.ResolveFontFamily
override FontFamily ResolveFontFamily(string fontFamily)
Create a new font family from the specified family name or true type file. If the family name or the ...
Definition: FontLibrary.cs:465
VectSharp.DefaultFontLibrary.ResolveFontFamily
override FontFamily ResolveFontFamily(FontFamily.StandardFontFamilies standardFontFamily)
Create a new font family from the specified standard font family name.
Definition: FontLibrary.cs:523
VectSharp.SimpleFontLibrary.Add
void Add(FontFamily fontFamily)
Add the specified font family to the library.
Definition: FontLibrary.cs:361
VectSharp.TrueTypeFile.GetFontFamilyName
string GetFontFamilyName()
Obtains the font family name from the TrueType file.
Definition: TrueType.cs:1846
VectSharp.FontFamily.TrueTypeFile
TrueTypeFile TrueTypeFile
Parsed TrueType font file for this font family. See also: VectSharp.TrueTypeFile.
Definition: Font.cs:586
VectSharp.FontFamily.FileName
string FileName
Full path to the TrueType font file for this font family (or, if this is a standard font family,...
Definition: Font.cs:575