33 Commits

Author SHA1 Message Date
Behdad Esfahbod
5132bbe411 [symfont] Remove glyph perimeter from GlyphStatistics
It's not technically statistics the same way the other properties are, and
we have a separate pen for it, so remove. Goal is to turn GlyphStatistics
into a pen.

Also remove perimeter from interpolatable.py contour characteristics vector.
Shouldn't be needed, given all the stats we already include.
2017-02-20 12:36:15 -06:00
Behdad Esfahbod
a8db22a077 Move MomentsPen into fontTools.pens.momentsPen 2017-02-20 12:33:12 -06:00
Behdad Esfahbod
d9bccb8609 [symfont] Simplify GlyphStatistics; just compute everything upfront
Our MomentsPen is sooooooooo fast now, there's no point trying to
make it lazy.
2017-02-20 11:28:44 -06:00
Behdad Esfahbod
a94e0f4e52 [symfont] Remove unused CovarianceMatrix 2017-02-20 10:17:07 -06:00
Behdad Esfahbod
da4b81e9ab Add momentsPen as generated by symfont:printPen()
To be moved to proper place soon.

Using this in interpolatable.py makes the core of the computation over an
order of magnitude faster.
2017-02-20 10:17:07 -06:00
Behdad Esfahbod
78637fb8c8 [symfont] Allow printing to files 2017-02-20 10:17:07 -06:00
Behdad Esfahbod
afe3407ca5 [symfont] More 2017-02-20 10:17:07 -06:00
Behdad Esfahbod
aaa950ea59 [symfont] Remove unused _Eigen method 2017-02-20 10:17:07 -06:00
Behdad Esfahbod
c8a82dcfee [symfont] Protect against math errors
Note that because our contours can overlap arbitrarily, our variance can end up
being negative, so, allow for that.
2017-02-20 10:17:07 -06:00
Behdad Esfahbod
223ecc6453 Revert "[symfont] Make sure variance is never negative (float precision issue)"
This reverts commit 5c025c6a03cca2ebe3390671a81aaca28492e71c.

Investigating why I'm seeing non-negligible negative variance.
2017-02-20 10:17:07 -06:00
Behdad Esfahbod
8869a5b343 [symfont] Minor 2017-02-19 13:59:56 -06:00
Behdad Esfahbod
5f82438206 [symfont] Write code to write optimized code for green-derived pens
Eg.:
printPen('MomentsPen',
         [('area', 1),
          ('momentX', x),
          ('momentY', y),
          ('momentXX', x*x),
          ('momentXY', x*y),
          ('momentYY', y*y)])
2017-02-19 02:50:06 -06:00
Behdad Esfahbod
aceabc032f [symfont] Minor 2017-02-19 00:10:41 -06:00
Behdad Esfahbod
5c025c6a03 [symfont] Make sure variance is never negative (float precision issue) 2017-02-17 19:44:32 -06:00
Behdad Esfahbod
67fdff238b [symfont] Optimize generated expression a bit 2017-02-17 19:44:32 -06:00
Behdad Esfahbod
e90f9b7d58 [symfont] Minor 2016-12-22 16:11:04 -06:00
Behdad Esfahbod
501e1f2f7e [symfont] Remove another level of indirection
Saves another few percents, though not as much as previous commit.
2016-07-11 12:23:56 -07:00
Behdad Esfahbod
7fd9dce0e9 [symfont] Speed up a bit
Remove one level of indirection in access to point data in generated
functions; ie. use p0, p1, ... instead of P[0], P[1], ...

Makes for about 10% speedup.
2016-07-11 12:23:56 -07:00
Behdad Esfahbod
cde56fce66 [symfont] Minor 2016-07-11 12:23:56 -07:00
Behdad Esfahbod
b3414e9ffd [symfont] Use AreaPen from fontTools
It's about 20% faster.
2016-06-14 01:26:39 -04:00
Behdad Esfahbod
acbd3df647 [symfont] Add function to print function sources for caching 2016-06-14 01:23:40 -04:00
Behdad Esfahbod
1a48fc27a1 [symfont] Remove one level of function call 2016-06-14 01:16:57 -04:00
Behdad Esfahbod
56c27f45c9 Speed up perimeterPen
It's still too slow, but an improvement.

Also, remove duplicate copy from symfont.
2016-06-13 18:50:01 -04:00
Behdad Esfahbod
b7cf54aef1 [symfont] Minor 2016-06-13 18:20:42 -04:00
Behdad Esfahbod
c34739760c [symfont] Handle closePath()
Apparently some draw() implementations expect closePath() to
draw a line to the contour beginning.

In fact, looks like fontTools's TrueType draw() always does the
lineTo() before closePath(), but the CFF draw() doesn't.

As raised in
https://github.com/behdad/fonttools/pull/618#issuecomment-225314022
2016-06-10 16:06:22 -07:00
Behdad Esfahbod
7822958fa5 [symfont] Negate sign in green() function
Following the theorem declaration:
https://en.wikipedia.org/wiki/Green%27s_theorem

we should negate the result.  Ie, for a counter-clockwise curve,
the area must be positive.

Raised in
https://github.com/behdad/fonttools/pull/618#issuecomment-225205335
2016-06-10 15:58:56 -07:00
Behdad Esfahbod
0204b66d30 [symfont] Simplify lambdify
A possible alternative solution to the proposed dummify solution...

Might fix https://github.com/behdad/fonttools/issues/595
2016-04-30 15:49:44 +02:00
n8willis
8325ae8c00 Fix berstein typo. 2016-04-26 19:16:46 -05:00
Behdad Esfahbod
6bfe6989de [Snippets/symfont] Add glyph perimeter to GlyphStatistics 2016-04-06 18:15:43 -07:00
Behdad Esfahbod
2e816d6c2d [symfont] Permissions 2016-03-21 10:12:26 -07:00
Behdad Esfahbod
8d9f04c576 Typo 2016-03-13 11:24:35 -07:00
Behdad Esfahbod
7319cd0afc Minor 2016-03-12 02:21:07 -08:00
Behdad Esfahbod
b01c41bcea [Snippets] Add symfont.py, for symbolic font statistics analysis 2016-03-10 06:13:18 -08:00