VectSharp  2.2.1
A light library for C# vector graphics
VectSharp.TrueTypeFile Class Reference

Represents a font file in TrueType format. Reference: http://stevehanov.ca/blog/?id=143, https://developer.apple.com/fonts/TrueType-Reference-Manual/, https://docs.microsoft.com/en-us/typography/opentype/spec/ More...

Classes

struct  Bearings
 Represents the left- and right-side bearings of a glyph. More...
 
class  PairKerning
 Contains information describing how the position of two glyphs in a kerning pair should be altered. More...
 
struct  TrueTypePoint
 Represents a point in a TrueType path description. More...
 
struct  VerticalMetrics
 Represents the maximum heigth above and depth below the baseline of a glyph. More...
 

Public Member Functions

void Destroy ()
 Remove this TrueType file from the cache, clear the tables and release the FontStream. Only call this when the actual file that was used to create this object needs to be changed! More...
 
TrueTypeFile SubsetFont (string charactersToInclude, bool consolidateAt32=false, Dictionary< char, char > outputEncoding=null)
 Create a subset of the TrueType file, containing only the glyphs for the specified characters. More...
 
string GetFontFamilyName ()
 Obtains the font family name from the TrueType file. More...
 
string GetFullFontFamilyName ()
 Obtains the full font family name from the TrueType file. More...
 
string GetFontName ()
 Obtains the PostScript font name from the TrueType file. More...
 
ushort GetFirstCharIndex ()
 Returns the index of the first character glyph represented by the font. More...
 
ushort GetLastCharIndex ()
 Returns the index of the last character glyph represented by the font. More...
 
bool IsItalic ()
 Determines whether the typeface is Italic or Oblique or not. More...
 
bool IsOblique ()
 Determines whether the typeface is Oblique or not. More...
 
bool IsBold ()
 Determines whether the typeface is Bold or not. More...
 
bool IsFixedPitch ()
 Determines whether the typeface is fixed-pitch (aka monospaces) or not. More...
 
bool IsSerif ()
 Determines whether the typeface is serifed or not. More...
 
bool IsScript ()
 Determines whether the typeface is a script typeface or not. More...
 
int GetGlyphIndex (char glyph)
 Determines the index of the glyph corresponding to a certain character. More...
 
TrueTypePoint[][] GetGlyphPath (int glyphIndex, double size)
 Get the path that describes the shape of a glyph. More...
 
TrueTypePoint[][] GetGlyphPath (char glyph, double size)
 Get the path that describes the shape of a glyph. More...
 
double Get1000EmGlyphWidth (char glyph)
 Computes the advance width of a glyph, in thousandths of em unit. More...
 
double Get1000EmGlyphWidth (int glyphIndex)
 Computes the advance width of a glyph, in thousandths of em unit. More...
 
double Get1000EmWinAscent ()
 Computes the font's Win ascent, in thousandths of em unit. More...
 
double Get1000EmAscent ()
 Computes the font ascent, in thousandths of em unit. More...
 
double Get1000EmDescent ()
 Computes the font descent, in thousandths of em unit. More...
 
double Get1000EmYMax ()
 Computes the maximum height over the baseline of the font, in thousandths of em unit. More...
 
double Get1000EmYMin ()
 Computes the maximum depth below the baseline of the font, in thousandths of em unit. More...
 
double Get1000EmXMax ()
 Computes the maximum distance to the right of the glyph origin of the font, in thousandths of em unit. More...
 
double Get1000EmXMin ()
 Computes the maximum distance to the left of the glyph origin of the font, in thousandths of em unit. More...
 
Bearings Get1000EmGlyphBearings (char glyph)
 Computes the left- and right- side bearings of a glyph, in thousandths of em unit. More...
 
VerticalMetrics Get1000EmGlyphVerticalMetrics (char glyph)
 Computes the vertical metrics of a glyph, in thousandths of em unit. More...
 
double Get1000EmUnderlinePosition ()
 Computes the distance of the top of the underline from the baseline, in thousandths of em unit. More...
 
double Get1000EmUnderlineThickness ()
 Computes the thickness of the underline, in thousandths of em unit. More...
 
