Skip to content

Commit

Permalink
add comment about float to 2.14 fixed conversion and vv.
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed May 8, 2021
1 parent e887c2f commit 2f533d9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/uharfbuzz/_harfbuzz.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ cdef class Font:
cdef unsigned int length
cdef const int *coords
coords = hb_font_get_var_coords_normalized(self._hb_font, &length)
# Convert from 2.14 fixed to float: divide by 1 << 14
return [coords[i] / 0x4000 for i in range(length)]

def set_var_coords_normalized(self, coords):
Expand All @@ -454,6 +455,7 @@ cdef class Font:
raise MemoryError()
try:
for i in range(length):
# Convert from float to 2.14 fixed: multiply by 1 << 14
coords_2dot14[i] = round(coords[i] * 0x4000)
hb_font_set_var_coords_normalized(self._hb_font, coords_2dot14, length)
finally:
Expand Down

0 comments on commit 2f533d9

Please sign in to comment.