/branches/Version13x/Scribus/scribus/fonts/scfontmetrics.cpp |
---|
355,20 → 355,15 |
} |
return true; |
} |
/* |
bool GlyIndex(ScFace * fnt, QMap<uint, PDFlib::GlNamInd> *GListInd) |
bool GlyIndex(FT_Face face, QMap<uint, std::pair<uint, QString> >& GList) |
{ |
struct PDFlib::GlNamInd gln; |
bool error; |
char buf[50]; |
FT_Library library; |
FT_Face face; |
FT_ULong charcode; |
FT_UInt gindex; |
uint counter1 = 32; |
uint counter2 = 0; |
error = FT_Init_FreeType(&library); |
error = FT_New_Face(library, QFile::encodeName(fnt->fontFilePath()), fnt->faceIndex(), &face); |
setBestEncoding(face); |
gindex = 0; |
charcode = FT_Get_First_Char(face, &gindex ); |
384,12 → 379,9 |
// just in case FT gives empty string or ".notdef" |
// no valid glyphname except ".notdef" starts with '.' |
if (notfound || buf[0] == '\0' || buf[0] == '.') |
gln.Name = "/" + adobeGlyphName(charcode); |
GList.insert(charcode, std::make_pair(counter1 + counter2, adobeGlyphName(charcode))); |
else |
gln.Name = "/" + QString(buf); |
gln.Code = counter1 + counter2; |
GListInd->insert(charcode, gln); |
GList.insert(charcode, std::make_pair(counter1 + counter2, QString(reinterpret_cast<char*>(buf)))); |
charcode = FT_Get_Next_Char(face, charcode, &gindex ); |
counter1++; |
if (counter1 > 255) |
398,11 → 390,10 |
counter2 += 0x100; |
} |
} |
FT_Done_FreeType( library ); |
return true; |
} |
*/ |
static int traceMoveto( FT_Vector *to, FPointArray *composite ) |
{ |
double tox = ( to->x / FTSCALE ); |
/branches/Version13x/Scribus/scribus/fonts/scface.cpp |
---|
16,6 → 16,10 |
return false; |
} |
bool ScFace::ScFaceData::glyphNameIndex(QMap<uint, std::pair<uint, QString> >& gList) const |
{ |
return false; |
} |
QMap<QString,QString> ScFace::ScFaceData::fontDictionary(double sz) const |
{ |
272,6 → 276,14 |
} |
bool ScFace::glyphNameIndex(QMap<uint, std::pair<uint, QString> >& gList) |
{ |
if (m->status == ScFace::UNKNOWN) { |
m->load(); |
} |
return m->glyphNameIndex(gList); |
} |
void ScFace::RawData(QByteArray & bb) |
{ |
if (m->status == ScFace::UNKNOWN) { |
/branches/Version13x/Scribus/scribus/fonts/ftface.cpp |
---|
96,6 → 96,11 |
m_strikeoutPos = m_ascent / 3; |
m_strokeWidth = m_face->underline_thickness / m_uniEM; |
const_cast<FtFace*>(this)->isFixedPitch = m_face->face_flags & 4; |
Ascent = QString::number(m_face->ascender); |
CapHeight = QString::number(m_face->height); |
Descender = QString::number(m_face->descender); |
FontBBox = QString::number(m_face->bbox.xMin)+" "+QString::number(m_face->bbox.yMin)+" "+QString::number(m_face->bbox.xMax)+" "+QString::number(m_face->bbox.yMax); |
ItalicAngle = "0"; |
//FIXME: FT_Set_Charmap(m_face, m_face->charmaps[m_encoding]); |
setBestEncoding(m_face); |
273,6 → 278,11 |
} |
bool FtFace::glyphNameIndex(QMap<uint, std::pair<uint, QString> >& GList) const |
{ |
return GlyIndex(ftFace(), GList); |
} |
void FtFace::RawData(QByteArray & bb) const |
{ |
FT_Stream fts = ftFace()->stream; |
/branches/Version13x/Scribus/scribus/fonts/scfontmetrics.h |
---|
31,6 → 31,7 |
QPixmap SCRIBUS_API FontSample(const ScFace& fnt, int s, QString ts, QColor back, bool force = false); |
//QPixmap SCRIBUS_API fontSamples(const ScFace& fnt, int s, QString ts, QColor back); |
bool SCRIBUS_API GlyNames(FT_Face face, QMap<uint, std::pair<QChar, QString> >& GList); |
bool SCRIBUS_API GlyIndex(FT_Face face, QMap<uint, std::pair<uint, QString> >& GList); |
//bool SCRIBUS_API GlyIndex(ScFace * fnt, QMap<uint, PDFlib::GlNamInd> *GListInd); |
#endif |
/branches/Version13x/Scribus/scribus/fonts/scface.h |
---|
149,6 → 149,11 |
// dummy implementations |
virtual double ascent(double sz) const { return sz; } |
virtual QString ascentAsString() const { return "0" ; } |
virtual QString descentAsString() const { return "0"; } |
virtual QString capHeightAsString() const { return "0"; } |
virtual QString FontBBoxAsString() const { return "0 0 0 0"; } |
virtual QString ItalicAngleAsString() const { return "0"; } |
virtual double descent(double /*sz*/) const { return 0.0; } |
virtual double xHeight(double sz) const { return sz; } |
virtual double capHeight(double sz) const { return sz; } |
164,6 → 169,7 |
virtual bool EmbedFont(QString &/*str*/) const { return false; } |
virtual void RawData(QByteArray & /*bb*/) const {} |
virtual bool glyphNames(QMap<uint, std::pair<QChar, QString> >& gList) const; |
virtual bool glyphNameIndex(QMap<uint, std::pair<uint, QString> >& gList) const; |
// these use the cache: |
virtual double glyphWidth(uint gl, double sz) const; |
195,6 → 201,7 |
bool EmbedFont(QString &str); |
void RawData(QByteArray & bb); |
bool glyphNames(QMap<uint, std::pair<QChar, QString> >& gList); |
bool glyphNameIndex(QMap<uint, std::pair<uint, QString> >& gList); |
/// prevent unloading of face data |
void increaseUsage() const; |
268,6 → 275,11 |
// font metrics |
double ascent(double sz=1.0) const { return m->ascent(sz); } |
QString ascentAsString() const { return m->ascentAsString() ; } |
QString descentAsString() const { return m->descentAsString() ; } |
QString capHeightAsString() const { return m->capHeightAsString() ; } |
QString FontBBoxAsString() const { return m->FontBBoxAsString() ; } |
QString ItalicAngleAsString() const { return m->ItalicAngleAsString() ; } |
double descent(double sz=1.0) const { return m->descent(sz); } |
double xHeight(double sz=1.0) const { return m->xHeight(sz); } |
double capHeight(double sz=1.0) const { return m->capHeight(sz); } |
/branches/Version13x/Scribus/scribus/fonts/ftface.h |
---|
66,6 → 66,11 |
double underlinePos(double sz=1.0) const { return m_underlinePos * sz; } |
double strokeWidth(double sz=1.0) const { return m_strokeWidth; } |
double maxAdvanceWidth(double sz=1.0) const { return m_maxAdvanceWidth * sz; } |
QString ascentAsString() const { return Ascent; } |
QString descentAsString() const { return Descender; } |
QString capHeightAsString() const { return CapHeight; } |
QString FontBBoxAsString() const { return FontBBox; } |
QString ItalicAngleAsString() const { return ItalicAngle; } |
//FIXME QMap<QString,QString> fontDictionary(double sz=1.0) const; |
77,6 → 82,7 |
void RawData (QByteArray & bb) const; |
bool glyphNames(QMap<uint, std::pair<QChar, QString> >& GList) const; |
bool glyphNameIndex(QMap<uint, std::pair<uint, QString> >& GList) const; |
void load () const; |
void unload () const; |
void loadGlyph (uint ch) const; |
86,13 → 92,13 |
static FT_Library library; |
QString Ascent; |
QString CapHeight; |
QString Descender; |
QString ItalicAngle; |
QString StdVW; |
mutable QString Ascent; |
mutable QString CapHeight; |
mutable QString Descender; |
mutable QString ItalicAngle; |
mutable QString StdVW; |
QString FontEnc; |
QString FontBBox; |
mutable QString FontBBox; |
mutable int m_encoding; |
/branches/Version13x/Scribus/scribus/pdflib.cpp |
---|
850,7 → 850,7 |
// TODO: think about QByteArray ScFace::getFontDescriptor() -- AV |
PutDoc("<<\n/Type /FontDescriptor\n"); |
PutDoc("/FontName /"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n"); |
PutDoc("/FontBBox [ "+AllFonts[it.key()].fontBBox()+" ]\n"); |
PutDoc("/FontBBox [ "+AllFonts[it.key()].FontBBoxAsString()+" ]\n"); |
PutDoc("/Flags "); |
//FIXME: isItalic() should be queried from ScFace, not from Qt -- AV |
//QFontInfo fo = QFontInfo(it.data()); |
858,16 → 858,21 |
if (AllFonts[it.key()].isFixedPitch()) |
pfl = pfl ^ 1; |
//if (fo.italic()) |
if (AllFonts[it.key()].italicAngle() != "0") |
if (AllFonts[it.key()].ItalicAngleAsString() != "0") |
pfl = pfl ^ 64; |
// pfl = pfl ^ 4; |
pfl = pfl ^ 32; |
PutDoc(QString::number(pfl)+"\n"); |
PutDoc("/Ascent "+QString::number(static_cast<int>(AllFonts[it.key()].ascent()))+"\n"); |
PutDoc("/Descent "+QString::number(static_cast<int>(AllFonts[it.key()].descent()))+"\n"); |
PutDoc("/CapHeight "+QString::number(static_cast<int>(AllFonts[it.key()].capHeight()))+"\n"); |
PutDoc("/ItalicAngle "+AllFonts[it.key()].italicAngle()+"\n"); |
PutDoc("/StemV "+ AllFonts[it.key()].stemV() + "\n"); |
PutDoc("/Ascent "+AllFonts[it.key()].ascentAsString()+"\n"); |
PutDoc("/Descent "+AllFonts[it.key()].descentAsString()+"\n"); |
PutDoc("/CapHeight "+AllFonts[it.key()].capHeightAsString()+"\n"); |
PutDoc("/ItalicAngle "+AllFonts[it.key()].ItalicAngleAsString()+"\n"); |
// PutDoc("/Ascent "+QString::number(static_cast<int>(AllFonts[it.key()].ascent()))+"\n"); |
// PutDoc("/Descent "+QString::number(static_cast<int>(AllFonts[it.key()].descent()))+"\n"); |
// PutDoc("/CapHeight "+QString::number(static_cast<int>(AllFonts[it.key()].capHeight()))+"\n"); |
// PutDoc("/ItalicAngle "+AllFonts[it.key()].italicAngle()+"\n"); |
// PutDoc("/StemV "+ AllFonts[it.key()].stemV() + "\n"); |
PutDoc("/StemV 1\n"); |
if ((fformat == ScFace::SFNT || fformat == ScFace::TTCF) && (Options.EmbedList.contains(it.key()))) |
PutDoc("/FontFile2 "+QString::number(ObjCounter-1)+" 0 R\n"); |
if ((fformat == ScFace::PFB) && (Options.EmbedList.contains(it.key()))) |
911,7 → 916,7 |
else */ |
// { |
GListe gl; |
AllFonts[it.key()].glyphNames(gl); |
AllFonts[it.key()].glyphNameIndex(gl); |
GlyphsIdxOfFont.insert(it.key(), gl); |
uint FontDes = ObjCounter - 1; |
GListe::Iterator itg; |
944,7 → 949,10 |
int crc = 0; |
for (int ww2 = 32; ww2 < 256; ++ww2) |
{ |
PutDoc("/"+itg2.data().second+" "); |
if (itg2.data().second != "") |
{ |
PutDoc("/"+itg2.data().second+" "); |
} |
if (itg2 == gl.end()) |
break; |
++itg2; |
3327,12 → 3335,10 |
} |
else |
{ |
/* cc = chstr[0].unicode(); |
idx = 0; |
uint cc = chstr[0].unicode(); |
uint idx = 0; |
if (GlyphsIdxOfFont[hl->font().scName()].contains(cc)) |
idx = GlyphsIdxOfFont[hl->font().scName()][cc].first; |
*/ |
uint idx = hl->glyph.glyph; |
uint idx1 = (idx >> 8) & 0xFF; |
tmp += UsedFontsP[hl->font().scName()]+"S"+QString::number(idx1)+" "+FToStr(tsz / 10.0)+" Tf\n"; |
if (hl->strokeColor() != CommonStrings::None) |
3386,12 → 3392,12 |
double wtr = hl->font().charWidth(chstr[0], chs) * (hl->scaleH() / 1000.0); |
tmp += "1 0 0 1 "+FToStr(x+hl->glyph.xoffset+wtr)+" "+FToStr(-y-hl->glyph.yoffset)+" Tm\n"; |
chstr = "-"; |
/* cc = chstr[0].unicode(); |
cc = chstr[0].unicode(); |
idx = 0; |
if (GlyphsIdxOfFont[hl->font().scName()].contains(cc)) |
idx = GlyphsIdxOfFont[hl->font().scName()][cc].first; |
*/ |
idx = hl->font().char2CMap(QChar('-')); |
// idx = hl->font().char2CMap(QChar('-')); |
idx1 = (idx >> 8) & 0xFF; |
tmp += UsedFontsP[hl->font().scName()]+"S"+QString::number(idx1)+" "+FToStr(tsz / 10.0)+" Tf\n"; |
idx2 = idx & 0xFF; |
/branches/Version13x/Scribus/scribus/pdflib.h |
---|
59,7 → 59,7 |
const std::vector<int> & pageNs, const QMap<int,QPixmap> & thumbs); |
private: |
typedef QMap<uint, std::pair<QChar, QString> > GListe; |
typedef QMap<uint, std::pair<uint, QString> > GListe; |
bool PDF_Begin_Doc(const QString& fn, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, BookMView* vi); |
void PDF_Begin_Page(const Page* pag, QPixmap pm = 0); |
/branches/Version13x/Scribus/scribus/pslib.cpp |
---|
2740,9 → 2740,11 |
dum.clear(); |
tsz = hl->fontSize(); |
QString chstr = hl->ch; |
if (hl->effects() & 2048) |
{ |
QString chstr; // dummy, FIXME: replace by glyph |
// QString chstr; // dummy, FIXME: replace by glyph |
if (pstyle.useBaselineGrid()) |
tsz = qRound(10 * ((Doc->typographicSettings.valueBaseGrid * (pstyle.dropCapLines()-1)+(hl->font().ascent(pstyle.charStyle().fontSize() / 10.0))) / (hl->font().realCharHeight(chstr[0], 10)))); |
else |
2797,9 → 2799,15 |
} |
if (glyph == (ScFace::CONTROL_GLYPHS + 29)) // NBSPACE |
{ |
glyph = cstyle.font().char2CMap(QChar(' ')); |
chstr = " "; |
} |
else if (glyph == (ScFace::CONTROL_GLYPHS + 24)) // NBHYPHEN |
{ |
glyph = cstyle.font().char2CMap(QChar('-')); |
chstr = "-"; |
} |
if (glyph == 0 || glyph >= ScFace::CONTROL_GLYPHS) |
return; |