double GetItalicAngle ()
 Computes the italic angle for the current font, in thousandths of em unit. This is computed from the vertical and is negative for text that leans forwards. More...
 
double[] Get1000EmUnderlineIntersections (char glyph, double position, double thickness)
 Computes the intersections between an underline at the specified position and thickness and a glyph, in thousandths of em units. More...
 
PairKerning Get1000EmKerning (char glyph1, char glyph2)
 Gets the kerning between two glyphs. More...
 
PairKerning Get1000EmKerning (int glyph1Index, int glyph2Index)
 Gets the kerning between two glyphs. More...
 

Properties

Stream FontStream [get]
 A stream pointing to the TrueType file source (either on disk or in memory). Never dispose this stream directly; if you really need to, call Destroy instead. More...
 

Detailed Description

Member Function Documentation

◆ Destroy()

void VectSharp.TrueTypeFile.Destroy ( )

Remove this TrueType file from the cache, clear the tables and release the FontStream. Only call this when the actual file that was used to create this object needs to be changed!

Definition at line 53 of file TrueType.cs.

◆ Get1000EmAscent()

double VectSharp.TrueTypeFile.Get1000EmAscent ( )

Computes the font ascent, in thousandths of em unit.

Returns
The font ascent in thousandths of em unit.

Definition at line 2131 of file TrueType.cs.

◆ Get1000EmDescent()

double VectSharp.TrueTypeFile.Get1000EmDescent ( )

Computes the font descent, in thousandths of em unit.

Returns
The font descent in thousandths of em unit.

Definition at line 2141 of file TrueType.cs.

◆ Get1000EmGlyphBearings()

Bearings VectSharp.TrueTypeFile.Get1000EmGlyphBearings ( char  glyph)

Computes the left- and right- side bearings of a glyph, in thousandths of em unit.

Parameters
glyphThe glyph whose bearings are to be computed.
Returns
The left- and right- side bearings of the glyph in thousandths of em unit

Definition at line 2223 of file TrueType.cs.

◆ Get1000EmGlyphVerticalMetrics()

VerticalMetrics VectSharp.TrueTypeFile.Get1000EmGlyphVerticalMetrics ( char  glyph)

Computes the vertical metrics of a glyph, in thousandths of em unit.

Parameters
glyphThe glyph whose vertical metrics are to be computed.
Returns
The vertical metrics of a glyph, in thousandths of em unit.

Definition at line 2271 of file TrueType.cs.

◆ Get1000EmGlyphWidth() [1/2]

double VectSharp.TrueTypeFile.Get1000EmGlyphWidth ( char  glyph)

Computes the advance width of a glyph, in thousandths of em unit.

Parameters
glyphThe glyph whose advance width is to be computed.
Returns
The advance width of the glyph in thousandths of em unit.

Definition at line 2082 of file TrueType.cs.

◆ Get1000EmGlyphWidth() [2/2]

double VectSharp.TrueTypeFile.Get1000EmGlyphWidth ( int  glyphIndex)

Computes the advance width of a glyph, in thousandths of em unit.

Parameters
glyphIndexThe index of the glyph whose advance width is to be computed.
Returns
The advance width of the glyph in thousandths of em unit.

Definition at line 2100 of file TrueType.cs.

◆ Get1000EmKerning() [1/2]

PairKerning VectSharp.TrueTypeFile.Get1000EmKerning ( char  glyph1,
char  glyph2 
)

Gets the kerning between two glyphs.

Parameters
glyph1The first glyph of the kerning pair.
glyph2The second glyph of the kerning pair.
Returns
A PairKerning object containing information about how the position of each glyphs should be altered.

Definition at line 2490 of file TrueType.cs.

◆ Get1000EmKerning() [2/2]

PairKerning VectSharp.TrueTypeFile.Get1000EmKerning ( int  glyph1Index,
int  glyph2Index 
)

Gets the kerning between two glyphs.

Parameters
glyph1IndexThe index of the first glyph of the kerning pair.
glyph2IndexThe index of the second glyph of the kerning pair.
Returns
A PairKerning object containing information about how the position of each glyphs should be altered.

