'identifier' param is part of the AbstractPointPen interface.
Even though it is unused by the segment pen protocol, the caller may attempt
to pass it by positional argument instead of keyword argument, e.g.
2920ddd07c/Lib/fontMath/mathGlyph.py (L486)
this patch avoids the resulting TypeError exception
Fix syntax error reported by build system: can't mix string string types when doing literal concatenation
Fix local import reference - doesn't work in Python3.
Addressed issues raised by @msousa for PR 1345 yesterday.
Will change cff2_merge_funcs.py and cff2mergePen.py from tab to space indentations after the current comments are resolved.
Add various improvements from comments:
- do not edit the post table under varLib.build(). Setting post table format 2 or 3 is now expected to be managed by whatever calls varLib.build().
- In the t2CharStringPen module, rename closure _round() nested in makeRoundFunc to an exportable function, and use it in cff2mergePen.
- remove TypeSupply copyright from cff2mergePen.
- use modulo function to convert float to int when it is meant to be 0 in cff2mergePen.
cff2_merge_funcs.py:merge_PrivateDicts() should only be blending the hint related fields in the PrivateDict. This oversight that was surfaced by @madig reporting an error building his Cantrell font. The bug appeared when the font was subroutinized, as the pen draw method then has to interpret the Subr field in order to access T2Charstring subroutines.
Fix expected ttx output file. When I removed the logic to add glyph names to the post table, glyph names in the ttx file changed.
Miguel prefers a simple list for readability in cff2_merge_funs.py:138.
So we now round towards +Infinity in:
- floatToFixed (which fully examplify that quotes from OT spec)
- psCharStrings: when packing floats as fixed 16.16
- t2CharStringPen: when rounding coordinates and advance widths
- subset: when rounding advance widths to compute average
- TupleVariation: rounding gvar deltas
- _g_l_y_f: when rounding coordinates: both in GlyphComponent.{x,y}
and for GlyphCoordinates.toInt()
- _h_m_t_x: for rounding horiz/vert metrics
- varLib: rounding horiz metrics and deltas
It doesn't make sense to add components that reference non-existing base glyphs
(ie. glyphs not in the input glyphSet, hence missing from the generated glyf table).
Even if we let them in here, it will fail immediately as soon as we attempt to
compile this glyf table containing 'dangling' component references.
Better to warn and skip.
This reverts commit fe2e897d13aab383d03b7759a15787ed2db99c77.
ufo2ft tests are failing with fonttools master with this error:
fontTools/cffLib/specializer.py:497:
> commands[i-1] = (new_op, args1+args2)
TypeError: can only concatenate list (not "tuple") to list
Previously, for closed paths, we were always dropping a lineTo segment
that followed moveTo, because after reversing the contour this lineTo
would become the last segment, and in the Pen protocol a closePath
always implies a line to the fist point.
This is OK when the move point and the following lineTo oncurve point
(which becomes last after reversal) don't overlap.
However, if they do, we ended up dropping the duplicate point.
This cu2qu issue exemplify the problem (cu2qu actually uses the
ReverseContourPointPen wrapped by ufoLib's converter pens, but
fontTools' ReverseContourPen does exactly the same):
https://github.com/googlei18n/cu2qu/issues/51
With this patch, the ReverseContourPen now emits the last lineTo
when it is the same as moveTo.
A filter pen that passes outline data to another pen, but reversing
the winding direction of all contours.
Like ufoLib's ReverseContourPointPen, but using segment-wise pen
interface, without additional point/segment converters, and without
ufoLib.
627f997ddb/Lib/ufoLib/pointPen.py (L327-L406)
A filter pen that accumulates contour data, passes it through a
`filterContour` method as the contour is closed or ended, and
draws the result with the output pen.
In the docstring of programToCommands, it says that:
> Each command is a two-tuple of commandname,arg-list
Previously the T2CharStringPen was passing command args as tuples instead
of lists to the specializeCommands function with option generalizeFirst=False,
which would only make a shallow copy of the input commands to modify them
in place. The problem is that it attempted to call list-only methods, leading
to errors like:
File "fontTools/cffLib/specializer.py", line 432, in specializeCommands
args.insert(pos, 0)
AttributeError: 'tuple' object has no attribute 'insert'
Since the expectation of the code here and elsewhere is that args is a
list, it makes sense that the T2 pen passes lists instead of tuples to the
specializeCommands function.
Tests are failing now, as cffLib.specializer combines operations whereas
previous pen didn't. I checked all failures and they all look like the
expectation needs to be updated to me.
Fixes https://github.com/fonttools/fonttools/issues/403
This is so we can reuse addComponent with the recording pen, without having to
inherit from the BasePen (which also splits curveTo and qCurveTo commands).
Log warning message on missing glyphs by default, optionally raise KeyError
if skipMissingComponents = False