Scribus
Open source desktop publishing at your fingertips
ScFace Class Reference

Base Class ScFace : This is a total rewrite of the old Foi class. More...

#include <scface.h>

Classes

struct  GlyphData
 
class  ScFaceData
 see accessors for ScFace for docs More...
 

Public Types

enum  Status {
  UNKNOWN, LOADED, CHECKED, BROKENGLYPHS,
  BROKEN, NULLFACE
}
 
enum  FontType {
  TYPE0, TYPE1, TYPE3, TTF,
  CFF, OTF, UNKNOWN_TYPE
}
 
enum  FontFormat {
  PFA, PFB, TYPE2, TYPE42,
  SFNT, TTCF, UNKNOWN_FORMAT
}
 
typedef uint gid_type
 
typedef uint ucs4_type
 
typedef QMap< gid_type, std::pair< ucs4_type, QString > > FaceEncoding
 

Public Member Functions

 ScFace (const ScFace &other)
 
bool isNone () const
 test for null object
 
bool isSymbolic () const
 test if font is a symbolic font
 
ScFaceoperator= (const ScFace &other)
 
bool operator== (const ScFace &other) const
 
bool operator!= (const ScFace &other) const
 
bool EmbedFont (QByteArray &str)
 
void RawData (QByteArray &bb)
 
bool glyphNames (QMap< gid_type, std::pair< ucs4_type, QString > > &gList)
 
void increaseUsage () const
 prevent unloading of face data
 
void decreaseUsage () const
 unload face data if not used any more
 
void unload () const
 unload face data. It will be reloaded on need
 
QString scName () const
 the name Scribus uses for this font
 
QString replacementName () const
 the name of the font which was used for replacement
 
QString replacementForDoc () const
 the name of the font which was used for replacement
 
bool isReplacement () const
 check if this is a replacement font
 
ScFace mkReplacementFor (QString name, QString doc)
 makes a repalcement font for font "name" using this fonts data
 
void chReplacementTo (ScFace &other, QString doc)
 
QString psName () const
 the name PostScript uses for this font
 
QString fontPath () const
 the physical location of the fontfile
 
QString fontFilePath () const
 the file path of the fontfile
 
int faceIndex () const
 if the fontfile contains more than one face, the index, else -1
 
QString localForDocument () const
 path name of the document this face is local to
 
FontType type () const
 font type, eg. Type1 or TTF
 
FontFormat format () const
 font format, which might be a little more complicated
 
bool usable () const
 test if this face can be used in documents
 
bool outline () const
 test if this face should be outlined in documents
 
bool embedPs () const
 test if this face can be embedded in PS/PDF
 
bool subset () const
 test if this face can be embedded as outlines in PS/PDF
 
void usable (bool flag)
 
void embedPs (bool flag)
 
void subset (bool flag)
 
void outline (bool flag)
 
bool hasNames () const
 deprecated? tells if the face has PS names
 
bool isStroked () const
 tells if this font is an outline font
 
bool isFixedPitch () const
 tells if this font is a fixed pitch font
 
bool isOTF () const
 tells if this is an OTF/CFF font
 
gid_type maxGlyph () const
 returns the highest glyph index in this face
 
QString family () const
 returns the font family as seen by Scribus
 
QString style () const
 returns the font style as seen by Scribus (eg. bold, Italic)
 
QString variant () const
 returns an additional discriminating String for this face
 
QString pdfAscentAsString () const
 
QString pdfDescentAsString () const
 
QString pdfCapHeightAsString () const
 
QString pdfFontBBoxAsString () const
 
QString italicAngleAsString () const
 
qreal ascent (qreal sz=1.0) const
 
qreal descent (qreal sz=1.0) const
 
qreal xHeight (qreal sz=1.0) const
 
qreal capHeight (qreal sz=1.0) const
 
qreal height (qreal sz=1.0) const
 
