44 #include "private/qpdf_p.h"
55 static const unsigned short symbol_map[0x100] = {
56 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
57 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
58 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
59 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
60 0x0020, 0x0021, 0x2200, 0x0023, 0x2203, 0x0025, 0x0026, 0x220b,
61 0x0028, 0x0029, 0x2217, 0x002b, 0x002c, 0x2212, 0x002e, 0x002f,
62 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
63 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
65 0x2245, 0x0391, 0x0392, 0x03a7, 0x0394, 0x0395, 0x03a6, 0x0393,
66 0x0397, 0x0399, 0x03d1, 0x039a, 0x039b, 0x039c, 0x039d, 0x039f,
67 0x03a0, 0x0398, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03c2, 0x03a9,
68 0x039e, 0x03a8, 0x0396, 0x005b, 0x2234, 0x005d, 0x22a5, 0x005f,
69 0xf8e5, 0x03b1, 0x03b2, 0x03c7, 0x03b4, 0x03b5, 0x03c6, 0x03b3,
70 0x03b7, 0x03b9, 0x03d5, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03bf,
71 0x03c0, 0x03b8, 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03d6, 0x03c9,
72 0x03be, 0x03c8, 0x03b6, 0x007b, 0x007c, 0x007d, 0x223c, 0x007f,
74 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
75 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
76 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
77 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
78 0x20ac, 0x03d2, 0x2023, 0x2264, 0x2044, 0x221e, 0x0192, 0x2263,
79 0x2666, 0x2665, 0x2660, 0x2194, 0x2190, 0x2191, 0x2192, 0x2193,
80 0x00b0, 0x00b1, 0x2033, 0x2265, 0x00d7, 0x221d, 0x2202, 0x2022,
81 0x00f7, 0x2260, 0x2261, 0x2248, 0x2026, 0xf8e6, 0xf8e7, 0x21b5,
83 0x2135, 0x2111, 0x211c, 0x2118, 0x2297, 0x2295, 0x2205, 0x2229,
84 0x222a, 0x2283, 0x2287, 0x2284, 0x2282, 0x2286, 0x2208, 0x2209,
85 0x2220, 0x2207, 0xf6da, 0xf6d9, 0xf6db, 0x220f, 0x221a, 0x22c5,
86 0x00ac, 0x2227, 0x2228, 0x21d4, 0x21d0, 0x21d1, 0x21d2, 0x21d3,
87 0x25ca, 0x2329, 0xf8e8, 0xf8e9, 0xf8ea, 0x2211, 0xf8eb, 0xf8ec,
88 0xf8ed, 0xf8ee, 0xf8ef, 0xf8f0, 0xf8f1, 0xf8f2, 0xf8f3, 0xf8f4,
89 0x0000, 0x232a, 0x222b, 0x2320, 0xf8f5, 0x2321, 0xf8f6, 0xf8f7,
90 0xf8f8, 0xf8f9, 0xf8fa, 0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0x0000
99 if (symbol && unicode < 0x100)
101 unicode = symbol_map[unicode];
103 const AGLEntry *
r = std::lower_bound(unicode_to_agl_map, unicode_to_agl_map + unicode_to_agl_map_size, unicode);
104 if ((
r != unicode_to_agl_map + unicode_to_agl_map_size) && !(unicode < *
r))
105 return glyph_names +
r->index;
124 if (reverseMap[glyphIndex] && reverseMap[glyphIndex] < 0x10000) {
125 s <<
'/' <<
glyphName(reverseMap[glyphIndex],
false);
127 s <<
"/gl" << (int)glyphIndex;
164 if (startLinear > 0 &&
g - startLinear >= 10)
172 if (
g - startLinear < 10)
174 int endnonlinear = startLinear ? startLinear :
g;
176 if (endnonlinear >
start) {
178 for (
int i =
start;
i < endnonlinear; ++
i)
192 if (++nranges > 100) {
193 ts << nranges <<
"beginbfrange\n"
194 << ranges <<
"endbfrange\n";
203 for (
uint uc = 0; uc < 0x10000; ++uc) {
205 if (
idx >= 0 && !reverseMap.
at(
idx))
206 reverseMap[
idx] = uc;
217 ts <<
"/CIDInit /ProcSet findresource begin\n"
220 "/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n"
221 "/CMapName /Adobe-Identity-UCS def\n"
223 "1 begincodespacerange\n"
225 "endcodespacerange\n";
233 int uc0 = reverseMap.
at(
g);
242 int uc = reverseMap[
g];
244 if (!uc || (
g>>8) != (
start >> 8))
250 if (startLinear > 0 &&
g - startLinear >= 10)
258 if (
g - startLinear < 10)
260 int endnonlinear = startLinear ? startLinear :
g;
262 if (endnonlinear >
start) {
265 if (endnonlinear ==
start + 1) {
269 for (
int i =
start;
i < endnonlinear; ++
i) {
274 checkRanges(ts, ranges, nranges);
277 while (startLinear <
g) {
278 int len =
g - startLinear;
279 int uc_start = reverseMap[startLinear];
280 int uc_end = uc_start +
len - 1;
281 if ((uc_end >> 8) != (uc_start >> 8))
282 len = 256 - (uc_start & 0xff);
286 checkRanges(ts, ranges, nranges);
292 ts << nranges <<
"beginbfrange\n"
293 << ranges <<
"endbfrange\n";
296 "CMapName currentdict /CMap defineresource pop\n"
454 const int head_size = 54;
457 t.data.resize(head_size);
525 const int hhea_size = 36;
528 t.data.resize(hhea_size);
576 const int maxp_size = 32;
579 t.data.resize(maxp_size);
649 return generateName(
list);
655 const int char_size = 2;
660 const int name_size = 6 + 12*
name.size();
662 for (
int i = 0;
i <
name.size(); ++
i) {
663 string_size +=
name.at(
i).value.length()*char_size;
665 t.data.resize(name_size + string_size);
678 for (
int i = 0;
i <
name.size(); ++
i) {
679 int len =
name.at(
i).value.length()*char_size;
694 for (
int i = 0;
i <
name.size(); ++
i) {
697 for (
int i = 0;
i <
n.length(); ++
i) {
726 int numElements =
path.elementCount();
727 for (
int i = 0;
i < numElements - 1; ++
i) {
738 int start = endPoints->
size() ? endPoints->
at(endPoints->
size()-1) - 1 : 0;
763 bool try_reduce =
points->size() > 1
768 const int split_limit = 3;
784 if (
qAbs(i1_x - i2_x) <= split_limit &&
qAbs(i1_y - i2_y) <= split_limit) {
787 np.
x = (i1_x + i2_x) >> 1;
788 np.
y = (i1_y + i2_y) >> 1;
838 int start = endPoints->
size() ? endPoints->
at(endPoints->
size()-1) + 1 : 0;
853 for (
int i = 1;
i <
points.size(); ++
i) {
854 *xmin = qMin(*xmin,
points.at(
i).x);
855 *xmax = qMax(*xmax,
points.at(
i).x);
856 *ymin = qMin(*ymin,
points.at(
i).y);
857 *ymax = qMax(*ymax,
points.at(
i).y);
867 int point_array_size = 0;
868 for (
int i = 0;
i <
points->size(); ++
i) {
878 }
else if (rel.
x > 0 && rel.
x < 256) {
881 }
else if (rel.
x < 0 && rel.
x > -256) {
886 point_array_size += 2;
890 }
else if (rel.
y > 0 && rel.
y < 256) {
893 }
else if (rel.
y < 0 && rel.
y > -256) {
898 point_array_size += 2;
911 return point_array_size;
916 const int max_size = int(5 *
sizeof(
qint16)
928 for (
int i = 0;
i < endPoints.
size(); ++
i)
936 for (
int i = 0;
i <
points.size(); ++
i) {
945 for (
int i = 0;
i <
points.size(); ++
i) {
971 if (
path.isEmpty()) {
990 int point_array_size = convertToRelative(&
points);
991 getGlyphData(&glyph,
points, endPoints, point_array_size);
1002 const int max_size_small = 65536*2;
1004 std::sort(glyphs.
begin(), glyphs.
end());
1010 for (
int i = 0;
i < glyphs.
size(); ++
i)
1011 glyf_size += (glyphs.
at(
i).data.size() + 3) & ~3;
1030 for (
int i = 0;
i < nGlyphs; ++
i) {
1041 advance = glyphs.
at(
pos).advanceWidth;
1042 lsb = glyphs.
at(
pos).lsb;
1045 if (glyf_size < max_size_small) {
1055 if (glyf_size < max_size_small) {
1076 return t1.tag <
t2.tag;
1083 std::sort(tables.
begin(), tables.
end());
1087 const int directory_size = 4*
sizeof(
quint32)*tables.
size();
1092 int n = tables.
size() >> 1;
1122 for (
int i = 0;
i < tables.
size(); ++
i) {
1125 if (
t.tag ==
MAKE_TAG(
'h',
'e',
'a',
'd'))
1126 head_offset = table_offset;
1131 table_offset +=
size;
1132 #define TAG(x) char(t.tag >> 24) << char((t.tag >> 16) & 0xff) << char((t.tag >> 8) & 0xff) << char(t.tag & 0xff)
1136 for (
int i = 0;
i < tables.
size(); ++
i) {
1140 while (
s & 3) {
font +=
'\0'; ++
s; }
1144 qWarning(
"QFontSubset: Font misses 'head' table");
1149 quint32 checksum_adjust = 0xB1B0AFBA - checksum(
font);
1171 #define TO_TTF(x) qRound(x * 2048. / ppem)
1179 font.head.font_revision = 0x00010000;
1180 font.head.flags = (1 << 2) | (1 << 4);
1181 font.head.created = 0;
1182 font.head.modified = 0;
1183 font.head.xMin = SHRT_MAX;
1184 font.head.xMax = SHRT_MIN;
1185 font.head.yMin = SHRT_MAX;
1186 font.head.yMax = SHRT_MIN;
1191 font.hhea.ascender =
qRound(properties.ascent);
1192 font.hhea.descender = -
qRound(properties.descent);
1193 font.hhea.lineGap =
qRound(properties.leading);
1197 font.hhea.xMaxExtent = SHRT_MIN;
1199 font.maxp.numGlyphs = 0;
1200 font.maxp.maxPoints = 0;
1201 font.maxp.maxContours = 0;
1202 font.maxp.maxCompositePoints = 0;
1203 font.maxp.maxCompositeContours = 0;
1204 font.maxp.maxComponentElements = 0;
1205 font.maxp.maxComponentDepth = 0;
1257 name_table = generateName(
name);
1259 tables.
append(name_table);
1269 return bindFont(tables);
small capitals from c petite p scientific i
[1]
The QByteArray class provides an array of bytes.
qsizetype size() const noexcept
bool isEmpty() const noexcept
void resize(qsizetype size)
QByteArray & append(char c)
bool operator<(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
virtual Properties properties() const
virtual qreal minRightBearing() const
virtual qreal minLeftBearing() const
virtual qreal maxCharWidth() const =0
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
QByteArray getSfntTable(uint tag) const
virtual glyph_t glyphIndex(uint ucs4) const =0
QByteArray toTruetype() const
QByteArray glyphName(unsigned int glyph, const QList< int > &reverseMap) const
QList< int > getReverseMap() const
QByteArray createToUnicodeMap() const
QList< uint > glyph_indices
QByteArray widthArray() const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void resize(qsizetype size)
void append(parameter_type t)
The QPainterPath::Element class specifies the position and type of a subpath.
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
The QRectF class defines a finite rectangle in the plane using floating point precision.
The QString class provides a Unicode character string.
const QChar at(qsizetype i) const
QTtfStream & operator<<(quint8 v)
QTtfStream(QByteArray &ba)
HeaderSize header_size(const HttpHeader &header)
const char * toHex(ushort u, char *buffer)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
constexpr T qToBigEndian(T source)
int qRound(qfloat16 d) noexcept
#define MAKE_TAG(ch1, ch2, ch3, ch4)
Q_DECLARE_TYPEINFO(QTtfTable, Q_RELOCATABLE_TYPE)
QT_BEGIN_INCLUDE_NAMESPACE typedef unsigned char uchar
QT_END_INCLUDE_NAMESPACE typedef double qreal
QT_BEGIN_NAMESPACE typedef signed char qint8
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum const void GLbitfield GLsizei numGlyphs
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLfixed GLfixed GLint GLint GLfixed points
GLsizei const GLchar *const * path
GLenum GLenum GLenum GLenum GLenum scale
GLenum GLenum GLsizei void * table
constexpr int toInt() const
constexpr qreal toReal() const
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
qint16 minLeftSideBearing
qint16 minRightSideBearing
quint16 maxCompositeContours
quint16 maxCompositePoints
quint16 maxComponentElements
quint16 maxComponentDepth