42 #include <rtl/ustring.hxx>
45 #include <osl/endian.h>
53 const char *
const modname =
"SunTypeTools-TT";
61 enum PathSegmentType {
76 explicit PSPathElement( PathSegmentType i_eType ) : type( i_eType ),
86 struct TTGlyphMetrics {
96 #define HFORMAT_LINELEN 64
105 struct GlyphOffsets {
114 void *res = malloc(size);
121 void *res = calloc(n, size);
132 t = (ptr+offset)[0] << 8 | (ptr+offset)[1];
142 t = (ptr+offset)[0] << 8 | (ptr+offset)[1];
152 t = (ptr+offset)[0] << 24 | (ptr+offset)[1] << 16 |
153 (ptr+offset)[2] << 8 | (ptr+offset)[3];
163 t = (ptr+offset)[0] << 24 | (ptr+offset)[1] << 16 |
164 (ptr+offset)[2] << 8 | (ptr+offset)[3];
176 sign = (a & 0x80000000) ^ (b & 0x80000000);
190 res += a1 * b2 + b1 * a2 + ((b1 * b2) >> 16);
192 return sign ? -res : res;
201 sign = (a & 0x80000000) ^ (b & 0x80000000);
215 res = (f << 16) + (r << 16) / b;
217 return sign ? -res : res;
233 return (n * 1000) / unitsPerEm;
239 static const char HexChars[] =
"0123456789ABCDEF";
241 return HexChars[nIndex];
246 HexFmt* res =
static_cast<HexFmt*
>(
smalloc(
sizeof(HexFmt)));
247 res->bufpos = res->total = 0;
256 size_t nWritten = fwrite(_this->buffer, 1, _this->bufpos, _this->o);
257 bRet = nWritten == _this->bufpos;
265 fputs(
"<\n", _this->o);
271 fputs(
"00\n>\n", _this->o);
285 if (_this->total + size > 65534) {
291 for (i=0; i<size; i++) {
292 Ch =
static_cast<sal_uInt8 const *
>(ptr)[i];
293 _this->buffer[_this->bufpos++] =
toHex(Ch >> 4);
294 _this->buffer[_this->bufpos++] =
toHex(Ch & 0xF);
297 fputc(
'\n', _this->o);
301 _this->total += size;
312 metrics->aw = metrics->lsb = metrics->ah = 0;
316 if (glyphID < ttf->horzMetricCount())
318 metrics->aw =
GetUInt16(table, 4 * glyphID);
319 metrics->lsb =
GetInt16(table, 4 * glyphID + 2);
331 if (glyphID < ttf->vertMetricCount())
332 metrics->ah =
GetUInt16(table, 4 * glyphID);
337 static int GetTTGlyphOutline(AbstractTrueTypeFont *, sal_uInt32 , ControlPoint **, TTGlyphMetrics *, std::vector< sal_uInt32 >* );
342 sal_uInt32 nTableSize;
347 *pointArray =
nullptr;
354 if( numberOfContours <= 0 )
366 sal_uInt16 lastPoint=0;
367 const sal_Int32 nMaxContours = (nTableSize - 10)/2;
368 if (numberOfContours > nMaxContours)
370 for (i=0; i<numberOfContours; i++)
377 sal_uInt16 instLen =
GetUInt16(ptr, 10 + numberOfContours*2);
378 sal_uInt32 nOffset = 10 + 2 * numberOfContours + 2 + instLen;
379 if (nOffset > nTableSize)
383 const sal_uInt32 nBytesRemaining = nTableSize - nOffset;
384 const sal_uInt16 palen = lastPoint+1;
387 if (palen > nBytesRemaining || lastPoint > nBytesRemaining-1)
389 SAL_WARN(
"vcl.fonts",
"Font " << OUString::createFromAscii(ttf->
fileName()) <<
390 "claimed a palen of "
391 << palen <<
" but max bytes remaining is " << nBytesRemaining);
398 while (i <= lastPoint) {
400 pa[i++].
flags =
static_cast<sal_uInt32
>(flag);
404 for (j=0; j<n; j++) {
409 pa[i++].
flags = flag;
416 for (i = 0; i <= lastPoint; i++) {
417 if (pa[i].flags & 0x02) {
418 if (pa[i].flags & 0x10) {
419 z +=
static_cast<int>(*p++);
421 z -=
static_cast<int>(*p++);
423 }
else if ( !(pa[i].flags & 0x10)) {
427 pa[i].
x =
static_cast<sal_Int16
>(z);
432 for (i = 0; i <= lastPoint; i++) {
433 if (pa[i].flags & 0x04) {
434 if (pa[i].flags & 0x20) {
439 }
else if ( !(pa[i].flags & 0x20)) {
443 pa[i].
y =
static_cast<sal_Int16
>(z);
446 for (i=0; i<numberOfContours; i++) {
447 sal_uInt16 offset =
GetUInt16(ptr, 10 + i * 2);
448 SAL_WARN_IF(offset >= palen,
"vcl.fonts",
"Font " << OUString::createFromAscii(ttf->
fileName()) <<
449 " contour " << i <<
" claimed an illegal offset of "
450 << offset <<
" but max offset is " << palen-1);
453 pa[offset].
flags |= 0x00008000;
457 return lastPoint + 1;
463 return sal_uInt32(n) << 2;
468 sal_uInt16 flags,
index;
472 std::vector<ControlPoint> myPoints;
475 F16Dot16 a = 0x10000, b = 0, c = 0,
d = 0x10000,
m,
n, abs1, abs2, abs3;
477 *pointArray =
nullptr;
502 if( std::find( glyphlist.begin(), glyphlist.end(), index ) != glyphlist.end() )
504 #if OSL_DEBUG_LEVEL > 1
505 SAL_INFO(
"vcl.fonts",
"Endless loop found in a compound glyph.");
507 std::ostringstream oss;
508 oss << index <<
" -> [";
509 for(
const auto& rGlyph : glyphlist )
511 oss << (
int) rGlyph <<
" ";
519 glyphlist.push_back( index );
521 if ((np =
GetTTGlyphOutline(ttf, index, &nextComponent,
nullptr, &glyphlist)) == 0)
524 #if OSL_DEBUG_LEVEL > 1
525 SAL_WARN(
"vcl.fonts",
"An empty compound!");
530 if( ! glyphlist.empty() )
531 glyphlist.pop_back();
573 abs1 = (a < 0) ? -a : a;
574 abs2 = (b < 0) ? -b : b;
575 m = std::max(abs1, abs2);
577 if (abs3 < 0) abs3 = -abs3;
578 if (abs3 <= 33)
m *= 2;
580 abs1 = (c < 0) ? -c : c;
581 abs2 = (
d < 0) ? -
d :
d;
582 n = std::max(abs1, abs2);
584 if (abs3 < 0) abs3 = -abs3;
585 if (abs3 <= 33) n *= 2;
587 SAL_WARN_IF(np && !
m,
"vcl.fonts",
"Parsing error in " << OUString::createFromAscii(ttf->
fileName()) <<
591 for (i=0; i<np; i++) {
595 const sal_uInt16
x = nextComponent[i].
x;
596 const sal_uInt16
y = nextComponent[i].
y;
598 cp.
x =
static_cast<sal_Int16
>(
fixedMul(t,
m) >> 16);
600 cp.
y =
static_cast<sal_Int16
>(
fixedMul(t, n) >> 16);
602 myPoints.push_back( cp );
612 if( myPoints.empty() )
615 np = myPoints.size();
639 sal_Int16 numberOfContours;
641 *pointArray =
nullptr;
644 memset(metrics, 0,
sizeof(TTGlyphMetrics));
653 if (metrics)
GetMetrics(ttf, glyphID, metrics);
657 numberOfContours =
GetInt16(ptr, 0);
659 if (numberOfContours >= 0)
665 std::vector< sal_uInt32 > aPrivList;
666 aPrivList.push_back( glyphID );
667 res =
GetCompoundTTOutline(ttf, glyphID, pointArray, metrics, glyphlist ? *glyphlist : aPrivList );
677 std::vector< PSPathElement > aPathList;
679 PSPathElement
p( PS_NOOP );
681 int x0 = 0, y0 = 0, x1 = 0, y1 = 0, x2, y2, curx, cury;
682 bool lastOff =
false;
686 int StartContour = 0, EndContour = 1;
691 while (srcCount > 0) {
695 while (!(srcA[l].flags & 0x8000)) l++;
697 if (StartContour == EndContour) {
698 if (cp + 1 < srcCount) {
705 p = PSPathElement(PS_MOVETO);
706 if (!(srcA[cp].flags & 1)) {
707 if (!(srcA[EndContour].flags & 1)) {
708 p.x1 = x0 = (srcA[cp].
x + srcA[EndContour].
x + 1) / 2;
709 p.y1 = y0 = (srcA[cp].
y + srcA[EndContour].
y + 1) / 2;
711 p.x1 = x0 = srcA[EndContour].
x;
712 p.y1 = y0 = srcA[EndContour].
y;
715 p.x1 = x0 = srcA[cp].
x;
716 p.y1 = y0 = srcA[cp].
y;
719 aPathList.push_back( p );
727 if (srcA[cp].flags & 1)
731 p = PSPathElement(PS_CURVETO);
732 p.x1 = x0 + (2 * (x1 - x0) + 1) / 3;
733 p.y1 = y0 + (2 * (y1 - y0) + 1) / 3;
734 p.x2 = x1 + (curx - x1 + 1) / 3;
735 p.y2 = y1 + (cury - y1 + 1) / 3;
738 aPathList.push_back( p );
742 if (x0 != curx || y0 != cury)
744 p = PSPathElement(PS_LINETO);
747 aPathList.push_back( p );
750 x0 = curx; y0 = cury; lastOff =
false;
756 x2 = (x1 + curx + 1) / 2;
757 y2 = (y1 + cury + 1) / 2;
758 p = PSPathElement(PS_CURVETO);
759 p.x1 = x0 + (2 * (x1 - x0) + 1) / 3;
760 p.y1 = y0 + (2 * (y1 - y0) + 1) / 3;
761 p.x2 = x1 + (x2 - x1 + 1) / 3;
762 p.y2 = y1 + (y2 - y1 + 1) / 3;
765 aPathList.push_back( p );
767 x1 = curx; y1 = cury;
769 x1 = curx; y1 = cury;
775 aPathList.emplace_back(PS_CLOSEPATH );
779 if (cp >= srcCount)
break;
783 if (cp == EndContour) {
791 if( (nPathCount = static_cast<int>(aPathList.size())) > 0)
793 *path =
static_cast<PSPathElement*
>(calloc(nPathCount,
sizeof(PSPathElement)));
795 memcpy( *path, aPathList.data(), nPathCount *
sizeof(PSPathElement) );
810 const sal_uInt8* end_table = name+nTableSize;
811 const int available_space = ptr > end_table ? 0 : (end_table - ptr);
812 if( (len <= 0) || len > available_space)
815 *ucs2result =
nullptr;
820 *ucs2result =
nullptr;
822 res =
static_cast<char*
>(malloc(1 + len/2));
824 for (
int i = 0;
i < len/2;
i++)
825 res[
i] = *(ptr +
i * 2 + 1);
829 *ucs2result =
static_cast<sal_Unicode*
>(malloc( len+2 ));
830 for (
int i = 0;
i < len/2;
i++ )
832 (*ucs2result)[len/2] = 0;
835 res =
static_cast<char*
>(malloc(1 + len));
837 memcpy(res, ptr, len);
845 sal_uInt16 encodingID, sal_uInt16 languageID, sal_uInt16 nameID )
847 if (n == 0)
return -1;
853 m1 = (platformID << 16) | encodingID;
854 m2 = (languageID << 16) | nameID;
857 const int i = (l + r) >> 1;
861 if (! ((m1 < t1) || ((m1 == t1) && (m2 < t2)))) l = i + 1;
862 if (! ((m1 > t1) || ((m1 == t1) && (m2 > t2)))) r = i - 1;
887 sal_uInt32 nTableSize;
892 #if OSL_DEBUG_LEVEL > 1
893 SAL_WARN(
"vcl.fonts",
"O_name table too small.");
901 const size_t nMinRecordSize = 12;
902 const size_t nSpaceAvailable = nTableSize - 6;
903 const size_t nMaxRecords = nSpaceAvailable/nMinRecordSize;
904 if (n >= nMaxRecords)
908 bool bPSNameOK =
true;
912 if ((r =
findname(table, n, 3, 1, 0x0409, 6)) != -1)
916 if ( ! t->
psname && (r =
findname(table, n, 3, 0, 0x0409, 6)) != -1)
932 while (pReverse != t->
fileName() && *pReverse !=
'/') pReverse--;
933 if(*pReverse ==
'/') pReverse++;
934 t->
psname = strdup(pReverse);
936 for (i=strlen(t->
psname) - 1; i > 0; i--)
939 if (t->
psname[i] ==
'.' ) {
946 t->
psname = strdup(
"Unknown" );
951 if ((r =
findname(table, n, 0, 0, 0, 1)) != -1)
953 if ( ! t->
family && (r =
findname(table, n, 3, 1, 0x0409, 1)) != -1)
957 if ( ! t->
family && (r =
findname(table, n, 3, 1, 0x0411, 1)) != -1)
959 if ( ! t->
family && (r =
findname(table, n, 3, 0, 0x0409, 1)) != -1)
969 if ((r =
findname(table, n, 1, 0, 0, 2)) != -1)
984 for( i = 0; t->
psname[i] != 0 && bPSNameOK; i++ )
994 bool bReplace =
true;
996 for( i = 0; t->
ufamily[ i ] != 0 && bReplace; i++ )
1012 FILE* fd = fopen(fname,
"rb");
1014 if (fread(buffer, 1, 12, fd) == 12) {
1023 #if !defined(_WIN32)
1037 if( ! (*ttf)->fileName() )
1043 fd = open(fname, O_RDONLY);
1050 if (fstat(fd, &st) == -1) {
1055 (*ttf)->fsize = st.st_size;
1061 if ((*ttf)->fsize == 0) {
1066 if (((*ttf)->ptr = static_cast<sal_uInt8 *>(mmap(
nullptr, (*ttf)->fsize, PROT_READ, MAP_SHARED, fd, 0))) == MAP_FAILED) {
1071 ret = (*ttf)->open(facenum);
1074 if (fd != -1)
close(fd);
1088 if( *ttf ==
nullptr )
1091 (*ttf)->fsize = nLen;
1105 bool withinBounds(sal_uInt32 tdoffset, sal_uInt32 moreoffset, sal_uInt32 len, sal_uInt32 available)
1112 return result <= available;
1117 : m_pFileName(nullptr)
1118 , m_nGlyphs(0xFFFFFFFF)
1119 , m_pGlyphOffsets(nullptr)
1123 , m_xCharMap(xCharMap)
1142 , subfamily(nullptr)
1143 , usubfamily(nullptr)
1150 #if !defined(_WIN32)
1168 sal_uInt32 table_size;
1179 if (((indexfmt != 0) && (indexfmt != 1)) || (
m_nUnitsPerEm <= 0))
1184 int k = (table_size / (indexfmt ? 4 : 2)) - 1;
1192 for (
int i = 0; i <= static_cast<int>(
m_nGlyphs); ++
i)
1197 int k = (table_size / 2) - 1;
1224 if (!
ParseCMAP(table, table_size, aCmapResult))
1239 sal_uInt32 tdoffset = 0;
1243 if ((TTCTag == 0x00010000) || (TTCTag ==
T_true)) {
1245 }
else if (TTCTag ==
T_otto) {
1247 }
else if (TTCTag ==
T_ttcf) {
1248 if (!withinBounds(12, 4 * facenum,
sizeof(sal_uInt32),
fsize))
1251 if (Version != 0x00010000 && Version != 0x00020000) {
1261 if (withinBounds(tdoffset, 0, 4 +
sizeof(sal_uInt16),
fsize))
1268 for (i = 0; i < static_cast<int>(
ntables); i++)
1271 const sal_uInt32 nStart = tdoffset + 12;
1272 const sal_uInt32 nOffset = 16 * i;
1273 if (withinBounds(nStart, nOffset,
sizeof(sal_uInt32),
fsize))
1276 tag =
static_cast<sal_uInt32
>(-1);
1295 default: nIndex = -1;
break;
1298 if ((nIndex >= 0) && withinBounds(nStart, nOffset, 12 +
sizeof(sal_uInt32),
fsize))
1300 sal_uInt32 nTableOffset =
GetUInt32(
ptr + nStart, nOffset + 8);
1308 if (facenum == sal_uInt32(~0))
1320 for (p = pHead + 12; p >
ptr; --p)
1322 if( p[0]==0x5F && p[1]==0x0F && p[2]==0x3C && p[3]==0xF5 ) {
1323 int nDelta = (pHead + 12) - p;
1325 for(
int j = 0; j <
NUM_TAGS; ++j )
1345 #if OSL_DEBUG_LEVEL > 1
1347 <<
" has bad table offset "
1349 <<
"d (tagnum=" << i <<
").");
1360 #if OSL_DEBUG_LEVEL > 1
1362 <<
" has too big table (tagnum=" << i <<
").");
1398 glyphlist.push_back( glyphID );
1401 sal_uInt16 flags,
index;
1430 sal_uInt16
const *glyphArray,
sal_uInt8 *encoding,
int nGlyphs,
1434 PSPathElement *path;
1438 TTGlyphMetrics metrics;
1441 const char *
const h01 =
"%%!PS-AdobeFont-%d.%d-%d.%d\n";
1442 const char *
const h02 =
"%% Creator: %s %s %s\n";
1443 const char *
const h09 =
"%% Original font name: %s\n";
1445 const char *
const h10 =
1447 "/PaintType 0 def\n"
1449 "/StrokeWidth 0 def\n";
1451 const char *
const h11 =
"/FontName (%s) cvn def\n";
1456 const char *
const h13 =
"/FontMatrix [.001 0 0 .001 0 0] def\n";
1457 const char *
const h14 =
"/FontBBox [%d %d %d %d] def\n";
1459 const char *
const h15=
1460 "/Encoding 256 array def\n"
1461 " 0 1 255 {Encoding exch /.notdef put} for\n";
1463 const char *
const h16 =
" Encoding %d /glyph%d put\n";
1464 const char *
const h17 =
"/XUID [103 0 0 16#%08" SAL_PRIXUINT32
" %d 16#%08" SAL_PRIXUINT32
" 16#%08" SAL_PRIXUINT32
"] def\n";
1466 const char *
const h30 =
"/CharProcs %d dict def\n";
1467 const char *
const h31 =
" CharProcs begin\n";
1468 const char *
const h32 =
" /.notdef {} def\n";
1469 const char *
const h33 =
" /glyph%d {\n";
1470 const char *
const h34 =
" } bind def\n";
1471 const char *
const h35 =
" end\n";
1473 const char *
const h40 =
1475 " exch /CharProcs get exch\n"
1476 " 2 copy known not\n"
1477 " {pop /.notdef} if\n"
1481 " 1 index /Encoding get exch get\n"
1482 " 1 index /BuildGlyph get exec\n"
1484 "currentdict end\n";
1486 const char *
const h41 =
"(%s) cvn exch definefont pop\n";
1490 if (!fname) fname = ttf->
psname;
1493 fprintf(outf, h02, modname, modver, modextra);
1494 fprintf(outf, h09, ttf->
psname);
1496 fprintf(outf,
"%s", h10);
1497 fprintf(outf, h11, fname);
1510 fprintf(outf, h17, rtl_crc32(0, ttf->
ptr, ttf->
fsize), nGlyphs, rtl_crc32(0, glyphArray, nGlyphs * 2), rtl_crc32(0, encoding, nGlyphs));
1511 fprintf(outf,
"%s", h13);
1512 fprintf(outf, h14,
XUnits(UPEm,
GetInt16(table, 36)),
XUnits(UPEm,
GetInt16(table, 38)),
XUnits(UPEm,
GetInt16(table, 40)),
XUnits(UPEm,
GetInt16(table, 42)));
1513 fprintf(outf,
"%s", h15);
1515 for (i = 0; i < nGlyphs; i++) {
1516 fprintf(outf, h16, encoding[i], i);
1519 fprintf(outf, h30, nGlyphs+1);
1520 fprintf(outf,
"%s", h31);
1521 fprintf(outf,
"%s", h32);
1523 for (i = 0; i < nGlyphs; i++) {
1524 fprintf(outf, h33, i);
1536 fprintf(outf,
"\t%d %d %d %d %d %d setcachedevice\n",
1537 wmode == 0 ?
XUnits(UPEm, metrics.aw) : 0,
1538 wmode == 0 ? 0 : -
XUnits(UPEm, metrics.ah),
1539 XUnits(UPEm, metrics.xMin),
1540 XUnits(UPEm, metrics.yMin),
1541 XUnits(UPEm, metrics.xMax),
1542 XUnits(UPEm, metrics.yMax));
1544 for (j = 0; j < n; j++)
1546 switch (path[j].
type)
1549 fprintf(outf,
"\t%d %d moveto\n",
XUnits(UPEm, path[j].x1),
XUnits(UPEm, path[j].y1));
1553 fprintf(outf,
"\t%d %d lineto\n",
XUnits(UPEm, path[j].x1),
XUnits(UPEm, path[j].y1));
1557 fprintf(outf,
"\t%d %d %d %d %d %d curveto\n",
XUnits(UPEm, path[j].x1),
XUnits(UPEm, path[j].y1),
XUnits(UPEm, path[j].x2),
XUnits(UPEm, path[j].y2),
XUnits(UPEm, path[j].x3),
XUnits(UPEm, path[j].y3));
1561 fprintf(outf,
"\tclosepath\n");
1567 if (n > 0) fprintf(outf,
"\tfill\n");
1569 fprintf(outf,
"%s", h34);
1574 fprintf(outf,
"%s", h35);
1576 fprintf(outf,
"%s", h40);
1577 fprintf(outf, h41, fname);
1584 sal_uInt16
const *glyphArray,
1589 TrueTypeTable *head=
nullptr, *hhea=
nullptr, *maxp=
nullptr, *cvt=
nullptr, *prep=
nullptr, *glyf=
nullptr, *fpgm=
nullptr, *cmap=
nullptr, *
name=
nullptr, *post =
nullptr, *os2 =
nullptr;
1603 sal_uInt32 nTableSize;
1629 sal_uInt32* gID =
static_cast<sal_uInt32*
>(
scalloc(nGlyphs,
sizeof(sal_uInt32)));
1631 for (i = 0; i < nGlyphs; i++) {
1638 for (i=0; i < nGlyphs; i++) {
1639 cmapAdd(cmap, 0x010000, encoding[i], gID[i]);
1643 if ((p = ttf->
table(
O_cvt, nTableSize)) !=
nullptr)
1647 if ((p = ttf->
table(
O_prep, nTableSize)) !=
nullptr)
1651 if ((p = ttf->
table(
O_fpgm, nTableSize)) !=
nullptr)
1655 if ((p = ttf->
table(
O_post, nTableSize)) !=
nullptr)
1670 #if OSL_DEBUG_LEVEL > 1
1672 << (
int) res <<
".");
1683 GlyphOffsets* res =
static_cast<GlyphOffsets*
>(
smalloc(
sizeof(GlyphOffsets)));
1685 sal_uInt16 numTables =
GetUInt16(sfntP, 4);
1686 sal_uInt32 locaLen = 0;
1687 sal_Int16 indexToLocFormat = 0;
1689 sal_uInt32 nMaxPossibleTables = sfntLen / (3*
sizeof(sal_uInt32));
1690 if (numTables > nMaxPossibleTables)
1692 SAL_WARN(
"vcl.fonts",
"GlyphOffsetsNew claimed to have "
1693 << numTables <<
" tables, but that's impossibly large");
1694 numTables = nMaxPossibleTables;
1697 for (sal_uInt16
i = 0;
i < numTables;
i++) {
1698 sal_uInt32 nLargestFixedOffsetPos = 12 + 16 *
i + 12;
1699 sal_uInt32 nMinSize = nLargestFixedOffsetPos +
sizeof(sal_uInt32);
1700 if (nMinSize > sfntLen)
1702 SAL_WARN(
"vcl.fonts",
"GlyphOffsetsNew claimed to have "
1703 << numTables <<
" tables, but only space for " <<
i);
1708 sal_uInt32 off =
GetUInt32(sfntP, 12 + 16 *
i + 8);
1709 sal_uInt32 len =
GetUInt32(sfntP, nLargestFixedOffsetPos);
1714 }
else if (tag ==
T_head) {
1715 indexToLocFormat =
GetInt16(sfntP + off, 50);
1719 res->nGlyphs = locaLen / ((indexToLocFormat == 1) ? 4 : 2);
1720 assert(res->nGlyphs != 0);
1721 res->offs =
static_cast<sal_uInt32*
>(
scalloc(res->nGlyphs,
sizeof(sal_uInt32)));
1723 for (sal_uInt32
i = 0;
i < res->nGlyphs;
i++) {
1724 if (indexToLocFormat == 1) {
1745 SAL_WARN(
"vcl.fonts",
"DumpSfnts sfntLen is too short: "
1746 << sfntLen <<
" legal min is: " << 12);
1750 const sal_uInt32 nSpaceForTables = sfntLen - 12;
1751 const sal_uInt32 nTableSize = 16;
1752 const sal_uInt32 nMaxPossibleTables = nSpaceForTables/nTableSize;
1755 sal_uInt16
i, numTables =
GetUInt16(sfntP, 4);
1759 if (numTables > nMaxPossibleTables)
1761 SAL_WARN(
"vcl.fonts",
"DumpSfnts claimed to have "
1762 << numTables <<
" tables, but only space for " << nMaxPossibleTables);
1763 numTables = nMaxPossibleTables;
1768 sal_uInt32* offs =
static_cast<sal_uInt32*
>(
scalloc(numTables,
sizeof(sal_uInt32)));
1770 fputs(
"/sfnts [", outf);
1775 for (i=0; i<numTables; i++)
1777 sal_uInt32 nLargestFixedOffsetPos = 12 + 16 * i + 12;
1778 sal_uInt32 nMinSize = nLargestFixedOffsetPos +
sizeof(sal_uInt32);
1779 if (nMinSize > sfntLen)
1781 SAL_WARN(
"vcl.fonts",
"DumpSfnts claimed to have "
1782 << numTables <<
" tables, but only space for " << i);
1787 sal_uInt32 off =
GetUInt32(sfntP, 12 + 16 * i + 8);
1790 SAL_WARN(
"vcl.fonts",
"DumpSfnts claims offset of "
1791 << off <<
" but max possible is " << sfntLen);
1795 sal_uInt32 len =
GetUInt32(sfntP, nLargestFixedOffsetPos);
1796 sal_uInt32 nMaxLenPossible = sfntLen - off;
1797 if (len > nMaxLenPossible)
1799 SAL_WARN(
"vcl.fonts",
"DumpSfnts claims len of "
1800 << len <<
" but only space for " << nMaxLenPossible);
1811 for (sal_uInt32 j = 0; j < go->nGlyphs - 1; j++)
1813 sal_uInt32 o = go->offs[j];
1814 sal_uInt32 l = go->offs[j + 1] - o;
1821 fputs(
"] def\n", outf);
1830 sal_uInt16
const *glyphArray,
1835 TrueTypeTable *head=
nullptr, *hhea=
nullptr, *maxp=
nullptr, *cvt=
nullptr, *prep=
nullptr, *glyf=
nullptr, *fpgm=
nullptr;
1848 assert(psname !=
nullptr);
1853 sal_uInt32 nTableSize;
1857 head =
TrueTypeTableNew_head(
GetInt32(p,
HEAD_fontRevision_offset),
GetUInt16(p,
HEAD_flags_offset),
GetUInt16(p,
HEAD_unitsPerEm_offset), p+
HEAD_created_offset,
GetUInt16(p,
HEAD_macStyle_offset),
GetUInt16(p,
HEAD_lowestRecPPEM_offset),
GetInt16(p,
HEAD_fontDirectionHint_offset));
1873 if ((p = ttf->
table(
O_cvt, nTableSize)) !=
nullptr)
1877 if ((p = ttf->
table(
O_prep, nTableSize)) !=
nullptr)
1881 if ((p = ttf->
table(
O_fpgm, nTableSize)) !=
nullptr)
1886 sal_uInt16* gID =
static_cast<sal_uInt16*
>(
scalloc(nGlyphs,
sizeof(sal_uInt32)));
1888 for (i = 0; i < nGlyphs; i++) {
1901 fprintf(outf,
"%%!PS-TrueTypeFont-%d.%d-%d.%d\n", static_cast<int>(ver), static_cast<int>(ver & 0xFF), static_cast<int>(rev>>16), static_cast<int>(rev & 0xFFFF));
1902 fprintf(outf,
"%%%%Creator: %s %s %s\n", modname, modver, modextra);
1903 fprintf(outf,
"%%- Font subset generated from a source font file: '%s'\n", ttf->
fileName());
1904 fprintf(outf,
"%%- Original font name: %s\n", ttf->
psname);
1905 fprintf(outf,
"%%- Original font family: %s\n", ttf->
family);
1906 fprintf(outf,
"%%- Original font sub-family: %s\n", ttf->
subfamily);
1907 fprintf(outf,
"11 dict begin\n");
1908 fprintf(outf,
"/FontName (%s) cvn def\n", psname);
1909 fprintf(outf,
"/PaintType 0 def\n");
1910 fprintf(outf,
"/FontMatrix [1 0 0 1 0 0] def\n");
1911 fprintf(outf,
"/FontBBox [%d %d %d %d] def\n",
XUnits(UPEm,
GetInt16(headP,
HEAD_xMin_offset)),
XUnits(UPEm,
GetInt16(headP,
HEAD_yMin_offset)),
XUnits(UPEm,
GetInt16(headP,
HEAD_xMax_offset)),
XUnits(UPEm,
GetInt16(headP,
HEAD_yMax_offset)));
1912 fprintf(outf,
"/FontType 42 def\n");
1913 fprintf(outf,
"/Encoding 256 array def\n");
1914 fprintf(outf,
" 0 1 255 {Encoding exch /.notdef put} for\n");
1916 for (i = 1; i<nGlyphs; i++) {
1917 fprintf(outf,
"Encoding %d /glyph%u put\n", encoding[i], gID[i]);
1919 fprintf(outf,
"/XUID [103 0 1 16#%08X %u 16#%08X 16#%08X] def\n", static_cast<unsigned int>(rtl_crc32(0, ttf->
ptr, ttf->
fsize)), static_cast<unsigned int>(nGlyphs), static_cast<unsigned int>(rtl_crc32(0, glyphArray, nGlyphs * 2)), static_cast<unsigned int>(rtl_crc32(0, encoding, nGlyphs)));
1924 fprintf(outf,
"/CharStrings %d dict dup begin\n", nGlyphs);
1925 fprintf(outf,
"/.notdef 0 def\n");
1926 for (i = 1; i < static_cast<int>(
glyfCount(glyf)); i++) {
1927 fprintf(outf,
"/glyph%d %d def\n", i, i);
1929 fprintf(outf,
"end readonly def\n");
1931 fprintf(outf,
"FontName currentdict end definefont pop\n");
1942 sal_uInt32 nTableSize;
1955 if (!nGlyphs || !glyphArray)
return nullptr;
1956 if (!n || !pTable)
return nullptr;
1958 std::unique_ptr<sal_uInt16[]> res(
new sal_uInt16[nGlyphs]);
1961 for(
int i = 0;
i < nGlyphs; ++
i) {
1962 sal_uInt32 nAdvOffset;
1963 sal_uInt16 glyphID = glyphArray[
i];
1966 nAdvOffset = 4 * glyphID;
1968 nAdvOffset = 4 * (n - 1);
1971 if( nAdvOffset >= nTableSize)
1974 res[
i] =
static_cast<sal_uInt16
>(
1983 const uint8_t *pOs2,
size_t nOs2,
2009 sal_uInt32 table_size;
2011 if (table_size < 46)
2036 sal_uInt32 table_size;
2038 if (table_size >= 42)
2059 if (table_size >= 12 +
sizeof(sal_uInt32))
2068 if (table_size >= 10)
2087 if (length < ttf->glyphOffset(glyphID + 1))
2096 const size_t nChunkLen = ((length + 1) & ~1);
2098 memcpy(d->
ptr, srcptr, length);
2099 memset(d->
ptr + length, 0, nChunkLen - length);
2107 d->
nbytes =
static_cast<sal_uInt16
>((length + 1) & ~1);
2115 for (
int i = 0;
i < n;
i++)
2117 if (cp[
i].flags & 0x8000)
2120 d->
npoints =
static_cast<sal_uInt16
>(n);
2121 d->
ncontours =
static_cast<sal_uInt16
>(m);
2129 if (glyphID < ttf->horzMetricCount()) {
2142 sal_uInt32 nTableSize;
2147 #if OSL_DEBUG_LEVEL > 1
2148 SAL_WARN(
"vcl.fonts",
"O_name table too small.");
2154 sal_uInt32 nStrBase =
GetUInt16(table, 4);
2158 if (n == 0)
return 0;
2160 const sal_uInt32 remaining_table_size = nTableSize-6;
2161 const sal_uInt32 nMinRecordSize = 12;
2162 const sal_uInt32 nMaxRecords = remaining_table_size / nMinRecordSize;
2163 if (n > nMaxRecords)
2165 SAL_WARN(
"vcl.fonts",
"Parsing error in " << OUString::createFromAscii(ttf->
fileName()) <<
2166 ": " << nMaxRecords <<
" max possible entries, but " <<
2167 n <<
" claimed, truncating");
2174 for (i = 0; i < n; i++) {
2175 sal_uInt32 nLargestFixedOffsetPos = 6 + 10 + 12 * i;
2176 sal_uInt32 nMinSize = nLargestFixedOffsetPos +
sizeof(sal_uInt16);
2177 if (nMinSize > nTableSize)
2179 SAL_WARN(
"vcl.fonts",
"Font " << OUString::createFromAscii(ttf->
fileName()) <<
" claimed to have "
2180 << n <<
" name records, but only space for " << i);
2190 sal_uInt32 nStrOffset =
GetUInt16(table, nLargestFixedOffsetPos);
2192 if (nStrBase + nStrOffset + rec[i].slen >= nTableSize)
2194 rec[i].
sptr =
nullptr;
2199 const sal_uInt32 rec_string = nStrBase + nStrOffset;
2200 const size_t available_space = rec_string > nTableSize ? 0 : (nTableSize - rec_string);
2201 if (rec[i].slen <= available_space)
2203 rec[i].
sptr =
static_cast<sal_uInt8 *
>(malloc(rec[i].slen));
assert(rec[i].sptr !=
nullptr);
2204 memcpy(rec[i].sptr, table + rec_string, rec[i].slen);
2208 rec[i].
sptr =
nullptr;
2212 rec[i].
sptr =
nullptr;
2215 if( (rec[i].platformID == 3) && (rec[i].encodingID == 0) )
2226 for (i = 0; i < n; i++) {
2227 if (nr[i].sptr) free(nr[i].sptr);
2232 template<
size_t N>
static void
2233 append(std::bitset<N> & rSet,
size_t const nOffset, sal_uInt32
const nValue)
2235 for (
size_t i = 0;
i < 32; ++
i)
2237 rSet.set(nOffset +
i, (nValue & (1 <<
i)) != 0);
2242 std::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> &rUnicodeRange,
2243 std::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> &rCodePageRange,
2244 const unsigned char* pTable,
size_t nLength)
2250 rUnicodeRange = std::bitset<UnicodeCoverage::MAX_UC_ENUM>();
2258 rCodePageRange = std::bitset<CodePageCoverage::MAX_CP_ENUM>();
static F16Dot16 fixedMulDiv(F16Dot16 a, F16Dot16 b, F16Dot16 c)
int winDescent
descender metric for Windows
constexpr int HEAD_yMax_offset
constexpr sal_uInt32 T_head
bool symbolEncoded
true: MS symbol encoded
sal_Int32 F16Dot16
fixed: 16.16
sal_Unicode * usubfamily
subfamily name UCS2
int pitch
0: proportional font, otherwise: monospaced
constexpr int OS2_ulCodePageRange2_offset
static int GetTTGlyphOutline(AbstractTrueTypeFont *, sal_uInt32, ControlPoint **, TTGlyphMetrics *, std::vector< sal_uInt32 > *)
sal_uInt16 ncontours
number of contours
const char *const modname
static bool HexFmtFlush(HexFmt *_this)
SFErrCodes CreateTTFromTTGlyphs(AbstractTrueTypeFont *ttf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 const *encoding, int nGlyphs)
Generates a new TrueType font and dumps it to outf file.
sal_uInt32 unitsPerEm() const
constexpr int OS2_ulCodePageRange1_offset
constexpr sal_uInt32 T_OS2
constexpr sal_uInt32 T_gsub
SFErrCodes indexGlyphData()
bool compflag
false- if non-composite
sal_uInt16 fsSelection
OS/2 fsSelection.
constexpr int HEAD_unitsPerEm_offset
int CountTTCFonts(const char *fname)
Get the number of fonts contained in a TrueType collection.
sal_Int16 y
Y coordinate in EmSquare units.
std::unique_ptr< sal_uInt16[]> GetTTSimpleGlyphMetrics(AbstractTrueTypeFont const *ttf, const sal_uInt16 *glyphArray, int nGlyphs, bool vertical)
Queries glyph metrics.
std::unique_ptr< ContentProperties > pData
constexpr sal_uInt32 T_hhea
static void HexFmtBlockWrite(HexFmt *_this, const void *ptr, sal_uInt32 size)
void DisposeNameRecords(NameRecord *nr, int n)
Deallocates previously allocated array of NameRecords.
SFErrCodes
Return value of OpenTTFont() and CreateT3FromTTGlyphs()
constexpr int OS2_ulUnicodeRange1_offset
char * subfamily
subfamily name
char * psname
PostScript name.
TrueTypeTable * TrueTypeTableNew_cmap()
Creates a new empty 'cmap' table.
sal_uInt32 glyphCount() const
void CloseTTFont(TrueTypeFont *ttf)
TrueTypeFont destructor.
SFErrCodes OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
constexpr sal_uInt32 T_true
constexpr int HHEA_descender_offset
constexpr sal_uInt32 T_loca
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
constexpr int HEAD_created_offset
constexpr int POST_underlineThickness_offset
constexpr int HEAD_macStyle_offset
static HexFmt * HexFmtNew(FILE *outf)
constexpr int OS2_fsType_offset
constexpr sal_uInt32 T_vhea
constexpr int OS2_ulUnicodeRange3_offset
exports com.sun.star. table
static char toHex(sal_uInt8 nIndex)
sal_uInt32 m_nHorzMetrics
TrueTypeTable * TrueTypeTableNew_glyf()
Creates a new empty 'glyf' table.
constexpr int HEAD_lowestRecPPEM_offset
TrueTypeTable * TrueTypeTableNew(sal_uInt32 tag, sal_uInt32 nbytes, const sal_uInt8 *ptr)
Creates a new raw TrueType table.
bool hasTable(sal_uInt32 ord) const override
constexpr int HEAD_Length
static void HexFmtCloseString(HexFmt *_this)
constexpr int HEAD_xMax_offset
Structure used by the TrueType Creator and GetRawGlyphData()
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
TrueTypeTable * TrueTypeTableNew_maxp(const sal_uInt8 *maxp, int size)
Creates a new 'maxp' table based on an existing maxp table.
sal_uInt16 nbytes
number of bytes in glyph data
incorrect logical font number of a TTC font
int width
value of WidthClass or 0 if can't be determined
constexpr int GLYF_numberOfContours_offset
int GetTTGlyphComponents(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal_uInt32 > &glyphlist)
For a specified glyph adds all component glyphs IDs to the list and return their number.
sal_uInt8 panose[10]
PANOSE classification number.
sal_Int16 x
X coordinate in EmSquare units.
constexpr int OS2_panoseNbBytes_offset
constexpr int HEAD_fontDirectionHint_offset
constexpr int OS2_typoAscender_offset
static F16Dot16 fromF2Dot14(sal_Int16 n)
constexpr sal_uInt32 T_cmap
int yMin
global bounding box: yMin
const char * fileName() const
FontCharMapRef GetCharMap() const
SFErrCodes open(sal_uInt32 facenum)
constexpr int OS2_usWidthClass_offset
sal_uInt32 vertMetricCount() const
static void * smalloc(size_t size)
TrueTypeFont(const char *pFileName=nullptr, const FontCharMapRef xCharMap=nullptr)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
virtual const sal_uInt8 * table(sal_uInt32 ord, sal_uInt32 &size) const =0
TrueTypeTable * TrueTypeTableNew_head(sal_uInt32 fontRevision, sal_uInt16 flags, sal_uInt16 unitsPerEm, const sal_uInt8 *created, sal_uInt16 macStyle, sal_uInt16 lowestRecPPEM, sal_Int16 fontDirectionHint)
Creates a new 'head' table for a TrueType font.
static void * scalloc(size_t n, size_t size)
SFErrCodes CreateT42FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *psname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs)
Generates a new PostScript Type42 font and dumps it to outf file.
void TrueTypeCreatorDispose(vcl::TrueTypeCreator *_this)
TrueTypeCreator destructor.
static void HexFmtDispose(HexFmt *_this)
constexpr int OS2_Legacy_length
static F16Dot16 fixedDiv(F16Dot16 a, F16Dot16 b)
static GlyphOffsets * GlyphOffsetsNew(sal_uInt8 *sfntP, sal_uInt32 sfntLen)
SFErrCodes StreamToFile(TrueTypeCreator *_this, const char *fname)
Writes a TrueType font generated by the TrueTypeCreator to a file.
constexpr sal_uInt32 T_prep
int winAscent
ascender metric for Windows
constexpr int OS2_typoDescender_offset
TrueTypeTable * TrueTypeTableNew_hhea(sal_Int16 ascender, sal_Int16 descender, sal_Int16 linegap, sal_Int16 caretSlopeRise, sal_Int16 caretSlopeRun)
Creates a new 'hhea' table for a TrueType font.
constexpr int HHEA_caretSlopeRise_offset
void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info)
Returns global font information about the TrueType font.
void GetTTFontMetrics(const uint8_t *pHhea, size_t nHhea, const uint8_t *pOs2, size_t nOs2, TTGlobalFontInfo *info)
Returns fonts metrics.
GlyphData * GetTTRawGlyphData(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID)
Extracts raw glyph data from the 'glyf' table and returns it in an allocated GlyphData structure...
TrueTypeTable * TrueTypeTableNew_post(sal_Int32 format, sal_Int32 italicAngle, sal_Int16 underlinePosition, sal_Int16 underlineThickness, sal_uInt32 isFixedPitch)
Creates a new 'post' table of one of the supported formats.
static int findname(const sal_uInt8 *name, sal_uInt16 n, sal_uInt16 platformID, sal_uInt16 encodingID, sal_uInt16 languageID, sal_uInt16 nameID)
sal_uInt32 typeFlags
type flags (copyright bits)
#define SAL_N_ELEMENTS(arr)
constexpr sal_uInt32 T_maxp
constexpr int HEAD_yMin_offset
ControlPoint structure used by GetTTGlyphPoints()
constexpr sal_uInt32 T_glyf
constexpr sal_uInt32 T_cvt
constexpr int OS2_winAscent_offset
int typoAscender
OS/2 portable typographic ascender.
static int BSplineToPSPath(ControlPoint const *srcA, int srcCount, PSPathElement **path)
constexpr int HHEA_ascender_offset
int ascender
typographic ascent.
static void DumpSfnts(FILE *outf, sal_uInt8 *sfntP, sal_uInt32 sfntLen)
constexpr int HHEA_lineGap_offset
AbstractTrueTypeFont(const char *fileName=nullptr, const FontCharMapRef xCharMap=nullptr)
int GetTTNameRecords(AbstractTrueTypeFont const *ttf, NameRecord **nr)
Extracts all Name Records from the font and stores them in an allocated array of NameRecord structs...
bool GetTTGlobalFontHeadInfo(const AbstractTrueTypeFont *ttf, int &xMin, int &yMin, int &xMax, int &yMax, sal_uInt16 &macStyle)
Returns part of the head table info, normally collected by GetTTGlobalFontInfo.
int descender
typographic descent.
static sal_Int32 GetInt32(const sal_uInt8 *ptr, size_t offset)
incorrect number of glyphs
constexpr int HEAD_indexToLocFormat_offset
constexpr int HEAD_flags_offset
int italicAngle
in counter-clockwise degrees * 65536
constexpr sal_uInt32 T_hmtx
std::enable_if< std::is_signed< T >::value, bool >::type checked_add(T a, T b, T &result)
sal_uInt32 horzMetricCount() const
sal_uInt16 platformID
Platform ID.
sal_uInt8 * sptr
Pointer to string data (not zero-terminated!)
constexpr int HEAD_fontRevision_offset
virtual bool hasTable(sal_uInt32 ord) const =0
static char * nameExtract(const sal_uInt8 *name, int nTableSize, int n, int dbFlag, sal_Unicode **ucs2result)
static void HexFmtOpenString(HexFmt *_this)
constexpr sal_uInt32 T_fpgm
int typoLineGap
OS/2 portable typographic line gap.
int weight
value of WeightClass or 0 if can't be determined
int yMax
global bounding box: yMax
constexpr int GLYF_xMin_offset
sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, AbstractTrueTypeFont *fnt)
Add a glyph to a glyf table.
static sal_Int16 GetInt16(const sal_uInt8 *ptr, size_t offset)
constexpr int GLYF_yMax_offset
static void append(std::bitset< N > &rSet, size_t const nOffset, sal_uInt32 const nValue)
void TrueTypeCreatorNewEmpty(sal_uInt32 tag, TrueTypeCreator **_this)
TrueTypeCreator constructor.
constexpr int OS2_V0_length
static sal_uInt16 GetUInt16(const sal_uInt8 *ptr, size_t offset)
static int GetSimpleTTOutline(AbstractTrueTypeFont const *ttf, sal_uInt32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics)
constexpr int POST_isFixedPitch_offset
const sal_uInt8 * table(sal_uInt32 ord, sal_uInt32 &size) const override
constexpr int GLYF_xMax_offset
std::array< struct TTFontTable_, NUM_TAGS > m_aTableList
virtual ~AbstractTrueTypeFont()
constexpr int OS2_typoLineGap_offset
int xMax
global bounding box: xMax
sal_uInt16 macStyle
macstyle bits from 'HEAD' table
int xMin
global bounding box: xMin
Structure used by the TrueType Creator and CreateTTFromTTGlyphs()
incorrect TrueType font format
SFErrCodes StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length)
Writes a TrueType font generated by the TrueTypeCreator to a segment of memory that this method alloc...
sal_uInt32 glyphOffset(sal_uInt32 glyphID) const
sal_Int16 lsb
left sidebearing
constexpr int HEAD_xMin_offset
#define SAL_WARN_IF(condition, area, stream)
static void GlyphOffsetsDispose(GlyphOffsets *_this)
sal_uInt16 encodingID
Platform-specific encoding ID.
LanguageType languageID
Language ID.
#define SAL_INFO(area, stream)
constexpr int OS2_V1_length
constexpr sal_uInt32 T_name
constexpr sal_uInt32 T_otto
constexpr sal_uInt32 T_post
bool getTTCoverage(std::optional< std::bitset< UnicodeCoverage::MAX_UC_ENUM >> &rUnicodeRange, std::optional< std::bitset< CodePageCoverage::MAX_CP_ENUM >> &rCodePageRange, const unsigned char *pTable, size_t nLength)
constexpr int OS2_winDescent_offset
constexpr int OS2_panose_offset
constexpr sal_uInt32 T_ttcf
sal_Unicode * ufamily
family name UCS2
void cmapAdd(TrueTypeTable *table, sal_uInt32 id, sal_uInt32 c, sal_uInt32 g)
Add a character/glyph pair to a cmap table.
constexpr int POST_underlinePosition_offset
sal_uInt16 slen
String length in bytes.
sal_uInt16 npoints
number of points
const char *const modextra
static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics, std::vector< sal_uInt32 > &glyphlist)
constexpr sal_uInt32 T_CFF
int linegap
typographic line gap. Negative values are treated as zero in Win 3.1, System 6 and System 7...
constexpr int OS2_fsSelection_offset
void AddTable(TrueTypeCreator *_this, TrueTypeTable *table)
Adds a TrueType table to the TrueType creator.
static void GetMetrics(AbstractTrueTypeFont const *ttf, sal_uInt32 glyphID, TTGlyphMetrics *metrics)
int GetTTGlyphPoints(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray)
Extracts TrueType control points, and stores them in an allocated array pointed to by *pointArray...
sal_uInt16 aw
advance width
static int XUnits(int unitsPerEm, int n)
sal_uInt32 glyphID
glyph ID
TrueTypeTable * TrueTypeTableNew_name(int n, NameRecord const *nr)
Creates a new 'name' table.
sal_uInt32 glyfCount(const TrueTypeTable *table)
Query the number of glyphs currently stored in the 'glyf' table.
#define SAL_WARN(area, stream)
void(* f)(TrueTypeTable *)
static sal_uInt32 GetUInt32(const sal_uInt8 *ptr, size_t offset)
SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode)
Generates a new PostScript Type 3 font and dumps it to outf file.
sal_uInt32 flags
00000000 00000000 e0000000 bbbbbbbb
sal_uInt16 nameID
Name ID.
sal_uInt32 m_nVertMetrics
bool ParseCMAP(const unsigned char *pCmap, int nLength, CmapResult &rResult)
constexpr int HEAD_majorVersion_offset
constexpr int HHEA_caretSlopeRun_offset
constexpr int POST_italicAngle_offset
constexpr int OS2_usWeightClass_offset
static F16Dot16 fixedMul(F16Dot16 a, F16Dot16 b)
int typoDescender
OS/2 portable typographic descender.
constexpr int OS2_ulUnicodeRange2_offset
Return value of GetTTGlobalFontInfo()
constexpr sal_uInt32 T_vmtx
sal_uInt32 * m_pGlyphOffsets
static void GetNames(TrueTypeFont *t)
constexpr int GLYF_yMin_offset
constexpr int OS2_ulUnicodeRange4_offset
sal_uInt8 * ptr
pointer to glyph data
FontCharMapRef m_xCharMap
SFErrCodes OpenTTFontBuffer(const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.