Skip to content

Commit 76e1ce5

Browse files
QuLogicjkseppan
authored andcommitted
Backport PR #20597: Fix TTF headers for type 42 stix font
1 parent c19a4d3 commit 76e1ce5

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

extern/ttconv/pprdrv_tt.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -841,17 +841,24 @@ void ttfont_sfnts(TTStreamWriter& stream, struct TTFONT *font)
841841

842842
/* Now, generate those silly numTables numbers. */
843843
sfnts_pputUSHORT(stream, count); /* number of tables */
844-
if ( count == 9 )
845-
{
846-
sfnts_pputUSHORT(stream, 7); /* searchRange */
847-
sfnts_pputUSHORT(stream, 3); /* entrySelector */
848-
sfnts_pputUSHORT(stream, 81); /* rangeShift */
844+
845+
int search_range = 1;
846+
int entry_sel = 0;
847+
848+
while (search_range <= count) {
849+
search_range <<= 1;
850+
entry_sel++;
849851
}
852+
entry_sel = entry_sel > 0 ? entry_sel - 1 : 0;
853+
search_range = (search_range >> 1) * 16;
854+
int range_shift = count * 16 - search_range;
855+
856+
sfnts_pputUSHORT(stream, search_range); /* searchRange */
857+
sfnts_pputUSHORT(stream, entry_sel); /* entrySelector */
858+
sfnts_pputUSHORT(stream, range_shift); /* rangeShift */
859+
850860
#ifdef DEBUG_TRUETYPE
851-
else
852-
{
853-
debug("only %d tables selected",count);
854-
}
861+
debug("only %d tables selected",count);
855862
#endif
856863

857864
/* Now, emmit the table directory. */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy