{"action":"created","issue":{"url":"https://api.github.com/repos/fontforge/fontforge/issues/2749","repository_url":"https://api.github.com/repos/fontforge/fontforge","labels_url":"https://api.github.com/repos/fontforge/fontforge/issues/2749/labels{/name}","comments_url":"https://api.github.com/repos/fontforge/fontforge/issues/2749/comments","events_url":"https://api.github.com/repos/fontforge/fontforge/issues/2749/events","html_url":"https://github.com/fontforge/fontforge/pull/2749","id":166879227,"number":2749,"title":"Zero pfminfo structure to fix FNT file metrics, closes #2748","user":{"login":"mungre","id":20479547,"avatar_url":"https://avatars.githubusercontent.com/u/20479547?v=3","gravatar_id":"","url":"https://api.github.com/users/mungre","html_url":"https://github.com/mungre","followers_url":"https://api.github.com/users/mungre/followers","following_url":"https://api.github.com/users/mungre/following{/other_user}","gists_url":"https://api.github.com/users/mungre/gists{/gist_id}","starred_url":"https://api.github.com/users/mungre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mungre/subscriptions","organizations_url":"https://api.github.com/users/mungre/orgs","repos_url":"https://api.github.com/users/mungre/repos","events_url":"https://api.github.com/users/mungre/events{/privacy}","received_events_url":"https://api.github.com/users/mungre/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-21T17:52:58Z","updated_at":"2016-07-21T22:09:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/fontforge/fontforge/pulls/2749","html_url":"https://github.com/fontforge/fontforge/pull/2749","diff_url":"https://github.com/fontforge/fontforge/pull/2749.diff","patch_url":"https://github.com/fontforge/fontforge/pull/2749.patch"},"body":"### Motivation and Context\r\n\r\nCloses #2748\r\n\r\n### Types of changes\r\nWhat types of changes does your code introduce? Check all the boxes that apply:\r\n- [X] Bug fix (non-breaking change which fixes an issue)\r\n\r\n### Description\r\n\r\nThe _FntFontDump function uses the SFDefaultOS2Info function to populate a pfminfo structure with font metrics that are written to the FNT file.\r\n\r\nThe SFDefaultOS2Info function requires the pfminfo structure to be zeroed otherwise it can produce bogus values for a few metrics including linegap, which is used to calculate the external leading.\r\n\r\nThis fix zeroes the structure.  It also fixes the problem for FON files because they are made of FNT files.\r\n\r\nWith one exception, every other call to SFDefaultOS2Info either uses the pfminfo embedded in the SplineFont structure, or zeroes its local structure first.  The exception is in scripting.c, so I fixed that one too.  I don't know that this one was causing any observable problem.\r\n\r\n### Final checklist\r\n\r\n- [X] My code follows the code style of this project found [here](https://github.com/fontforge/fontforge/blob/master/CONTRIBUTING.md#coding-style).\r\n- [ ] My change requires a change to the documentation.\r\n- [ ] I have updated the documentation accordingly.\r\n- [X] I have read the [**CONTRIBUTING**](https://github.com/fontforge/fontforge/blob/master/CONTRIBUTING.md) guidelines.\r\n"},"comment":{"url":"https://api.github.com/repos/fontforge/fontforge/issues/comments/234399580","html_url":"https://github.com/fontforge/fontforge/pull/2749#issuecomment-234399580","issue_url":"https://api.github.com/repos/fontforge/fontforge/issues/2749","id":234399580,"user":{"login":"mungre","id":20479547,"avatar_url":"https://avatars.githubusercontent.com/u/20479547?v=3","gravatar_id":"","url":"https://api.github.com/users/mungre","html_url":"https://github.com/mungre","followers_url":"https://api.github.com/users/mungre/followers","following_url":"https://api.github.com/users/mungre/following{/other_user}","gists_url":"https://api.github.com/users/mungre/gists{/gist_id}","starred_url":"https://api.github.com/users/mungre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mungre/subscriptions","organizations_url":"https://api.github.com/users/mungre/orgs","repos_url":"https://api.github.com/users/mungre/repos","events_url":"https://api.github.com/users/mungre/events{/privacy}","received_events_url":"https://api.github.com/users/mungre/received_events","type":"User","site_admin":false},"created_at":"2016-07-21T22:09:50Z","updated_at":"2016-07-21T22:09:50Z","body":"@adrientetar SFDefaultOS2Info supports the initialization of a pfminfo structure which has already been partially initialized.  This is indicated by the hheadset and vheadset members.\r\n\r\nIf every stack-allocated pfminfo was zeroed (as I said above) then we could do the zeroing in SFDefaultOS2Info.  I double-checked using grep and found that github search had missed both calls to SFDefaultOS2Info in fontforgeexe/fontinfo.c.  One of these uses a stack-allocated pfminfo that is preinitialized to SplineFont.pfminfo with some additional changes.\r\n\r\nSo we can't distinguish between a stack-allocated pfminfo structure that needs to be zeroed, and one that has already been partially initialized.\r\n"}}
{"actor":{"display_login":"mungre"}}