Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtGui.QRawFont Class Reference

The QRawFont class provides access to a single physical instance of a font. More...

Inheritance diagram for QtGui.QRawFont:
Collaboration diagram for QtGui.QRawFont:

Public Types

enum  AntialiasingType { PixelAntialiasing = 0, SubPixelAntialiasing = 1 }
  More...
 

Public Member Functions

override bool Equals (object o)
 
override int GetHashCode ()
 
 QRawFont ()
 
 
 QRawFont (QRawFont other)
 
 
 QRawFont (QByteArray fontData, double pixelSize, QFont.HintingPreference hintingPreference=QFont.HintingPreference.PreferDefaultHinting)
 
 
 QRawFont (string fileName, double pixelSize, QFont.HintingPreference hintingPreference=QFont.HintingPreference.PreferDefaultHinting)
 
 
virtual void CreateProxy ()
 
new bool AdvancesForGlyphIndexes (ref uint glyphIndexes, QPointF advances, int numGlyphs)
 
 
new
System.Collections.Generic.List
< QPointF
AdvancesForGlyphIndexes (System.Collections.Generic.List< System.UInt32 > glyphIndexes)
 
 
new QImage AlphaMapForGlyph (uint glyphIndex, QRawFont.AntialiasingType antialiasingType=QRawFont.AntialiasingType.SubPixelAntialiasing)
 
 
new QImage AlphaMapForGlyph (uint glyphIndex, QRawFont.AntialiasingType antialiasingType, QTransform transform)
 
 
new double Ascent ()
 
 
new double AverageCharWidth ()
 
 
new double Descent ()
 
 
new string FamilyName ()
 
 
new QByteArray FontTable (string tagName)
 
 
new bool GlyphIndexesForChars (QChar chars, int numChars, ref uint glyphIndexes, ref int numGlyphs)
 
 
new
System.Collections.Generic.List
< System.UInt32 > 
GlyphIndexesForString (string text)
 
 
new QFont.HintingPreference HintingPreference ()
 
 
new bool IsValid ()
 
 
new double Leading ()
 
 
new void LoadFromData (QByteArray fontData, double pixelSize, QFont.HintingPreference hintingPreference)
 
 
new void LoadFromFile (string fileName, double pixelSize, QFont.HintingPreference hintingPreference)
 
 
new double MaxCharWidth ()
 
 
new QPainterPath PathForGlyph (uint glyphIndex)
 
 
new QFont.Style Style ()
 
 
new string StyleName ()
 
 
new
System.Collections.Generic.List
< QFontDatabase.WritingSystem
SupportedWritingSystems ()
 
 
new bool SupportsCharacter (QChar character)
 
 
new bool SupportsCharacter (uint ucs4)
 
 
new double UnitsPerEm ()
 
 
new int Weight ()
 
 
new double xHeight ()
 
 
new void Dispose ()
 

Static Public Member Functions

static QRawFont FromFont (QFont font, QFontDatabase.WritingSystem writingSystem=QFontDatabase.WritingSystem.Any)
 
 
static bool operator!= (QRawFont arg1, QRawFont arg2)
 
 
static bool operator== (QRawFont arg1, QRawFont arg2)
 
 