Definition at line 2504 of file TrueType.cs.

◆ Get1000EmUnderlineIntersections()

double [] VectSharp.TrueTypeFile.Get1000EmUnderlineIntersections ( char  glyph,
double  position,
double  thickness 
)

Computes the intersections between an underline at the specified position and thickness and a glyph, in thousandths of em units.

Parameters
glyphThe glyph whose intersections with the underline will be computed.
positionThe distance of the top of the underline from the baseline, in thousandths of em unit.
thicknessThe thickness of the underline, in thousandths of em unit.
Returns
If the underline does not intersect the glyph, this method returns null. Otherwise, it returns an array containing two elements, representing the horizontal coordinates of the leftmost and rightmost intersection points.

Definition at line 2340 of file TrueType.cs.

◆ Get1000EmUnderlinePosition()

double VectSharp.TrueTypeFile.Get1000EmUnderlinePosition ( )

Computes the distance of the top of the underline from the baseline, in thousandths of em unit.

Returns
The distance of the top of the underline from the baseline, in thousandths of em unit.

Definition at line 2288 of file TrueType.cs.

◆ Get1000EmUnderlineThickness()

double VectSharp.TrueTypeFile.Get1000EmUnderlineThickness ( )

Computes the thickness of the underline, in thousandths of em unit.

Returns
The thickness of the underline, in thousandths of em unit.

Definition at line 2304 of file TrueType.cs.

◆ Get1000EmWinAscent()

double VectSharp.TrueTypeFile.Get1000EmWinAscent ( )

Computes the font's Win ascent, in thousandths of em unit.

Returns
The font's Win ascent in thousandths of em unit.

Definition at line 2111 of file TrueType.cs.

◆ Get1000EmXMax()

double VectSharp.TrueTypeFile.Get1000EmXMax ( )

Computes the maximum distance to the right of the glyph origin of the font, in thousandths of em unit.

Returns
The maximum distance to the right of the glyph origin of the font in thousandths of em unit.

Definition at line 2168 of file TrueType.cs.

◆ Get1000EmXMin()

double VectSharp.TrueTypeFile.Get1000EmXMin ( )

Computes the maximum distance to the left of the glyph origin of the font, in thousandths of em unit.

Returns
The maximum distance to the left of the glyph origin of the font in thousandths of em unit.

Definition at line 2177 of file TrueType.cs.

◆ Get1000EmYMax()

double VectSharp.TrueTypeFile.Get1000EmYMax ( )

Computes the maximum height over the baseline of the font, in thousandths of em unit.

Returns
The maximum height over the baseline of the font in thousandths of em unit.

Definition at line 2150 of file TrueType.cs.

◆ Get1000EmYMin()

double VectSharp.TrueTypeFile.Get1000EmYMin ( )

Computes the maximum depth below the baseline of the font, in thousandths of em unit.

Returns
The maximum depth below the baseline of the font in thousandths of em unit.

Definition at line 2159 of file TrueType.cs.

◆ GetFirstCharIndex()

ushort VectSharp.TrueTypeFile.GetFirstCharIndex ( )

Returns the index of the first character glyph represented by the font.

Returns
The index of the first character glyph represented by the font.

Definition at line 1920 of file TrueType.cs.

◆ GetFontFamilyName()

string VectSharp.TrueTypeFile.GetFontFamilyName ( )

Obtains the font family name from the TrueType file.

Returns
The font family name, if available; null otherwise.

Definition at line 1846 of file TrueType.cs.

◆ GetFontName()

string VectSharp.TrueTypeFile.GetFontName ( )

Obtains the PostScript font name from the TrueType file.

Returns
The PostScript font name, if available; null otherwise.

Definition at line 1901 of file TrueType.cs.

◆ GetFullFontFamilyName()

string VectSharp.TrueTypeFile.GetFullFontFamilyName ( )

Obtains the full font family name from the TrueType file.

Returns
The full font family name, if available; null otherwise.

Definition at line 1873 of file TrueType.cs.

◆ GetGlyphIndex()

int VectSharp.TrueTypeFile.GetGlyphIndex ( char  glyph)

Determines the index of the glyph corresponding to a certain character.

