 |
VectSharp
2.2.1
A light library for C# vector graphics
|
19 using System.Collections.Generic;
126 public double Top {
get; }
138 internal DetailedFontMetrics(
double width,
double height,
double leftSideBearing,
double rightSideBearing,
double top,
double bottom,
double advanceWidth)
309 Point currentGlyphPlacementDelta =
new Point();
314 for (
int i = 0; i < text.Length; i++)
318 currentGlyphPlacementDelta = nextGlyphPlacementDelta;
319 currentGlyphAdvanceDelta = nextGlyphAdvanceDelta;
320 nextGlyphAdvanceDelta =
new Point();
321 nextGlyphPlacementDelta =
new Point();
327 currentGlyphPlacementDelta =
new Point(currentGlyphPlacementDelta.
X + kerning.Glyph1Placement.X, currentGlyphPlacementDelta.
Y + kerning.Glyph1Placement.Y);
328 currentGlyphAdvanceDelta =
new Point(currentGlyphAdvanceDelta.
X + kerning.Glyph1Advance.X, currentGlyphAdvanceDelta.
Y + kerning.Glyph1Advance.Y);
330 nextGlyphPlacementDelta =
new Point(nextGlyphPlacementDelta.
X + kerning.Glyph2Placement.X, nextGlyphPlacementDelta.
Y + kerning.Glyph2Placement.Y);
331 nextGlyphAdvanceDelta =
new Point(nextGlyphAdvanceDelta.
X + kerning.Glyph2Advance.X, nextGlyphAdvanceDelta.
Y + kerning.Glyph2Advance.Y);
338 yMin = Math.Min(yMin, (vMet.YMin + currentGlyphPlacementDelta.
Y) * this.
FontSize / 1000);
339 yMax = Math.Max(yMax, (vMet.YMax + currentGlyphPlacementDelta.
Y) * this.
FontSize / 1000);
345 return new Size(width, yMax - yMin);
349 return new Size(0, 0);
366 Point currentGlyphPlacementDelta =
new Point();
371 for (
int i = 0; i < text.Length; i++)
375 currentGlyphPlacementDelta = nextGlyphPlacementDelta;
376 currentGlyphAdvanceDelta = nextGlyphAdvanceDelta;
377 nextGlyphAdvanceDelta =
new Point();
378 nextGlyphPlacementDelta =
new Point();
384 currentGlyphPlacementDelta =
new Point(currentGlyphPlacementDelta.
X + kerning.Glyph1Placement.X, currentGlyphPlacementDelta.
Y + kerning.Glyph1Placement.Y);
385 currentGlyphAdvanceDelta =
new Point(currentGlyphAdvanceDelta.
X + kerning.Glyph1Advance.X, currentGlyphAdvanceDelta.
Y + kerning.Glyph1Advance.Y);
387 nextGlyphPlacementDelta =
new Point(nextGlyphPlacementDelta.
X + kerning.Glyph2Placement.X, nextGlyphPlacementDelta.
Y + kerning.Glyph2Placement.Y);
388 nextGlyphAdvanceDelta =
new Point(nextGlyphAdvanceDelta.
X + kerning.Glyph2Advance.X, nextGlyphAdvanceDelta.
Y + kerning.Glyph2Advance.Y);
395 yMin = Math.Min(yMin, (vMet.YMin + currentGlyphPlacementDelta.
Y) * this.
FontSize / 1000);
396 yMax = Math.Max(yMax, (vMet.YMax + currentGlyphPlacementDelta.
Y) * this.
FontSize / 1000);
402 double advanceWidth = width;
461 internal static object fontFamilyLock =
new object();
462 internal static readonly Dictionary<string, Stream> manifestResources =
new Dictionary<string, Stream>();
464 internal static Stream GetManifestResourceStream(
string name)
466 if (!manifestResources.ContainsKey(name))
468 manifestResources.Add(name, typeof(
FontFamily).Assembly.GetManifestResourceStream(name));
471 return manifestResources[name];
478 public static string[]
StandardFamilies =
new string[] {
"Times-Roman",
"Times-Bold",
"Times-Italic",
"Times-BoldItalic",
"Helvetica",
"Helvetica-Bold",
"Helvetica-Oblique",
"Helvetica-BoldOblique",
"Courier",
"Courier-Bold",
"Courier-Oblique",
"Courier-BoldOblique",
"Symbol",
"ZapfDingbats" };
485 "VectSharp.StandardFonts.Tinos-Regular.ttf",
"VectSharp.StandardFonts.Tinos-Bold.ttf",
"VectSharp.StandardFonts.Tinos-Italic.ttf",
"VectSharp.StandardFonts.Tinos-BoldItalic.ttf",
486 "VectSharp.StandardFonts.Arimo-Regular.ttf",
"VectSharp.StandardFonts.Arimo-Bold.ttf",
"VectSharp.StandardFonts.Arimo-Italic.ttf",
"VectSharp.StandardFonts.Arimo-BoldItalic.ttf",
487 "VectSharp.StandardFonts.Cousine-Regular.ttf",
"VectSharp.StandardFonts.Cousine-Bold.ttf",
"VectSharp.StandardFonts.Cousine-Italic.ttf",
"VectSharp.StandardFonts.Cousine-BoldItalic.ttf",
488 "VectSharp.StandardFonts.SymbolNeu_GB.ttf",
"VectSharp.StandardFonts.Levibats-Regular_GB.ttf"
539 HelveticaBoldOblique,
591 public bool IsBold {
get;
internal set; }
607 [Obsolete(
"Please use the FontFamily.ResolveFontFamily(string) method instead!",
true)]
610 lock (fontFamilyLock)
635 lock (fontFamilyLock)
655 lock (fontFamilyLock)
673 [Obsolete(
"Please use the FontFamily.ResolveFontFamily(StandardFontFamilies) method instead!",
true)]
676 lock (fontFamilyLock)
706 public ResourceFontFamily(System.IO.Stream resourceStream,
string resourceName) : base(resourceStream)
708 this.ResourceName = resourceName;
Represents a font file in TrueType format. Reference: http://stevehanov.ca/blog/?id=143,...
FontUnderline Underline
Determines the underline style of text drawn using this font. If this is null, the text is not underl...
PairKerning Get1000EmKerning(char glyph1, char glyph2)
Gets the kerning between two glyphs.
double Get1000EmUnderlinePosition()
Computes the distance of the top of the underline from the baseline, in thousandths of em unit.
double Width
Width of the text (measured on the actual glyph outlines).
Font(FontFamily fontFamily, double fontSize)
Create a new Font object, given the base typeface and the font size.
double LeftSideBearing
How much the leftmost glyph in the string overhangs the glyph origin on the left. Positive for glyphs...
double Get1000EmYMax()
Computes the maximum height over the baseline of the font, in thousandths of em unit.
FontFamily(StandardFontFamilies standardFontFamily)
Create a new standard FontFamily.
FontFamily(Stream ttfStream)
Create a new FontFamily.
double RightSideBearing
How much the rightmost glyph in the string overhangs the glyph end on the right. Positive for glyphs ...
bool IsItalic
Whether this font is italic or oblique or not. This is set based on the information included in the O...
bool FollowItalicAngle
Determine whether the shape of the underline is slanted to follow the angle of italic fonts.
DetailedFontMetrics MeasureTextAdvanced(string text)
Measure all the metrics of a text string when typeset with this font.
double WinAscent
Height above the baseline for a clipping region (Windows ascent). Always >= 0.
double Top
Height of the tallest glyph in the string over the baseline. Always >= 0.
string ResourceName
The name of the embedded resource, which will be parsed using
int RightSideBearing
The right-side bearing of the glyph.
LineCaps
Represents line caps.
static IFontLibrary DefaultFontLibrary
The default font library used to resolve font family names.
Represents a font library with methods to create FontFamily objects from a string or from FontFamily....
bool IsStandardFamily
Whether this is one of the 14 standard font families or not.
double YMax
Absolute maximum height over the baseline of the glyphs in the font. Always >= 0.
ResourceFontFamily(System.IO.Stream resourceStream, string resourceName)
Create a new ResourceFontFamily from the specified resourceStream containing a TTF file,...
Represents a typeface with a specific size.
double Position
Determines the position of the top of the underline with respect to the text baseline....
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 ...
static 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 ...
static FontFamily ResolveFontFamily(string 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 ...
static string[] StandardFontFamilyResources
The names of the resource streams pointing to the included TrueType font files for each of the standa...
bool IsItalic()
Determines whether the typeface is Italic or Oblique or not.
double Bottom
Depth of the deepest glyph in the string below the baseline. Always <= 0.
LineCaps LineCap
Determines the caps at the start and end of the underline.
string FamilyName
Name of the font family, including any variantes.
double Get1000EmYMin()
Computes the maximum depth below the baseline of the font, in thousandths of em unit.
A default font library that resolves standard families using the embedded fonts.
bool IsOblique
Whether this font is oblique or not. This is set based on the information included in the OS/2 table ...
double AdvanceWidth
Advance width of the text (excluding any left- or right- side bearing).
double Get1000EmAscent()
Computes the font ascent, in thousandths of em unit.
Font(FontFamily fontFamily, double fontSize, bool underlined)
Create a new Font object, given the base typeface, the font size, and a boolean value determining whe...
static bool EnableKerning
Determines whether text kerning is enabled. Note that, even when this is set to false,...
Represents options to underline text.
Represents detailed information about the metrics of a text string when drawn with a certain font.
string GetFullFontFamilyName()
Obtains the full font family name from the TrueType file.
bool IsBold
Whether this font is bold or not. This is set based on the information included in the OS/2 table of ...
int LeftSideBearing
The left-side bearing of the glyph.
bool SkipDescenders
Determines whether the underline skips the parts of the glyph that would intersect with it or not.
double Thickness
Determines the thickness of the underline, expressed as a fraction of the font size.
double X
Horizontal (x) coordinate, measured to the right of the origin.
double Ascent
Maximum height over the baseline of the usual glyphs in the font (there may be glyphs taller than thi...
double Get1000EmGlyphWidth(char glyph)
Computes the advance width of a glyph, in thousandths of em unit.
Represents a FontFamily created from a resource stream.
double Get1000EmWinAscent()
Computes the font's Win ascent, in thousandths of em unit.
Represents the maximum heigth above and depth below the baseline of a glyph.
bool IsOblique()
Determines whether the typeface is Oblique or not.
StandardFontFamilies
The 14 standard font families.
static string[] StandardFamilies
The names of the 14 standard families that are guaranteed to be displayed correctly.
Size MeasureText(string text)
Measure the size of a text string when typeset with this font.
Represents the size of an object.
static FontFamily ResolveFontFamily(StandardFontFamilies standardFontFamily)
Create a new font family from the specified standard font family name. Equivalent to DefaultFontLibra...
Contains information describing how the position of two glyphs in a kerning pair should be altered.
double YMin
Absolute maximum depth below the baseline of the glyphs in the font. Always <= 0.
FontFamily(TrueTypeFile ttf)
Create a new FontFamily.
FontFamily(string fileName)
Create a new FontFamily.
Font(FontFamily fontFamily, double fontSize, FontUnderline underline)
Create a new Font object, given the base typeface, the font size, and an object describing the underl...
double Get1000EmUnderlineThickness()
Computes the thickness of the underline, in thousandths of em unit.
double FontSize
Font size, in graphics units.
Represents a point relative to an origin in the top-left corner.
bool IsBold()
Determines whether the typeface is Bold or not.
double Descent
Maximum depth below the baseline of the usual glyphs in the font (there may be glyphs deeper than thi...
double Height
Height of the text (measured on the actual glyph outlines).
double Get1000EmDescent()
Computes the font descent, in thousandths of em unit.
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 ...
string GetFontFamilyName()
Obtains the font family name from the TrueType file.
double Y
Vertical (y) coordinate, measured to the bottom of the origin.
TrueTypeFile TrueTypeFile
Parsed TrueType font file for this font family. See also: VectSharp.TrueTypeFile.
string FileName
Full path to the TrueType font file for this font family (or, if this is a standard font family,...