File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed
Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -800,16 +800,23 @@ void ttfont_sfnts(TTStreamWriter& stream, struct TTFONT *font)
800800
801801 /* Now, generate those silly numTables numbers. */
802802 sfnts_pputUSHORT (stream, count); /* number of tables */
803- if ( count == 9 )
804- {
805- sfnts_pputUSHORT (stream, 7 ); /* searchRange */
806- sfnts_pputUSHORT (stream, 3 ); /* entrySelector */
807- sfnts_pputUSHORT (stream, 81 ); /* rangeShift */
808- }
809- else
810- {
811- debug (" only %d tables selected" ,count);
803+
804+ int search_range = 1 ;
805+ int entry_sel = 0 ;
806+
807+ while (search_range <= count) {
808+ search_range <<= 1 ;
809+ entry_sel++;
812810 }
811+ entry_sel = entry_sel > 0 ? entry_sel - 1 : 0 ;
812+ search_range = (search_range >> 1 ) * 16 ;
813+ int range_shift = count * 16 - search_range;
814+
815+ sfnts_pputUSHORT (stream, search_range); /* searchRange */
816+ sfnts_pputUSHORT (stream, entry_sel); /* entrySelector */
817+ sfnts_pputUSHORT (stream, range_shift); /* rangeShift */
818+
819+ debug (" only %d tables selected" ,count);
813820
814821 /* Now, emmit the table directory. */
815822 for (x=0 ; x < 9 ; x++)
You can’t perform that action at this time.
0 commit comments