Rotate 90º seems to send contours upward.
ryan last edited by ryan
I'm wondering if it'd make sense to slightly alter the built-in RF way to rotate. Continuing to rotate often won't return you to your home position, and instead send the glyph up or down, presumably because the bounds are odd.
See video demo, and alternative script suggestion:
g = CurrentGlyph() # gather midpoint of selection xs =  ys =  for pt in g.selection: xs.append(pt.x) ys.append(pt.y) mid_x = round((max(xs) + min(xs)) / 2) mid_y = round((max(ys) + min(ys)) / 2) # rotate around midpoint for pt in g.selection: pt.rotateBy(90, origin = (mid_x, mid_y)) g.update()
This is for the
selection, but you get the idea.
RoboFont is using
see the difference here:
from fontTools.misc.fixedTools import otRound value = .5 print(otRound(value)) print(round(value)) value = .49 print(otRound(value)) print(round(value)) value = .51 print(otRound(value)) print(round(value))
RF’s native rotate still sends the contour upward, and otRound doesn’t: see here. Something else must be going on.
yeah, if this is the case then the numbers are just not working for you... by hitting a single
rthe points are rotated and rounded off, next them the same happens.
I can reproduce all cases: moving up, moving right, doing nothing... with both the internal rotation and your example script. I just have to move a point 1 unit up/down/left/right.
@frederik I see. I just did some more testing with
roundand it looks like
otRoundgoes rightward over several rotations, which I now notice from my last video.
roundseems to return home each time, though. Any reason
roundwould be bad?
round: stationary on average
Here's another video and test script:
from fontTools.misc.fixedTools import otRound g = CurrentGlyph() # contour 0 : round c_0 = g mid_x_0 = round((c_0.bounds + c_0.bounds) / 2) mid_y_0 = round((c_0.bounds + c_0.bounds) / 2) c_0.rotateBy(90, origin = (mid_x_0, mid_y_0)) # contour 1 : otRound c_1 = g mid_x_1 = otRound((c_1.bounds + c_1.bounds) / 2) mid_y_1 = otRound((c_1.bounds + c_1.bounds) / 2) c_1.rotateBy(90, origin = (mid_x_1, mid_y_1)) g.update()
I tried when only the rounding the offset position with the default python
roundits that seems to be oke... And this will be "fixed" in the next beta/release.
The reason why every rounding is with
otRoundis to keep a single rounding func for all sort of rounding.
This is also the difference between
roundin py2 vs py3.
@frederik Makes sense to lean toward using one method. Did not know their were changes to
roundfrom py2 to py3! Appreciate you looking at this, Frederik!