Remove Type1 support

Type1 support was only required for postscript
generation. As we don't support this anymore, get
rid of this code.

Change-Id: Ifdc27ec563b5da8d94554f8b078bcd3ac079d201
Reviewed-on: http://codereview.qt.nokia.com/3214
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
This commit is contained in:
Lars Knoll 2011-08-16 14:39:54 +02:00
parent 28f1c1b9ef
commit b7f3253f90
2 changed files with 0 additions and 255 deletions

View File

@ -57,8 +57,6 @@
#include FT_FREETYPE_H
#endif
#ifndef QT_NO_PRINTER
QT_BEGIN_NAMESPACE
static const char * const agl =
@ -1493,251 +1491,4 @@ QByteArray QFontSubset::toTruetype() const
return bindFont(tables);
}
// ------------------ Type 1 generation ---------------------------
// needs at least 6 bytes of space in tmp
static const char *encodeNumber(int num, char *tmp)
{
const char *ret = tmp;
if(num >= -107 && num <= 107) {
QPdf::toHex((uchar)(num + 139), tmp);
tmp += 2;
} else if (num > 107 && num <= 1131) {
num -= 108;
QPdf::toHex((uchar)((num >> 8) + 247), tmp);
tmp += 2;
QPdf::toHex((uchar)(num & 0xff), tmp);
tmp += 2;
} else if(num < - 107 && num >= -1131) {
num += 108;
num = -num;
QPdf::toHex((uchar)((num >> 8) + 251), tmp);
tmp += 2;
QPdf::toHex((uchar)(num & 0xff), tmp);
tmp += 2;
} else {
*tmp++ = 'f';
*tmp++ = 'f';
QPdf::toHex((uchar)(num >> 24), tmp);
tmp += 2;
QPdf::toHex((uchar)(num >> 16), tmp);
tmp += 2;
QPdf::toHex((uchar)(num >> 8), tmp);
tmp += 2;
QPdf::toHex((uchar)(num >> 0), tmp);
tmp += 2;
}
*tmp = 0;
// qDebug("encodeNumber: %d -> '%s'", num, ret);
return ret;
}
static QByteArray charString(const QPainterPath &path, qreal advance, qreal lsb, qreal ppem)
{
// the charstring commands we need
const char *hsbw = "0D";
const char *closepath = "09";
const char *moveto[3] = { "16", "04", "15" };
const char *lineto[3] = { "06", "07", "05" };
const char *rcurveto = "08";
const char *endchar = "0E";
enum { horizontal = 1, vertical = 2 };
char tmp[16];
qreal factor = 1000./ppem;
int lsb_i = qRound(lsb*factor);
int advance_i = qRound(advance*factor);
// qDebug("--- charstring");
// first of all add lsb and width to the charstring using the hsbw command
QByteArray charstring;
charstring += encodeNumber(lsb_i, tmp);
charstring += encodeNumber(advance_i, tmp);
charstring += hsbw;
// add the path
int xl = lsb_i;
int yl = 0;
bool openpath = false;
for (int i = 0; i < path.elementCount(); ++i) {
const QPainterPath::Element &elm = path.elementAt(i);
int x = qRound(elm.x*factor);
int y = -qRound(elm.y*factor);
int dx = x - xl;
int dy = y - yl;
if (elm.type == QPainterPath::MoveToElement && openpath) {
// qDebug("closepath %s", closepath);
charstring += closepath;
}
if (elm.type == QPainterPath::MoveToElement ||
elm.type == QPainterPath::LineToElement) {
int type = -1;
if (dx || !dy) {
charstring += encodeNumber(dx, tmp);
type += horizontal;
// qDebug("horizontal");
}
if (dy) {
charstring += encodeNumber(dy, tmp);
type += vertical;
// qDebug("vertical");
}
// qDebug("moveto/lineto %s", (elm.type == QPainterPath::MoveToElement ? moveto[type] : lineto[type]));
charstring += (elm.type == QPainterPath::MoveToElement ? moveto[type] : lineto[type]);
openpath = true;
xl = x;
yl = y;
} else {
Q_ASSERT(elm.type == QPainterPath::CurveToElement);
const QPainterPath::Element &elm2 = path.elementAt(++i);
const QPainterPath::Element &elm3 = path.elementAt(++i);
int x2 = qRound(elm2.x*factor);
int y2 = -qRound(elm2.y*factor);
int x3 = qRound(elm3.x*factor);
int y3 = -qRound(elm3.y*factor);
charstring += encodeNumber(dx, tmp);
charstring += encodeNumber(dy, tmp);
charstring += encodeNumber(x2 - x, tmp);
charstring += encodeNumber(y2 - y, tmp);
charstring += encodeNumber(x3 - x2, tmp);
charstring += encodeNumber(y3 - y2, tmp);
charstring += rcurveto;
openpath = true;
xl = x3;
yl = y3;
// qDebug("rcurveto");
}
}
if (openpath)
charstring += closepath;
charstring += endchar;
if (charstring.length() > 240) {
int pos = 240;
while (pos < charstring.length()) {
charstring.insert(pos, '\n');
pos += 241;
}
}
return charstring;
}
#ifndef QT_NO_FREETYPE
static const char *helvetica_styles[4] = {
"Helvetica",
"Helvetica-Bold",
"Helvetica-Oblique",
"Helvetica-BoldOblique"
};
static const char *times_styles[4] = {
"Times-Regular",
"Times-Bold",
"Times-Italic",
"Times-BoldItalic"
};
static const char *courier_styles[4] = {
"Courier",
"Courier-Bold",
"Courier-Oblique",
"Courier-BoldOblique"
};
#endif
QByteArray QFontSubset::toType1() const
{
QFontEngine::Properties properties = fontEngine->properties();
QVector<int> reverseMap = getReverseMap();
QByteArray font;
QPdf::ByteStream s(&font);
QByteArray id = QByteArray::number(object_id);
QByteArray psname = properties.postscriptName;
psname.replace(' ', "");
standard_font = false;
#ifndef QT_NO_FREETYPE
FT_Face face = ft_face(fontEngine);
if (face && !FT_IS_SCALABLE(face)) {
int style = 0;
if (fontEngine->fontDef.style)
style += 2;
if (fontEngine->fontDef.weight >= QFont::Bold)
style++;
if (fontEngine->fontDef.family.contains(QLatin1String("Helvetica"))) {
psname = helvetica_styles[style];
standard_font = true;
} else if (fontEngine->fontDef.family.contains(QLatin1String("Times"))) {
psname = times_styles[style];
standard_font = true;
} else if (fontEngine->fontDef.family.contains(QLatin1String("Courier"))) {
psname = courier_styles[style];
standard_font = true;
}
}
#endif
s << "/F" << id << "-Base\n";
if (standard_font) {
s << '/' << psname << " findfont\n"
"0 dict copy dup /NumGlyphs 0 put dup /CMap 256 array put def\n";
} else {
s << "<<\n";
if(!psname.isEmpty())
s << "/FontName /" << psname << '\n';
s << "/FontInfo <</FsType " << (int)fontEngine->fsType << ">>\n"
"/FontType 1\n"
"/PaintType 0\n"
"/FontMatrix [.001 0 0 .001 0 0]\n"
"/FontBBox { 0 0 0 0 }\n"
"/Private <<\n"
"/password 5839\n"
"/MinFeature {16 16}\n"
"/BlueValues []\n"
"/lenIV -1\n"
">>\n"
"/CharStrings << >>\n"
"/NumGlyphs 0\n"
"/CMap 256 array\n"
">> def\n";
}
s << type1AddedGlyphs();
downloaded_glyphs = glyph_indices.size();
return font;
}
QByteArray QFontSubset::type1AddedGlyphs() const
{
if (downloaded_glyphs == glyph_indices.size())
return QByteArray();
QFontEngine::Properties properties = fontEngine->properties();
QVector<int> reverseMap = getReverseMap();
QByteArray glyphs;
QPdf::ByteStream s(&glyphs);
int nGlyphs = glyph_indices.size();
QByteArray id = QByteArray::number(object_id);
s << 'F' << id << "-Base [\n";
for (int i = downloaded_glyphs; i < nGlyphs; ++i) {
glyph_t g = glyph_indices.at(i);
QPainterPath path;
glyph_metrics_t metric;
fontEngine->getUnscaledGlyph(g, &path, &metric);
QByteArray charstring = charString(path, metric.xoff.toReal(), metric.x.toReal(),
properties.emSquare.toReal());
s << glyphName(i, reverseMap);
if (!standard_font)
s << "\n<" << charstring << ">\n";
}
s << (standard_font ? "] T1AddMapping\n" : "] T1AddGlyphs\n");
return glyphs;
}
QT_END_NAMESPACE
#endif // QT_NO_PRINTER

View File

@ -55,8 +55,6 @@
#include "private/qfontengine_p.h"
#ifndef QT_NO_PRINTER
QT_BEGIN_NAMESPACE
class QFontSubset
@ -71,8 +69,6 @@ public:
}
QByteArray toTruetype() const;
QByteArray toType1() const;
QByteArray type1AddedGlyphs() const;
QByteArray widthArray() const;
QByteArray createToUnicodeMap() const;
QVector<int> getReverseMap() const;
@ -94,6 +90,4 @@ public:
QT_END_NAMESPACE
#endif // QT_NO_PRINTER
#endif // QFONTSUBSET_P_H