8#include "private/qpdf_p.h"
22 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
23 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
24 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
25 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
26 0x0020, 0x0021, 0x2200, 0x0023, 0x2203, 0x0025, 0x0026, 0x220b,
27 0x0028, 0x0029, 0x2217, 0x002b, 0x002c, 0x2212, 0x002e, 0x002f,
28 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
29 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
31 0x2245, 0x0391, 0x0392, 0x03a7, 0x0394, 0x0395, 0x03a6, 0x0393,
32 0x0397, 0x0399, 0x03d1, 0x039a, 0x039b, 0x039c, 0x039d, 0x039f,
33 0x03a0, 0x0398, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03c2, 0x03a9,
34 0x039e, 0x03a8, 0x0396, 0x005b, 0x2234, 0x005d, 0x22a5, 0x005f,
35 0xf8e5, 0x03b1, 0x03b2, 0x03c7, 0x03b4, 0x03b5, 0x03c6, 0x03b3,
36 0x03b7, 0x03b9, 0x03d5, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03bf,
37 0x03c0, 0x03b8, 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03d6, 0x03c9,
38 0x03be, 0x03c8, 0x03b6, 0x007b, 0x007c, 0x007d, 0x223c, 0x007f,
40 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
41 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
42 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
43 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
44 0x20ac, 0x03d2, 0x2023, 0x2264, 0x2044, 0x221e, 0x0192, 0x2263,
45 0x2666, 0x2665, 0x2660, 0x2194, 0x2190, 0x2191, 0x2192, 0x2193,
46 0x00b0, 0x00b1, 0x2033, 0x2265, 0x00d7, 0x221d, 0x2202, 0x2022,
47 0x00f7, 0x2260, 0x2261, 0x2248, 0x2026, 0xf8e6, 0xf8e7, 0x21b5,
49 0x2135, 0x2111, 0x211c, 0x2118, 0x2297, 0x2295, 0x2205, 0x2229,
50 0x222a, 0x2283, 0x2287, 0x2284, 0x2282, 0x2286, 0x2208, 0x2209,
51 0x2220, 0x2207, 0xf6da, 0xf6d9, 0xf6db, 0x220f, 0x221a, 0x22c5,
52 0x00ac, 0x2227, 0x2228, 0x21d4, 0x21d0, 0x21d1, 0x21d2, 0x21d3,
53 0x25ca, 0x2329, 0xf8e8, 0xf8e9, 0xf8ea, 0x2211, 0xf8eb, 0xf8ec,
54 0xf8ed, 0xf8ee, 0xf8ef, 0xf8f0, 0xf8f1, 0xf8f2, 0xf8f3, 0xf8f4,
55 0x0000, 0x232a, 0x222b, 0x2320, 0xf8f5, 0x2321, 0xf8f6, 0xf8f7,
56 0xf8f8, 0xf8f9, 0xf8fa, 0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0x0000
65 if (symbol && unicode < 0x100)
69 const AGLEntry *
r = std::lower_bound(unicode_to_agl_map, unicode_to_agl_map + unicode_to_agl_map_size, unicode);
70 if ((
r != unicode_to_agl_map + unicode_to_agl_map_size) && !(unicode < *
r))
71 return glyph_names +
r->index;
112 if (startLinear > 0 &&
g - startLinear >= 10)
120 if (
g - startLinear < 10)
122 qsizetype endnonlinear = startLinear ? startLinear :
g;
124 if (endnonlinear >
start) {
140 if (++nranges > 100) {
141 ts << nranges <<
"beginbfrange\n"
142 << ranges <<
"endbfrange\n";
151 for (
uint uc = 0; uc < 0x10000; ++uc) {
153 if (idx >= 0 && !reverseMap.
at(idx))
154 reverseMap[idx] = uc;
165 ts <<
"/CIDInit /ProcSet findresource begin\n"
168 "/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n"
169 "/CMapName /Adobe-Identity-UCS def\n"
171 "1 begincodespacerange\n"
173 "endcodespacerange\n";
181 int uc0 = reverseMap.
at(
g);
190 int uc = reverseMap[
g];
192 if (!uc || (
g>>8) != (
start >> 8))
198 if (startLinear > 0 &&
g - startLinear >= 10)
206 if (
g - startLinear < 10)
208 qsizetype endnonlinear = startLinear ? startLinear :
g;
210 if (endnonlinear >
start) {
213 if (endnonlinear ==
start + 1) {
225 while (startLinear <
g) {
227 qsizetype uc_start = reverseMap[startLinear];
229 if ((uc_end >> 8) != (uc_start >> 8))
230 len = 256 - (uc_start & 0xff);
240 ts << nranges <<
"beginbfrange\n"
241 << ranges <<
"endbfrange\n";
244 "CMapName currentdict /CMap defineresource pop\n"
402 const int head_size = 54;
405 t.data.resize(head_size);
473 const int hhea_size = 36;
476 t.data.resize(hhea_size);
524 const int maxp_size = 32;
527 t.data.resize(maxp_size);
590 if (
name.subfamily !=
"Regular"_L1)
603 const int char_size = 2;
608 const int name_size = 6 + 12*
name.size();
610 for (
int i = 0;
i <
name.size(); ++
i) {
611 string_size +=
name.at(
i).value.size()*char_size;
613 t.data.resize(name_size + string_size);
626 for (
int i = 0;
i <
name.size(); ++
i) {
627 int len =
name.at(
i).value.size()*char_size;
642 for (
int i = 0;
i <
name.size(); ++
i) {
670 int numElements =
path.elementCount();
671 for (
int i = 0;
i < numElements - 1; ++
i) {
682 int start = endPoints->
size() ? endPoints->
at(endPoints->
size()-1) - 1 : 0;
712 const int split_limit = 3;
728 if (
qAbs(i1_x - i2_x) <= split_limit &&
qAbs(i1_y - i2_y) <= split_limit) {
731 np.
x = (i1_x + i2_x) >> 1;
732 np.
y = (i1_y + i2_y) >> 1;
755 base[2].x =
a = (
a +
c ) >> 1;
756 base[4].x =
b = (
b +
c ) >> 1;
757 base[3].x = (
a +
b ) >> 1;
765 base[2].y =
a = (
a +
c ) >> 1;
766 base[4].y =
b = (
b +
c ) >> 1;
767 base[3].y = (
a +
b ) >> 1;
782 int start = endPoints->
size() ? endPoints->
at(endPoints->
size()-1) + 1 : 0;
797 for (
int i = 1;
i <
points.size(); ++
i) {
811 int point_array_size = 0;
812 for (
int i = 0;
i <
points->size(); ++
i) {
822 }
else if (rel.
x > 0 && rel.
x < 256) {
825 }
else if (rel.
x < 0 && rel.
x > -256) {
830 point_array_size += 2;
834 }
else if (rel.
y > 0 && rel.
y < 256) {
837 }
else if (rel.
y < 0 && rel.
y > -256) {
842 point_array_size += 2;
855 return point_array_size;
860 const int max_size = int(5 *
sizeof(
qint16)
872 for (
int i = 0;
i < endPoints.
size(); ++
i)
880 for (
int i = 0;
i <
points.size(); ++
i) {
889 for (
int i = 0;
i <
points.size(); ++
i) {
915 if (
path.isEmpty()) {
946 const int max_size_small = 65536*2;
948 std::sort(glyphs.
begin(), glyphs.
end());
954 for (
int i = 0;
i < glyphs.
size(); ++
i)
955 glyf_size += (glyphs.
at(
i).data.size() + 3) & ~3;
974 for (
int i = 0;
i < nGlyphs; ++
i) {
985 advance = glyphs.
at(
pos).advanceWidth;
986 lsb = glyphs.
at(
pos).lsb;
989 if (glyf_size < max_size_small) {
999 if (glyf_size < max_size_small) {
1020 return t1.tag <
t2.tag;
1027 std::sort(tables.
begin(), tables.
end());
1031 const int directory_size = 4*
sizeof(
quint32)*tables.
size();
1032 font.resize(header_size + directory_size);
1036 int n = tables.
size() >> 1;
1065 quint32 table_offset = header_size + directory_size;
1066 for (
int i = 0;
i < tables.
size(); ++
i) {
1069 if (
t.tag ==
MAKE_TAG(
'h',
'e',
'a',
'd'))
1070 head_offset = table_offset;
1075 table_offset +=
size;
1076#define TAG(x) char(t.tag >> 24) << char((t.tag >> 16) & 0xff) << char((t.tag >> 8) & 0xff) << char(t.tag & 0xff)
1080 for (
int i = 0;
i < tables.
size(); ++
i) {
1084 while (
s & 3) {
font +=
'\0'; ++
s; }
1088 qWarning(
"QFontSubset: Font misses 'head' table");
1115#define TO_TTF(x) qRound(x * 2048. / ppem)
1123 font.head.font_revision = 0x00010000;
1124 font.head.flags = (1 << 2) | (1 << 4);
1125 font.head.created = 0;
1126 font.head.modified = 0;
1127 font.head.xMin = SHRT_MAX;
1128 font.head.xMax = SHRT_MIN;
1129 font.head.yMin = SHRT_MAX;
1130 font.head.yMax = SHRT_MIN;
1141 font.hhea.xMaxExtent = SHRT_MIN;
1143 font.maxp.numGlyphs = 0;
1144 font.maxp.maxPoints = 0;
1145 font.maxp.maxContours = 0;
1146 font.maxp.maxCompositePoints = 0;
1147 font.maxp.maxCompositeContours = 0;
1148 font.maxp.maxComponentElements = 0;
1149 font.maxp.maxComponentDepth = 0;
1195 name.copyright =
"Fake font"_L1;
1199 name.subfamily =
"Regular"_L1;
1203 tables.
append(name_table);
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
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
static QByteArray glyphName(unsigned short unicode, bool symbol)
qsizetype nGlyphs() const
QByteArray toTruetype() const
QList< int > getReverseMap() const
QByteArray createToUnicodeMap() const
QList< uint > glyph_indices
QByteArray widthArray() const
qsizetype addGlyph(uint index)
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)
\inmodule QtCore\reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
QTtfStream(QByteArray &ba)
QTtfStream & operator<<(quint8 v)
const char * toHex(ushort u, char *buffer)
Combined button and popup list for selecting options.
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
static const QCssKnownValue properties[NumProperties - 1]
constexpr T qToBigEndian(T source)
int qRound(qfloat16 d) noexcept
#define MAKE_TAG(ch1, ch2, ch3, ch4)
static QTtfTable generateHhea(const qttf_hhea_table &hhea)
static void convertPath(const QPainterPath &path, QList< TTF_POINT > *points, QList< int > *endPoints, qreal ppem)
static bool operator<(const QTtfGlyph &g1, const QTtfGlyph &g2)
static QByteArray bindFont(const QList< QTtfTable > &_tables)
static QTtfTable generateHead(const qttf_head_table &head)
static QList< QTtfTable > generateGlyphTables(qttf_font_tables &tables, const QList< QTtfGlyph > &_glyphs)
static quint32 checksum(const QByteArray &table)
static const unsigned short symbol_map[0x100]
static QTtfTable generateMaxp(const qttf_maxp_table &maxp)
static void getGlyphData(QTtfGlyph *glyph, const QList< TTF_POINT > &points, const QList< int > &endPoints, int point_array_size)
static QTtfTable generateName(const qttf_name_table &name)
static void checkRanges(QPdf::ByteStream &ts, QByteArray &ranges, int &nranges)
static void getBounds(const QList< TTF_POINT > &points, qint16 *xmin, qint16 *xmax, qint16 *ymin, qint16 *ymax)
static int convertToRelative(QList< TTF_POINT > *points)
static QTtfGlyph generateGlyph(int index, const QPainterPath &path, qreal advance, qreal lsb, qreal ppem)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
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
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
QT_BEGIN_NAMESPACE typedef signed char qint8
static int toInt(const QChar &qc, int R)
constexpr int toInt() const
constexpr qreal toReal() const
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
qint16 minLeftSideBearing
qint16 minRightSideBearing
quint16 maxCompositeContours
quint16 maxCompositePoints
quint16 maxComponentElements
quint16 maxComponentDepth