Parameters
glyphThe character whose glyph is sought.
Returns
The index of the glyph in the TrueType file.

Definition at line 2010 of file TrueType.cs.

◆ GetGlyphPath() [1/2]

TrueTypePoint [][] VectSharp.TrueTypeFile.GetGlyphPath ( char  glyph,
double  size 
)

Get the path that describes the shape of a glyph.

Parameters
glyphThe glyph whose path is sought.
sizeThe font size to be used for the font coordinates.
Returns
An array of contours, each of which is itself an array of TrueType points.

Definition at line 2072 of file TrueType.cs.

◆ GetGlyphPath() [2/2]

TrueTypePoint [][] VectSharp.TrueTypeFile.GetGlyphPath ( int  glyphIndex,
double  size 
)

Get the path that describes the shape of a glyph.

Parameters
glyphIndexThe index of the glyph whose path is sought.
sizeThe font size to be used for the font coordinates.
Returns
An array of contours, each of which is itself an array of TrueType points.

Definition at line 2061 of file TrueType.cs.

◆ GetItalicAngle()

double VectSharp.TrueTypeFile.GetItalicAngle ( )

Computes the italic angle for the current font, in thousandths of em unit. This is computed from the vertical and is negative for text that leans forwards.

Returns

Definition at line 2320 of file TrueType.cs.

◆ GetLastCharIndex()

ushort VectSharp.TrueTypeFile.GetLastCharIndex ( )

Returns the index of the last character glyph represented by the font.

Returns
The index of the last character glyph represented by the font.

Definition at line 1931 of file TrueType.cs.

◆ IsBold()

bool VectSharp.TrueTypeFile.IsBold ( )

Determines whether the typeface is Bold or not.

Returns
A bool indicating whether the typeface is Bold or not

Definition at line 1965 of file TrueType.cs.

◆ IsFixedPitch()

bool VectSharp.TrueTypeFile.IsFixedPitch ( )

Determines whether the typeface is fixed-pitch (aka monospaces) or not.

Returns
A bool indicating whether the typeface is fixed-pitch (aka monospaces) or not.

Definition at line 1976 of file TrueType.cs.

◆ IsItalic()

bool VectSharp.TrueTypeFile.IsItalic ( )

Determines whether the typeface is Italic or Oblique or not.

Returns
A bool indicating whether the typeface is Italic or Oblique or not.

Definition at line 1943 of file TrueType.cs.

◆ IsOblique()

bool VectSharp.TrueTypeFile.IsOblique ( )

Determines whether the typeface is Oblique or not.

Returns
A bool indicating whether the typeface is Oblique or not.

Definition at line 1954 of file TrueType.cs.

◆ IsScript()

bool VectSharp.TrueTypeFile.IsScript ( )

Determines whether the typeface is a script typeface or not.

Returns
A bool indicating whether the typeface is a script typeface or not.

Definition at line 1998 of file TrueType.cs.

◆ IsSerif()

bool VectSharp.TrueTypeFile.IsSerif ( )

Determines whether the typeface is serifed or not.

Returns
A bool indicating whether the typeface is serifed or not.

Definition at line 1987 of file TrueType.cs.

◆ SubsetFont()

TrueTypeFile VectSharp.TrueTypeFile.SubsetFont ( string  charactersToInclude,
bool  consolidateAt32 = false,
Dictionary< char, char >  outputEncoding = null 
)

Create a subset of the TrueType file, containing only the glyphs for the specified characters.

Parameters
charactersToIncludeA string containing the characters for which the glyphs should be included.
consolidateAt32If true, the character map is rearranged so that the included glyphs start at the unicode U+0032 control point.
outputEncodingIf consolidateAt32 is true, entries will be added to this dictionary mapping the original characters to the new map (that starts at U+0033).
Returns

Definition at line 562 of file TrueType.cs.

Property Documentation

◆ FontStream

Stream VectSharp.TrueTypeFile.FontStream
get

A stream pointing to the TrueType file source (either on disk or in memory). Never dispose this stream directly; if you really need to, call Destroy instead.

Definition at line 47 of file TrueType.cs.


The documentation for this class was generated from the following file: