-
Notifications
You must be signed in to change notification settings - Fork 4
WIP: Implement qcurve handling in tfont #15
base: master
Are you sure you want to change the base?
Conversation
bounds = arrayTools.unionRect( | ||
bounds, bezierTools.calcQuadraticBounds(first_anchor, p1, p2) | ||
) | ||
first_anchor = p2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a lot of intermediate functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prob. fine for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would speak against reusing fontTools functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplicity & speed, basically
src/tfont/objects/path.py
Outdated
@@ -257,6 +257,8 @@ def __repr__(self): | |||
def bounds(self): | |||
points = self.points | |||
pts_len = len(points) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can do type = self._points[self._end].type
instead of using len.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not self.type
?
There is code for intersection here: https://github.com/trufont/trufont/blob/wx/src/trufont/util/bezierMath.py#L99 |
Neat! Any reason to have a bezierMath.py in Trufont and tfont? |
Ugh. The TruFont function doesn't seem to work (aside from pc0 having a |
Ok, so this is a very rough implementation that works. I don't know why fontTools' |
And for some reason, depending on ufoLib2 does not pull in fontTools[ufo]. Ugh. |
Still occasionally get
Just catch that and return |
I gave up and simply adapted |
|
I suppose I could change the return value of |
Or the index of the segment. then it can be accessed directly https://github.com/trufont/trufont/blob/wx/src/trufont/objects/factories.py#L104 |
What is the reason |
Comparison is based on identity so two different points with the same coordinates wouldn't hash to the same value. |
I find this maddeningly tricky while it looks like there must be an easy solution. |
@adrientetar So this mostly works, please advise on the segment list bookkeeping and what to return as I have code like points_inserted = len(points_to_insert) - 1
segments.insert(index, newSegment)
new_segments = []
index_start = start
for index, point in enumerate(points[start : start + points_inserted]):
if point.type is not None:
new_segments.append(Segment(points, index_start, index))
index_start += index + 1
segments[index:index+1] = new_segments
newSegment = new_segments[0]
for seg in segments[index + 1 :]:
seg._start += points_inserted
seg._end += points_inserted But that likes to delete everything except one point under certain circumstances. Even with the sledgehammer method in the PR, sometimes I can literally draw a cutting line through a glyph, deleting everything below it, if I cut a glyph just right... |
Adding the Edit: alternative approach: always depend on |
This makes the text tool work.
Todo: look at what's missing. Intersection to make ruler work.
TestFont.ufo
was cribbed from defcon. Had to changepublic.background
sA
to not be all-off-curves, otherwise UFOConverter would be stuck in an infinite loop trying to shuffle points around ;)