Skip to content
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

[interpolatable] WIP use uharfbuzz if available #3343

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

behdad
Copy link
Member

@behdad behdad commented Nov 17, 2023

For faster drawing. However, I'm hitting a lot of
node-count-differs errors. I have not tracked the cause down yet.

I thought this line might be:

https://github.com/harfbuzz/harfbuzz/blob/df635ab78ae1d397396e3a0fe688b8a4674b2e8a/src/hb-draw.hh#L148

But disabling it in uharfbuzz didn't help.

@behdad behdad marked this pull request as draft November 17, 2023 23:29
@behdad
Copy link
Member Author

behdad commented Nov 17, 2023

@khaledhosny Any help here is appreciated.

For faster drawing. However, I'm hitting a lot of
node-count-differs errors.  I have not tracked the
cause down yet.

I thought this line might be:

https://github.com/harfbuzz/harfbuzz/blob/df635ab78ae1d397396e3a0fe688b8a4674b2e8a/src/hb-draw.hh#L148

But disabling it in uharfbuzz didn't help.
@behdad
Copy link
Member Author

behdad commented Nov 21, 2023

Reopening to investigate so at least we know who's stealing a point from the outline!

@behdad behdad reopened this Nov 21, 2023
@anthrotype
Copy link
Member

you need to explicitly emit the implied closing line otherwise a duplicate line segment at the end of a contour can get eaten up, see

# For closed contours, a 'lineTo' is always implied from the last oncurve
# point to the starting point, thus we can omit it when the last and
# starting point don't overlap.
# However, when the last oncurve point is a "line" segment and has same
# coordinates as the starting point of a closed contour, we need to output
# the closing 'lineTo' explicitly (regardless of the value of the
# 'outputImpliedClosingLine' option) in order to disambiguate this case from
# the implied closing 'lineTo', otherwise the duplicate point would be lost.
# See https://github.com/googlefonts/fontmake/issues/572.
if (
i + 1 != nSegments
or outputImpliedClosingLine
or not closed
or pt == lastPt
):
pen.lineTo(pt)
lastPt = pt

@anthrotype
Copy link
Member

and that's because SegmentToPointPen always pops the last node when path is closed and last == first

if len(self.contour) > 1 and self.contour[0][0] == self.contour[-1][0]:
self.contour[0] = self.contour[-1]
del self.contour[-1]

so to compensate and make sure points are roundtripped when going points => segments => points you need to make sure the segment representation has explicit closing lineTos

@behdad
Copy link
Member Author

behdad commented Nov 21, 2023

Yeah but doing that in HB didn't seem to help my problem. I'll investigate more.

@behdad
Copy link
Member Author

behdad commented Nov 21, 2023

The fonttools RecordingPen and draw() work fine for me. HB is doing something different.

@behdad behdad self-assigned this Dec 6, 2023
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.

None yet

2 participants