behdad/fonttools — pull request #179 by anthrotype (2014-09-29 17:43:27+00:00)
Title: [subset] option to update OS/2 ulUnicodeRanges

Hello,

I hope you'll find this helpful, at least as a start.

The bits and ranges data is taken from the current OpenType Specification v1.6:

I gathered the data and the relevant functions inside a new 'unicodeRanges.py' module, which I placed in fontTools/ttLib/tables.
I believe this is better than modifying the old OS/2 table module, or adding them only to the subset.py module (even though the latter would be it's main user, I guess).

The main updateRanges(ttFont) function simply gathers the available codepoints from all the Unicode cmap sub-tables, and check the intersection between these and the standard Unicode block ranges defined in the OT spec.

I do bit manipulation using integers and bitwise operators, instead of treating binary numbers as strings (e.g. num2binary / binary2num).
I think it makes things clearer -- well, to me at least. I collected these binary manipulation functions in a new "binTools.py" module inside fontTools/misc.

Please let me know how you think this might be improved.
Thank you,

Cosimo