Source: scribus/scfonts.h
|
|
|
|
#ifndef SCFONTS_H
#define SCFONTS_H
#include
#include
#include
#include
#include "scfonts_encoding.h"
/* Base Class Foi : This is subclassed by a class to handle Type1 fonts, a class
to handle TrueType fonts, and potentially any other type that becomes appropriate in
the future.
Note the virtual destructor, needed to ensure that the correct destructor is called
for subclasses
The RealName field has been changed from a data member to a member function.
This is because the only place the PostScript real name of a font is required is
the printing code, so it's cheaper to extract this information only when it is
required, for just the used fonts, than for every one of potentially hundreds at
application startup! This also allows for the fact that truetype fonts will require
a different method of extracting their names.
One implication of using a base class/subclass model for fonts: It is no longer
possible to store the Foi structures in a QMap. This is because QMap allocates
its own structures, and copies the supplied data to them. A QMap
would demote all subclasses to Foi classes, and hence break the polymorphism.
QDict can be used instead, with very little change to the rest of the code, since
it stores references to the data instead of copying the data. With AutoDelete set
to true, it will automatically dispose of all data when its destructor is called,
so there are no extra cleaning-up chores to take care of.
*/
class Foi
{
public:
Foi(QString scname, QString path, bool embedps, SCFonts_Encoding &encoding);
virtual ~Foi() {};
virtual QString RealName();
virtual bool EmbedFont(QString &str);
virtual bool ReadMetrics();
QString SCName;
QString Datei;
QFont Font;
bool EmbedPS;
SCFonts_Encoding &Encoding;
static SCFonts_Encoding StdEncoding;
static SCFonts_Encoding TTFEncoding;
bool HasMetrics;
float CharWidth[256];
QString Ascent;
QString CapHeight;
QString Descender;
QString ItalicAngle;
QString StdVW;
QString FontEnc;
bool IsFixedPitch;
QString FontBBox;
bool UseFont;
};
/* Main class SCFonts.
Subclass of QDict.
This class replaces the previous SCFonts typedef, and is nearly as convenient.
The chief difference from the application point of view is that while data can
still be retrieved with SCFonts[fontname], this cannot be used to add members.
Since the only piece of code that will generally add members is scfonts.h, this
is not a major problem.
*/
class SCFonts : public QDict
{
public:
SCFonts() : QDict(), FontPath(true), Encoding("ISOenc.txt")
{
setAutoDelete(true);
}
~SCFonts();
void GetFonts(QString pf);
void FreeExtraFonts();
private:
void AddPath(QString p);
void AddScalableFonts(const QString &path);
void AddUserPath(QString pf);
void AddXFontServerPath();
void AddXFontPath();
QStrList FontPath;
QString ExtraPath;
SCFonts_Encoding Encoding;
};
typedef QDictIterator SCFontsIterator;
#endif
Generated by: paul on T6.linux on Tue Mar 18 23:32:13 2003, using kdoc 2.0a54. |