qreal strikeoutPos (qreal sz=1.0) const
 
qreal underlinePos (qreal sz=1.0) const
 
qreal strokeWidth (qreal sz=1.0) const
 
qreal maxAdvanceWidth (qreal sz=1.0) const
 
QString stemV (qreal sz=1.0) const
 deprecated
 
QString italicAngle (qreal sz=1.0) const
 deprecated
 
QString fontBBox (qreal sz=1.0) const
 deprecated
 
QMap< QString, QString > fontDictionary (qreal sz=1.0) const
 returns a map of values used for font dictionaries in PS/PDF
 
qreal glyphWidth (gid_type gl, qreal sz=1.0) const
 returns the glyphs normal advance width at size 'sz'
 
qreal glyphKerning (gid_type gl1, gid_type gl2, qreal sz=1.0) const
 returns the glyph kerning between 'gl1' and 'gl2' at size 'sz'
 
GlyphMetrics glyphBBox (gid_type gl, qreal sz=1.0) const
 returns the glyphs bounding box at size 'sz', ie. the area where this glyph will produce marks
 
FPointArray glyphOutline (gid_type gl, qreal sz=1.0) const
 returns the glyph's outline as a cubic Bezier path
 
FPoint glyphOrigin (gid_type gl, qreal sz=1.0) const
 returns the glyph's origin FIXME: what's that exactly?
 
bool canRender (QChar ch) const
 test if the face can render this char
 
gid_type char2CMap (QChar ch) const
 translate unicode to glyph index
 
qreal charWidth (QChar ch, qreal sz=1.0, QChar ch2=QChar(0)) const
 returns the combined glyph width and kerning for 'ch' if followed by 'ch2'
 
qreal realCharWidth (QChar ch, qreal sz=1.0) const
 deprecated, see glyphBBox()
 
qreal realCharHeight (QChar ch, qreal sz=1.0) const
 deprecated, see glyphBBox()
 
qreal realCharAscent (QChar ch, qreal sz=1.0) const
 deprecated, see glyphBBox()
 
qreal realCharDescent (QChar ch, qreal sz=1.0) const
 deprecated, see glyphBBox()
 

Static Public Member Functions

static const ScFacenone ()
 used as a null object
 

Static Public Attributes

static const gid_type CONTROL_GLYPHS = 2000000000
 

Friends

class SCFonts
 

Detailed Description

Base Class ScFace : This is a total rewrite of the old Foi class.

It uses a shared private implementation which must be a subclass of ScFontData. ScFace objects are quite small and can be handled like value objects. Reference counting ensures that the shared data is freed when the last ScFace object is destructed.

ScFaceData has caches for face and glyph data. load() fills those caches for face data, loadGlyph() fills the cache for glyphs. caches are always filled by need, so you can call unload() any time (well, better not multithreaded...) without producing errors. the increaseUsage() and decreaseUsage() keep track of at how many places a face is used and automatically unload when the count reaches zero. Other data is recalculated on demand. The implementation can choose to do its own caching for this data.

ScFace uses a sophisticated lifecycle which controls the state of initialisation and the performed checks. the normal lilecycle goes:

UNKNOWN –load()–> LOADED –checkAllGlyphs()–> CHECKED

If the face can not be loaded, the status changes to BROKEN. If only some glyphs can not be loaded, the status changes to BROKENGLYPHS. These fonts can still be used and subsetted(outlined), but not embedded.

ScFace constructors are only accessible to the ScFonts class which does some checking before creating a new ScFace. These checks are recorded in a cache and only reexecuted if the font file changes. The field 'cachedStatus' allows load() to switch directly to one of the states BROKEN, CHECKED or BROKENGLYPHS if this state was reached during a previous run of Scribus.

Member Function Documentation

bool ScFace::operator== ( const ScFace other) const

two ScFaces are equal if they either are both NULLFACEs or they agree on family, style, variant and fontpath


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