{"action":"created","issue":{"url":"https://api.github.com/repos/fonttools/fonttools/issues/686","repository_url":"https://api.github.com/repos/fonttools/fonttools","labels_url":"https://api.github.com/repos/fonttools/fonttools/issues/686/labels{/name}","comments_url":"https://api.github.com/repos/fonttools/fonttools/issues/686/comments","events_url":"https://api.github.com/repos/fonttools/fonttools/issues/686/events","html_url":"https://github.com/fonttools/fonttools/issues/686","id":180489278,"number":686,"title":"Cannot change woff compression level with sfnt.ZLIB_COMPRESSION_LEVEL","user":{"login":"severinmeyer","id":12496525,"avatar_url":"https://avatars.githubusercontent.com/u/12496525?v=3","gravatar_id":"","url":"https://api.github.com/users/severinmeyer","html_url":"https://github.com/severinmeyer","followers_url":"https://api.github.com/users/severinmeyer/followers","following_url":"https://api.github.com/users/severinmeyer/following{/other_user}","gists_url":"https://api.github.com/users/severinmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/severinmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/severinmeyer/subscriptions","organizations_url":"https://api.github.com/users/severinmeyer/orgs","repos_url":"https://api.github.com/users/severinmeyer/repos","events_url":"https://api.github.com/users/severinmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/severinmeyer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-02T01:18:57Z","updated_at":"2016-10-02T09:43:13Z","closed_at":null,"body":"Currently, setting `sfnt.ZLIB_COMPRESSION_LEVEL` to a custom value does not have any effect.\r\n\r\nThe culprit: [Lib/fontTools/ttLib/sfnt.py#L496](https://github.com/fonttools/fonttools/blob/1eba7b383c785924a33c30f6e38cebd571819a5f/Lib/fontTools/ttLib/sfnt.py#L496)\r\n\r\nThe problem is that `zlibCompressionLevel` is accessed as an instance variable, but it is actually declared as a class variable at [Lib/fontTools/ttLib/sfnt.py#L481](https://github.com/fonttools/fonttools/blob/1eba7b383c785924a33c30f6e38cebd571819a5f/Lib/fontTools/ttLib/sfnt.py#L481). As a result, it is instantiated once when the module is loaded, and any later change of `sfnt.ZLIB_COMPRESSION_LEVEL` is not propagated.\r\n\r\nPossible solution: Ditch the variable and use `ZLIB_COMPRESSION_LEVEL` directly:\r\n```python\r\nif not self.uncompressed:\r\n    compressedData = compress(data, ZLIB_COMPRESSION_LEVEL)\r\n```"},"comment":{"url":"https://api.github.com/repos/fonttools/fonttools/issues/comments/250962888","html_url":"https://github.com/fonttools/fonttools/issues/686#issuecomment-250962888","issue_url":"https://api.github.com/repos/fonttools/fonttools/issues/686","id":250962888,"user":{"login":"severinmeyer","id":12496525,"avatar_url":"https://avatars.githubusercontent.com/u/12496525?v=3","gravatar_id":"","url":"https://api.github.com/users/severinmeyer","html_url":"https://github.com/severinmeyer","followers_url":"https://api.github.com/users/severinmeyer/followers","following_url":"https://api.github.com/users/severinmeyer/following{/other_user}","gists_url":"https://api.github.com/users/severinmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/severinmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/severinmeyer/subscriptions","organizations_url":"https://api.github.com/users/severinmeyer/orgs","repos_url":"https://api.github.com/users/severinmeyer/repos","events_url":"https://api.github.com/users/severinmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/severinmeyer/received_events","type":"User","site_admin":false},"created_at":"2016-10-02T09:43:13Z","updated_at":"2016-10-02T09:43:13Z","body":"That makes sense.\r\n\r\nHowever, it still seems problematic to use **self.**zlibCompressionLevel, because it doesn't exist and falls back to the class variable. Which is why I assumed this is a mistake in the first place.\r\n\r\nNow, forgive me if I make a fool of myself, but is there any documentation on how to change the compression level? Because I ended up following the `--with-zopfli` option, which activates zopfli via `sfnt.USE_ZOPFLI` [here](http://github.com/fonttools/fonttools/blob/1eba7b383c785924a33c30f6e38cebd571819a5f/Lib/fontTools/ttx.py#L264). It therefore seemed obvious that the compression level should be changed with `sfnt.ZLIB_COMPRESSION_LEVEL` [right next to it](http://github.com/fonttools/fonttools/blob/1eba7b383c785924a33c30f6e38cebd571819a5f/Lib/fontTools/ttLib/sfnt.py#L136-L141).\r\n\r\nIn any case, I highly value FontTools and simply try to figure out how to use it correctly."}}
{"actor":{"display_login":"severinmeyer"}}