28 #include "fpointarray.h"
76 enum Status { UNKNOWN, LOADED, CHECKED, BROKENGLYPHS, BROKEN, NULLFACE };
77 enum FontType { TYPE0, TYPE1, TYPE3, TTF, CFF, OTF, UNKNOWN_TYPE };
78 enum FontFormat { PFA, PFB, TYPE2, TYPE42,
80 SFNT, TTCF, UNKNOWN_FORMAT };
82 typedef uint gid_type;
83 typedef uint ucs4_type;
84 typedef QMap<gid_type, std::pair<ucs4_type, QString> > FaceEncoding;
86 static const gid_type CONTROL_GLYPHS = 2000000000;
96 GlyphData() : Outlines(), x(0), y(0), bbox_width(1), bbox_ascent(1), bbox_descent(0), broken(
true) {}
118 mutable ScFace::Status status;
119 ScFace::FontType typeCode;
120 ScFace::FontFormat formatCode;
140 mutable QHash<gid_type, qreal> m_glyphWidth;
141 mutable QHash<gid_type, GlyphData> m_glyphOutline;
146 virtual void load()
const
148 m_glyphWidth.clear();
149 m_glyphOutline.clear();
152 status = qMax(cachedStatus, ScFace::LOADED);
155 virtual void unload()
const
157 m_glyphWidth.clear();
158 m_glyphOutline.clear();
161 status = ScFace::UNKNOWN;
164 virtual void loadGlyph(gid_type )
const {}
167 virtual qreal ascent(qreal sz)
const {
return sz; }
168 virtual QString pdfAscentAsString()
const {
return "0" ; }
169 virtual QString pdfDescentAsString()
const {
return "0"; }
170 virtual QString pdfCapHeightAsString()
const {
return "0"; }
171 virtual QString pdfFontBBoxAsString()
const {
return "0 0 0 0"; }
172 virtual QString italicAngleAsString()
const {
return "0"; }
173 virtual qreal descent(qreal )
const {
return 0.0; }
174 virtual qreal xHeight(qreal sz)
const {
return sz; }
175 virtual qreal capHeight(qreal sz)
const {
return sz; }
176 virtual qreal height(qreal sz)
const {
return sz; }
177 virtual qreal strikeoutPos(qreal sz)
const {
return sz / 2; }
178 virtual qreal underlinePos(qreal )
const {
return -1.0; }
179 virtual qreal strokeWidth(qreal )
const {
return 0.1; }
180 virtual qreal maxAdvanceWidth(qreal sz)
const {
return sz; }
181 virtual gid_type
char2CMap(QChar )
const {
return 0; }
182 virtual qreal
glyphKerning(gid_type gl1, gid_type gl2, qreal sz)
const;
185 virtual bool EmbedFont(QByteArray &)
const {
return false; }
186 virtual void RawData(QByteArray & )
const {}
188 virtual bool hasNames()
const {
return hasGlyphNames; }
189 virtual bool glyphNames(QMap<gid_type, std::pair<ucs4_type, QString> >& gList)
const;
192 virtual qreal
glyphWidth(gid_type gl, qreal sz)
const;
196 virtual bool isSymbolic()
const {
return false; }
209 bool isNone()
const {
return m->status == NULLFACE; }
219 bool operator!=(
const ScFace& other)
const {
return ! (*
this == other); }
222 bool EmbedFont(QByteArray &str);
223 void RawData(QByteArray & bb);
224 bool glyphNames(QMap<gid_type, std::pair<ucs4_type, QString> >& gList);
236 QString
scName()
const {
return replacedName.isEmpty() ? m->scName : replacedName; }
250 result.replacedName = name;
251 result.replacedInDoc = doc;
255 void chReplacementTo(
ScFace& other, QString doc) {
256 QString oldName = replacedName;
258 replacedName = oldName;
263 QString
psName()
const {
return m->psName; }
266 QString
fontPath()
const {
return m->faceIndex >= 0 ? QString(
"%1(%2)").arg(m->fontFile).arg(m->faceIndex+1) : m->fontFile; }
278 FontType
type()
const {
return m->typeCode; }
281 FontFormat
format()
const {
return m->formatCode; }
290 bool embedPs()
const {
return m->embedPs && m->status < BROKENGLYPHS; }
293 bool subset()
const {
return m->subset && m->status < BROKEN; }
295 void usable(
bool flag) { m->usable = flag; }
296 void embedPs(
bool flag) { m->embedPs = flag; }
297 void subset(
bool flag) { m->subset = flag; }
298 void outline(
bool flag) { m->outline = flag; }
310 bool isOTF()
const {
return m->typeCode == OTF; }
316 QString
family()
const {
return m->family; }
319 QString
style()
const {
return m->style; }
322 QString
variant()
const {
return m->variant; }
325 QString pdfAscentAsString()
const;
326 QString pdfDescentAsString()
const;
327 QString pdfCapHeightAsString()
const;
328 QString pdfFontBBoxAsString()
const;
329 QString italicAngleAsString()
const;
330 qreal ascent(qreal sz=1.0)
const;
331 qreal descent(qreal sz=1.0)
const;
332 qreal xHeight(qreal sz=1.0)
const;
333 qreal capHeight(qreal sz=1.0)
const;
334 qreal height(qreal sz=1.0)
const;
335 qreal strikeoutPos(qreal sz=1.0)
const;
336 qreal underlinePos(qreal sz=1.0)
const;
337 qreal strokeWidth(qreal sz=1.0)
const;
338 qreal maxAdvanceWidth(qreal sz=1.0)
const;
350 QMap<QString,QString>
fontDictionary(qreal sz=1.0)
const {
return m->fontDictionary(sz); }
354 qreal
glyphWidth(gid_type gl, qreal sz=1.0)
const {
return m->glyphWidth(gl, sz); }
357 qreal
glyphKerning(gid_type gl1, gid_type gl2, qreal sz=1.0)
const {
return qMax(gl1,gl2) < CONTROL_GLYPHS ? m->glyphKerning(gl1, gl2, sz) : 0; }
377 qreal
charWidth(QChar ch, qreal sz=1.0, QChar ch2 = QChar(0))
const;
397 QString replacedName;
398 QString replacedInDoc;
401 void checkAllGlyphs();
402 gid_type emulateGlyph(QChar c)
const;
int usage
controls load()
Definition: scface.h:106
QString style() const
returns the font style as seen by Scribus (eg. bold, Italic)
Definition: scface.h:319
bool isOTF() const
tells if this is an OTF/CFF font
Definition: scface.h:310
static const ScFace & none()
used as a null object
Definition: scface.cpp:198
QString fontBBox(qreal sz=1.0) const
deprecated
Definition: scface.h:347
gid_type maxGlyph() const
returns the highest glyph index in this face
Definition: scface.h:313
QString fontPath() const
the physical location of the fontfile
Definition: scface.h:266
gid_type char2CMap(QChar ch) const
translate unicode to glyph index
Definition: scface.cpp:365
qreal glyphKerning(gid_type gl1, gid_type gl2, qreal sz=1.0) const
returns the glyph kerning between 'gl1' and 'gl2' at size 'sz'
Definition: scface.h:357
QString fontFilePath() const
the file path of the fontfile
Definition: scface.h:269
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 ...
Definition: scface.h:360
bool embedPs() const
test if this face can be embedded in PS/PDF
Definition: scface.h:290
void decreaseUsage() const
unload face data if not used any more
Definition: scface.cpp:328
FontFormat format() const
font format, which might be a little more complicated
Definition: scface.h:281
bool canRender(QChar ch) const
test if the face can render this char
Definition: scface.cpp:383
qreal realCharDescent(QChar ch, qreal sz=1.0) const
deprecated, see glyphBBox()
Definition: scface.h:389
bool subset() const
test if this face can be embedded as outlines in PS/PDF
Definition: scface.h:293
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'
Definition: scface.cpp:402
QString italicAngle(qreal sz=1.0) const
deprecated
Definition: scface.h:344
QString replacementName() const
the name of the font which was used for replacement
Definition: scface.h:239
bool isReplacement() const
check if this is a replacement font
Definition: scface.h:245
QString replacementForDoc() const
the name of the font which was used for replacement
Definition: scface.h:242
void increaseUsage() const
prevent unloading of face data
Definition: scface.cpp:322
bool isNone() const
test for null object
Definition: scface.h:209
QString family() const
returns the font family as seen by Scribus
Definition: scface.h:316
int refs
controls destruction
Definition: scface.h:104
bool isStroked() const
tells if this font is an outline font
Definition: scface.h:304
qreal glyphWidth(gid_type gl, qreal sz=1.0) const
returns the glyphs normal advance width at size 'sz'
Definition: scface.h:354
A point with floating point precision.
Definition: fpoint.h:43
FontType type() const
font type, eg. Type1 or TTF
Definition: scface.h:278
qreal realCharHeight(QChar ch, qreal sz=1.0) const
deprecated, see glyphBBox()
Definition: scface.h:383
bool usable() const
test if this face can be used in documents
Definition: scface.h:284
bool hasNames() const
deprecated? tells if the face has PS names
Definition: scface.h:301
QMap< QString, QString > fontDictionary(qreal sz=1.0) const
returns a map of values used for font dictionaries in PS/PDF
Definition: scface.h:350
void unload() const
unload face data. It will be reloaded on need
Definition: scface.cpp:336
bool isSymbolic() const
test if font is a symbolic font
Definition: scface.cpp:204
bool operator==(const ScFace &other) const
Definition: scface.cpp:185
FPoint glyphOrigin(gid_type gl, qreal sz=1.0) const
returns the glyph's origin FIXME: what's that exactly?
Definition: scface.h:366
QString variant() const
returns an additional discriminating String for this face
Definition: scface.h:322
qreal realCharAscent(QChar ch, qreal sz=1.0) const
deprecated, see glyphBBox()
Definition: scface.h:386
Base Class ScFace : This is a total rewrite of the old Foi class.
Definition: scface.h:73
see accessors for ScFace for docs
Definition: scface.h:101
QString scName() const
the name Scribus uses for this font
Definition: scface.h:236
bool outline() const
test if this face should be outlined in documents
Definition: scface.h:287
bool isFixedPitch() const
tells if this font is a fixed pitch font
Definition: scface.h:307
FPointArray glyphOutline(gid_type gl, qreal sz=1.0) const
returns the glyph's outline as a cubic Bezier path
Definition: scface.h:363
Definition: fpointarray.h:42
QString stemV(qreal sz=1.0) const
deprecated
Definition: scface.h:341
qreal realCharWidth(QChar ch, qreal sz=1.0) const
deprecated, see glyphBBox()
Definition: scface.h:380
ScFace mkReplacementFor(QString name, QString doc)
makes a repalcement font for font "name" using this fonts data
Definition: scface.h:248
int faceIndex() const
if the fontfile contains more than one face, the index, else -1
Definition: scface.h:272
QString localForDocument() const
path name of the document this face is local to
Definition: scface.h:275
QString psName() const
the name PostScript uses for this font
Definition: scface.h:263
Main class SCFonts. Subclass of QDict. This class replaces the previous SCFonts typedef...
Definition: scfonts.h:36