Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backport PR #20597 on branch v3.4.x #20643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions extern/ttconv/pprdrv_tt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,17 +841,24 @@ void ttfont_sfnts(TTStreamWriter& stream, struct TTFONT *font)

/* Now, generate those silly numTables numbers. */
sfnts_pputUSHORT(stream, count); /* number of tables */
if ( count == 9 )
{
sfnts_pputUSHORT(stream, 7); /* searchRange */
sfnts_pputUSHORT(stream, 3); /* entrySelector */
sfnts_pputUSHORT(stream, 81); /* rangeShift */

int search_range = 1;
int entry_sel = 0;

while (search_range <= count) {
search_range <<= 1;
entry_sel++;
}
entry_sel = entry_sel > 0 ? entry_sel - 1 : 0;
search_range = (search_range >> 1) * 16;
int range_shift = count * 16 - search_range;

sfnts_pputUSHORT(stream, search_range); /* searchRange */
sfnts_pputUSHORT(stream, entry_sel); /* entrySelector */
sfnts_pputUSHORT(stream, range_shift); /* rangeShift */

#ifdef DEBUG_TRUETYPE
else
{
debug("only %d tables selected",count);
}
debug("only %d tables selected",count);
#endif

/* Now, emmit the table directory. */
Expand Down