Protected Member Functions

 QRawFont (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

new double PixelSize [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

The QRawFont class provides access to a single physical instance of a font.

Note: QRawFont is a low level class. For most purposes QFont is a more appropriate class.

Most commonly, when presenting text in a user interface, the exact fonts used to render the characters is to some extent unknown. This can be the case for several reasons: For instance, the actual, physical fonts present on the target system could be unexpected to the developers, or the text could contain user selected styles, sizes or writing systems that are not supported by font chosen in the code.

Therefore, Qt's QFont class really represents a query for fonts. When text is interpreted, Qt will do its best to match the text to the query, but depending on the support, different fonts can be used behind the scenes.

For most use cases, this is both expected and necessary, as it minimizes the possibility of text in the user interface being undisplayable. In some cases, however, more direct control over the process might be useful. It is for these use cases the QRawFont class exists.

A QRawFont object represents a single, physical instance of a given font in a given pixel size. I.e. in the typical case it represents a set of TrueType or OpenType font tables and uses a user specified pixel size to convert metrics into logical pixel units. It can be used in combination with the QGlyphRun class to draw specific glyph indexes at specific positions, and also have accessors to some relevant data in the physical font.

QRawFont only provides support for the main font technologies: GDI and DirectWrite on Windows platforms, FreeType on Symbian and Linux platforms and CoreText on Mac OS X. For other font back-ends, the APIs will be disabled.

QRawFont can be constructed in a number of ways:

It can be constructed by calling QTextLayout::glyphs() or QTextFragment::glyphs(). The returned QGlyphs objects will contain QRawFont objects which represent the actual fonts used to render each portion of the text.

It can be constructed by passing a QFont object to QRawFont::fromFont(). The function will return a QRawFont object representing the font that will be selected as response to the QFont query and the selected writing system.

It can be constructed by passing a file name or QByteArray directly to the QRawFont constructor, or by calling loadFromFile() or loadFromData(). In this case, the font will not be registered in QFontDatabase, and it will not be available as part of regular font selection.

QRawFont is considered local to the thread in which it is constructed (either using a constructor, or by calling loadFromData() or loadFromFile()). The QRawFont cannot be moved to a different thread, but will have to be recreated in the thread in question.

Note: For the requirement of caching glyph indexes and font selections for static text to avoid reshaping and relayouting in the inner loop of an application, a better choice is the QStaticText class, since it optimizes the memory cost of the cache and also provides the possibility of paint engine specific caches for an additional speed-up.

Member Enumeration Documentation

This enum represents the different ways a glyph can be rasterized in the function alphaMapForGlyph().

Enumerator:
PixelAntialiasing 

Will rasterize by measuring the coverage of the shape on whole pixels. The returned image contains the alpha values of each pixel based on the coverage of the glyph shape.

SubPixelAntialiasing 

Will rasterize by measuring the coverage of each subpixel, returning a separate alpha value for each of the red, green and blue components of each pixel.

Constructor & Destructor Documentation

QtGui.QRawFont.QRawFont ( System.Type  dummy)
protected
QtGui.QRawFont.QRawFont ( )

Constructs an invalid QRawFont.

QtGui.QRawFont.QRawFont ( QRawFont  other)

Creates a QRawFont which is a copy of other.

QtGui.QRawFont.QRawFont ( QByteArray  fontData,
double  pixelSize,
QFont.HintingPreference  hintingPreference = QFont.HintingPreference.PreferDefaultHinting 
)

Constructs an invalid QRawFont.

QtGui.QRawFont.QRawFont ( string  fileName,
double  pixelSize,
QFont.HintingPreference  hintingPreference = QFont.HintingPreference.PreferDefaultHinting 
)

Constructs an invalid QRawFont.

Member Function Documentation

new bool QtGui.QRawFont.AdvancesForGlyphIndexes ( ref uint  glyphIndexes,
QPointF  advances,
int  numGlyphs 
)

Returns the QRawFont's advances for each of the glyphIndexes in pixel units. The advances give the distance from the position of a given glyph to where the next glyph should be drawn to make it appear as if the two glyphs are unspaced.

See also QTextLine::horizontalAdvance() and QFontMetricsF::width().

new System.Collections.Generic.List<QPointF> QtGui.QRawFont.AdvancesForGlyphIndexes ( System.Collections.Generic.List< System.UInt32 >  glyphIndexes)

Returns the QRawFont's advances for each of the glyphIndexes in pixel units. The advances give the distance from the position of a given glyph to where the next glyph should be drawn to make it appear as if the two glyphs are unspaced.

See also QTextLine::horizontalAdvance() and QFontMetricsF::width().

new QImage QtGui.QRawFont.AlphaMapForGlyph ( uint  glyphIndex,
QRawFont.AntialiasingType  antialiasingType = QRawFont.AntialiasingType.SubPixelAntialiasing 
)

This function returns a rasterized image of the glyph at the given glyphIndex in the underlying font, using the transform specified. If the QRawFont is not valid, this function will return an invalid QImage.

If antialiasingType is set to QRawFont::SubPixelAntialiasing, then the resulting image will be in QImage::Format_RGB32 and the RGB values of each pixel will represent the subpixel opacities of the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of QImage::Format_Indexed8 and each pixel will contain the opacity of the pixel in the rasterization.

See also pathForGlyph() and QPainter::drawGlyphRun().

new QImage QtGui.QRawFont.AlphaMapForGlyph ( uint  glyphIndex,
QRawFont.AntialiasingType  antialiasingType,
QTransform  transform 
)

This function returns a rasterized image of the glyph at the given glyphIndex in the underlying font, using the transform specified. If the QRawFont is not valid, this function will return an invalid QImage.

If antialiasingType is set to QRawFont::SubPixelAntialiasing, then the resulting image will be in QImage::Format_RGB32 and the RGB values of each pixel will represent the subpixel opacities of the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of QImage::Format_Indexed8 and each pixel will contain the opacity of the pixel in the rasterization.

See also pathForGlyph() and QPainter::drawGlyphRun().

new double QtGui.QRawFont.Ascent ( )

Returns the ascent of this QRawFont in pixel units.

See also QFontMetricsF::ascent().

new double QtGui.QRawFont.AverageCharWidth ( )

Returns the average character width of this QRawFont in pixel units.

See also QFontMetricsF::averageCharWidth().

virtual void QtGui.QRawFont.CreateProxy ( )
virtual
new double QtGui.QRawFont.Descent ( )

Returns the descent of this QRawFont in pixel units.

See also QFontMetricsF::descent().

new void QtGui.QRawFont.Dispose ( )
override bool QtGui.QRawFont.Equals ( object  o)
new string QtGui.QRawFont.FamilyName ( )

Returns the family name of this QRawFont.

new QByteArray QtGui.QRawFont.FontTable ( string  tagName)

Retrieves the sfnt table named tagName from the underlying physical font, or an empty byte array if no such table was found. The returned font table's byte order is Big Endian, like the sfnt format specifies. The tagName must be four characters long and should be formatted in the default endianness of the current platform.

static QRawFont QtGui.QRawFont.FromFont ( QFont  font,
QFontDatabase.WritingSystem  writingSystem = QFontDatabase.WritingSystem.Any 
)
static

Fetches the physical representation based on a font query. The physical font returned is the font that will be preferred by Qt in order to display text in the selected writingSystem.

override int QtGui.QRawFont.GetHashCode ( )
new bool QtGui.QRawFont.GlyphIndexesForChars ( QChar  chars,
int  numChars,
ref uint  glyphIndexes,
ref int  numGlyphs 
)

Converts a string of unicode points to glyph indexes using the CMAP table in the underlying font. The function works like glyphIndexesForString() except it take an array (chars), the results will be returned though glyphIndexes array and number of glyphs will be set in numGlyphs. The size of glyphIndexes array must be at least numChars, if that's still not enough, this function will return false, then you can resize glyphIndexes from the size returned in numGlyphs.

See also glyphIndexesForString(), advancesForGlyphIndexes(), QGlyphRun, QTextLayout::glyphRuns(), and QTextFragment::glyphRuns().

new System.Collections.Generic.List<System.UInt32> QtGui.QRawFont.GlyphIndexesForString ( string  text)

Converts the string of unicode points given by text to glyph indexes using the CMAP table in the underlying font, and returns a vector containing the result.

Note that, in cases where there are other tables in the font that affect the shaping of the text, the returned glyph indexes will not correctly represent the rendering of the text. To get the correctly shaped text, you can use QTextLayout to lay out and shape the text, then call QTextLayout::glyphs() to get the set of glyph index list and QRawFont pairs.

See also advancesForGlyphIndexes(), glyphIndexesForChars(), QGlyphRun, QTextLayout::glyphRuns(), and QTextFragment::glyphRuns().

new QFont.HintingPreference QtGui.QRawFont.HintingPreference ( )

Returns the hinting preference used to construct this QRawFont.

See also QFont::hintingPreference().

new bool QtGui.QRawFont.IsValid ( )

Returns true if the QRawFont is valid and false otherwise.

new double QtGui.QRawFont.Leading ( )

Returns the leading of this QRawFont in pixel units.

See also QFontMetricsF::leading().

new void QtGui.QRawFont.LoadFromData ( QByteArray  fontData,
double  pixelSize,
QFont.HintingPreference  hintingPreference 
)

Replaces the current QRawFont with the font contained in the supplied fontData for the size (in pixels) given by pixelSize, and using the hinting preference specified by hintingPreference.

The fontData must contain a TrueType or OpenType font.

See also loadFromFile().

new void QtGui.QRawFont.LoadFromFile ( string  fileName,
double  pixelSize,
QFont.HintingPreference  hintingPreference 
)

Replaces the current QRawFont with the contents of the file referenced by fileName for the size (in pixels) given by pixelSize, and using the hinting preference specified by hintingPreference.

The file must reference a TrueType or OpenType font.

See also loadFromData().

new double QtGui.QRawFont.MaxCharWidth ( )

Returns the width of the widest character in the font.

See also QFontMetricsF::maxWidth().

static bool QtGui.QRawFont.operator!= ( QRawFont  arg1,
QRawFont  arg2 
)
static

Returns true if this QRawFont is not equal to other. Otherwise, returns false.

static bool QtGui.QRawFont.operator== ( QRawFont  arg1,
QRawFont  arg2 
)
static

Returns true if this QRawFont is equal to other. Otherwise, returns false.

new QPainterPath QtGui.QRawFont.PathForGlyph ( uint  glyphIndex)

This function returns the shape of the glyph at a given glyphIndex in the underlying font if the QRawFont is valid. Otherwise, it returns an empty QPainterPath.

The returned glyph will always be unhinted.

See also alphaMapForGlyph() and QPainterPath::addText().

new QFont.Style QtGui.QRawFont.Style ( )

Returns the style of this QRawFont.

See also QFont::style().

new string QtGui.QRawFont.StyleName ( )

Returns the style name of this QRawFont.

See also QFont::styleName().

new System.Collections.Generic.List<QFontDatabase.WritingSystem> QtGui.QRawFont.SupportedWritingSystems ( )

Returns a list of writing systems supported by the font according to designer supplied information in the font file. Please note that this does not guarantee support for a specific unicode point in the font. You can use the supportsCharacter() to check support for a single, specific character.

Note: The list is determined based on the unicode ranges and codepage ranges set in the font's OS/2 table and requires such a table to be present in the underlying font file.

See also supportsCharacter().

new bool QtGui.QRawFont.SupportsCharacter ( QChar  character)

Returns true if the font has a glyph that corresponds to the given character.

See also supportedWritingSystems().

new bool QtGui.QRawFont.SupportsCharacter ( uint  ucs4)

Returns true if the font has a glyph that corresponds to the given character.

See also supportedWritingSystems().

new double QtGui.QRawFont.UnitsPerEm ( )

Returns the number of design units define the width and height of the em square for this QRawFont. This value is used together with the pixel size when converting design metrics to pixel units, as the internal metrics are specified in design units and the pixel size gives the size of 1 em in pixels.

See also pixelSize() and setPixelSize().

new int QtGui.QRawFont.Weight ( )

Returns the weight of this QRawFont.

See also QFont::weight().

new double QtGui.QRawFont.xHeight ( )

Returns the xHeight of this QRawFont in pixel units.

See also QFontMetricsF::xHeight().

Member Data Documentation

SmokeInvocation QtGui.QRawFont.interceptor
protected

Property Documentation

new double QtGui.QRawFont.PixelSize
getset

Returns the pixel size set for this QRawFont. The pixel size affects how glyphs are rasterized, the size of glyphs returned by pathForGlyph(), and is used to convert internal metrics from design units to logical pixel units.

Sets the pixel size with which this font should be rendered to pixelSize.

virtual System.IntPtr QtGui.QRawFont.SmokeObject
getset