91 Commits

Author SHA1 Message Date
Cosimo Lupo
d017d2b173
use pytest importorskip to skip modules that depend on extra requirements
this should allow to run the basic test suite against the dependency-less core of fonttools library
2023-05-24 16:26:48 +01:00
Behdad Esfahbod
45b6269cbb [qu2cuPen_test] Fix test 2023-02-22 09:32:59 -07:00
Behdad Esfahbod
8f89a435ac [ttGlyphPen] Rename preserveTopology to dropImpliedOnCurves 2023-02-22 09:08:39 -07:00
Behdad Esfahbod
dabd07e3cc [ttGlyphPen_test] Add one more test 2023-02-22 08:53:35 -07:00
Behdad Esfahbod
a32118a19f [ttGlyphPen_test] Add test with two contours
To exercise the remaining lines of ttGlyphPen.
2023-02-22 08:44:15 -07:00
Behdad Esfahbod
303eeeeec5 [ttGlyphPen_test] Parametrize test 2023-02-22 08:41:14 -07:00
Behdad Esfahbod
bbdee18f67 [ttGlyphPen_test] Exercise preserveTopology 2023-02-22 07:57:37 -07:00
Behdad Esfahbod
68bfd99da0 [ttGlyphPen_test] Exercise preserveTopology=False
Still wouldn't exercise non-empty drop codepath.
2023-02-22 07:43:14 -07:00
Behdad Esfahbod
9c60b86b46 [cu2quPen] Add all_quadratic=True 2023-02-21 14:52:15 -07:00
Behdad Esfahbod
24e798da95 [ttGlyphPen] Add tests for cubic glyf 2023-02-21 13:01:49 -07:00
Behdad Esfahbod
82e0536beb [glyf] Support cubic curves
https://github.com/harfbuzz/boring-expansion-spec/issues/41
2023-02-21 13:01:49 -07:00
Behdad Esfahbod
085b489012 [qu2cuPen] Change stats
To count number of quadratic vs cubic segments.
2023-02-21 13:01:41 -07:00
Behdad Esfahbod
94ee47c6e4 [qu2cu] Add a test and fix a bug 2023-02-20 12:22:16 -07:00
Behdad Esfahbod
f87a897c7f
Merge pull request #2993 from fonttools/qu2cu
qu2cu
2023-02-20 11:04:48 -07:00
Behdad Esfahbod
77d25b332e [qu2cu] Add test for oncurveless contour 2023-02-20 08:58:29 -07:00
Behdad Esfahbod
f1086ddb65 [qu2cu] Produce optimal mix of cubic/quadratic splines
Yay. Finally!
2023-02-18 16:36:43 -07:00
Behdad Esfahbod
3534b59631 [qu2cu] Add pen tests 2023-02-18 09:46:56 -07:00
Behdad Esfahbod
f32df5a418 [cu2quPen_test] Remove redundant test 2023-02-18 09:46:56 -07:00
Behdad Esfahbod
ac94ee9949 [Cu2QuPen] Use FilterPen 2023-02-18 09:46:56 -07:00
Behdad Esfahbod
64bce6fc9b [cu2quPen] Remove deprecated ignore_single_points 2023-02-18 09:46:56 -07:00
Cosimo Lupo
4f486ad92e
no need to massage expected test_reverse_point_pen 2023-02-17 16:56:14 +00:00
Cosimo Lupo
b64b41f645
add additional tests for outputImpliedClosingLine 2023-02-17 16:56:14 +00:00
Cosimo Lupo
a42b77bd8f
reverseContourPen_test: parametrize all existing tests with outputImpliedClosingLine 2023-02-17 15:35:18 +00:00
Cosimo Lupo
81279d2ed6
reverseContourPen_test: check outputImpliedClosingLine works as expected
I looked at this again and got suspicious becuase I noticed that the number of pen commands increased from 4 to 6, whereas I only expected it to be 5 (4+1) in the outputImpliedClosingLine=True case.

Turns out we are adding an extra duplicate lineTo right after moveTo, which I think is not correct.
2023-02-17 15:02:59 +00:00
Cosimo Lupo
c192707bab
cu2qu_test: black fix
this was merged just before the black CI check was put in
2022-12-14 19:00:16 +00:00
Cosimo Lupo
c30a6355ff
Merge pull request #2925 from fonttools/blacken-code
Blacken code
2022-12-14 18:53:35 +00:00
Behdad Esfahbod
78a939848f [Cu2QuMultiPen] Add tests and fix a but
Fixes https://github.com/fonttools/fonttools/issues/2926
2022-12-13 11:28:33 -07:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Behdad Esfahbod
78e10d8b42 [ttGlyphPen] Add outputImpliedClosingLine argument
Fixes https://github.com/fonttools/fonttools/issues/2913
2022-12-12 09:53:59 -07:00
Behdad Esfahbod
ddbbef2257 [reverseContourPen] Add outputImpliedClosingLine
Fixes https://github.com/fonttools/fonttools/issues/2914
2022-12-12 09:49:06 -07:00
Just van Rossum
d5db47e09d minor cleanup 2022-08-30 08:49:36 +02:00
Just van Rossum
b818e1494f Refactor ttGlyphSet.py
- only differentiate between glyf and CFF/CFF2 implementations, not var vs non-var
- use collections.abc.Mapping to get a more consistent dict-like object with less code
- prefer HVAR metrics over gvar metrics
- move some responsibilities from the _TTGlyphSet objects to the _TTGlyph objects
- adjust some tests to the changes
2022-08-30 08:49:36 +02:00
Cosimo Lupo
14f88fb781 Fix cu2quPen_test.py for python 3.11
Credits to pnamade from https://github.com/fonttools/fonttools/pull/2655
2022-07-06 11:16:02 +01:00
Takaaki Fuji
5f2c492635 freetypePen: format code with Black 2022-01-31 20:56:03 +09:00
Takaaki Fuji
a27789c477 freetypePen: handle rotate/skew transform
The pen is designed to determine the bitmap size when omitted, which
helps users to see an image somehow even when they have no idea how the
arguments should be passed. And I realised that I didn't give enough
thought to rotate/skew transforms in former PRs. This commit fixes the
calculation of the bbox after transformation. Also tries to clear up how
the autosizing options work in the docstring.

Some minor fixes will follow.
2022-01-31 18:08:51 +09:00
Takaaki Fuji
f87f75a437 Replace base64-encoded images with PGM files
Surprisingly I found Preview.app can still display PGM images. While
somewhat legacy, it's a super straightforward format to (de)serialize.
The images are scaled to 50x50 px and only consume 5KB in total. Makes
more sense to human being than the previous base64-encoded zlib
compressed data, plus we don't have to add pillow as a dependency.
2022-01-12 01:09:15 +09:00
Takaaki Fuji
072b4c8db0 Fit to contents when image size omitted
Eliminates the assumption of any specific metrics from the pen. It still
gives some image without giving any parameters, thus it should be a good
starting point for new users.
2022-01-11 23:02:37 +09:00
Takaaki Fuji
6f7ef4a838 Prefer single transform matrix over offset/scale 2022-01-11 23:02:37 +09:00
Takaaki Fuji
42bc1257b4 Add reference for PSNR 2022-01-11 02:26:05 +09:00
Takaaki Fuji
d399e93d95 Rename even_odd to evenOdd
PointInsidePen already uses camelCase convention for the argument.
2022-01-11 01:42:05 +09:00
Takaaki Fuji
2c0ab2a05a Relax assertions for rendering tests
There are possibilities that the rendering results may change among
FreeType versions. I've already used the PSNR comparison for cubic
vs quadratic testing, so I applied the same technique and threshold to
all rendering tests to relax assertions. Also handles the case that
MSE becomes zero. Optional dependencies are not needed for the tests.
2022-01-11 01:42:05 +09:00
Takaaki Fuji
0e880260ae Remove unnecessary import in test 2022-01-11 01:41:43 +09:00
Takaaki Fuji
d0dbbbd3c8 Rename to freetypePen/FreeTypePen 2022-01-10 23:51:28 +09:00
Takaaki Fuji
f7c29e89be Change arguments for positioning and dimension
After experimenting with uharfbuzz for a while, I found out it was hard
to handle top-to-bottom texts, so I gave up an idea to put an ascender
or a descender value in the arguments. Instead, I simply expose 'offset',
'width' and 'height', which is way more straightforward than the
previous design.

In addition, 'contain' option is added to easily compensate and render
glyphs such as combining accents or excessively tall letters.
2022-01-07 22:29:01 +09:00
Takaaki Fuji
10a3ca8ea5 Use freetype-py instead
I didn't expect that the PyPI package contains the pre-built binary
for each platform. Skip the test when freetype-py is not avaiable.
2022-01-06 19:07:26 +09:00
Takaaki Fuji
46c580f00b Fix import in unit test 2022-01-06 18:18:42 +09:00
Takaaki Fuji
e2fad4db11 Add FreeType-based Pen for rasterisation 2022-01-06 09:00:53 +09:00
Cosimo Lupo
0dc2a2a13f ttGlyphPen: test that open contours work with TTGlyphPen
currently this fails with NotImplementedError. Fix will follow in subsequent commit
2021-07-15 18:19:46 +01:00
Jens Kutilek
0cb2bea386
Add TTGlyphPointPen (#2205)
* Add TTGlyphPointPen
* Format code with black
* Implement TTGlyphPen and TTGlyphPointPen with common base class
* Use PenError instead of assert
* Add note about decomposing mixed composites to the docstring
2021-05-17 14:09:36 +02:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00