8000 [_g_l_y_f] fix float precision loss in GlyphCoordinates by anthrotype · Pull Request #964 · fonttools/fonttools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[_g_l_y_f] fix float precision loss in GlyphCoordinates #964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2017

Conversation

anthrotype
Copy link
Member

This failing test is to show the issue #963.
The patch below fixes it.

I don't see problems with changing GlyphCoordinates to using doubles instead of floats, but I'd like to hear from others before committing the change in case I may be missing something.

diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
index 1e255506..b4586e39 100644
--- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py
+++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
@@ -1170,13 +1170,13 @@ class GlyphCoordinates(object):
 		return self._a
 
 	def isFloat(self):
-		return self._a.typecode == 'f'
+		return self._a.typecode == 'd'
 
 	def _ensureFloat(self):
 		if self.isFloat():
 			return
 		# The conversion to list() is to work around Jython bug
-		self._a = array.array("f", list(self._a))
+		self._a = array.array("d", list(self._a))
 
 	def _checkFloat(self, p):
 		if self.isFloat():

@anthrotype
Copy link
Member Author

@behdad
Copy link
Member
behdad commented May 16, 2017

LGTM.

@anthrotype
Copy link
Member Author

thanks

@anthrotype anthrotype merged commit ced61f7 into fonttools:master May 16, 2017
@anthrotype anthrotype deleted the coords-as-double branch May 16, 2017 16:16
@behdad
Copy link
Member
behdad commented Apr 7, 2021

We now do rounding before serializing to tables. Should we consider changing back to float?

behdad added a commit that referenced this pull request Apr 7, 2021
We do proper rounding these days, so revert this back.

#964 (comment)
behdad added a commit that referenced this pull request Apr 8, 2021
We do proper rounding these days, so revert this back.

#964 (comment)
behdad added a commit that referenced this pull request Apr 8, 2021
We do proper rounding these days, so revert this back.

#964 (comment)
behdad added a commit that referenced this pull request Apr 8, 2021
We do proper rounding these days, so revert this back.

#964 (comment)
simoncozens pushed a commit to simoncozens/fonttools that referenced this pull request Oct 22, 2021
We do proper rounding these days, so revert this back.

fonttools#964 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0