File tree 1 file changed +16
-9
lines changed
1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -841,17 +841,24 @@ void ttfont_sfnts(TTStreamWriter& stream, struct TTFONT *font)
841
841
842
842
/* Now, generate those silly numTables numbers. */
843
843
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++;
849
851
}
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
+
850
860
#ifdef DEBUG_TRUETYPE
851
- else
852
- {
853
- debug (" only %d tables selected" ,count);
854
- }
861
+ debug (" only %d tables selected" ,count);
855
862
#endif
856
863
857
864
/* Now, emmit the table directory. */
You can’t perform that action at this time.
0 commit comments