258 Commits

Author SHA1 Message Date
Takaaki Fuji
9eadd908c6 freetypePen: fix bits for cubic on-curve 2022-01-31 18:08:51 +09:00
Takaaki Fuji
e1c3cdcfde freetypePen: raise PenError when missing moveTo 2022-01-31 18:08:51 +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
a7e330aa83 Revert "Raise ImportError in __init__"
This reverts commit 24d356da25a148c63c78c461a8ccc7e632371ca4.
2022-01-13 18:59:47 +09:00
Takaaki Fuji
0e5b5790ef Fix example code block formatting in docs 2022-01-13 15:09:45 +09:00
Takaaki Fuji
24d356da25 Raise ImportError in __init__
Importing freetype at import time breaks the Read the Docs build. Solves
the issue by raising an error in __init__ as fontTools.ttLib.woff2 does,
while avoiding adding an extra line to Doc/docs-requirements.txt.
2022-01-13 08:42:58 +09:00
Takaaki Fuji
d181ecaaaf Fix warnings when generating docs 2022-01-12 01:27:40 +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
e3bbf39a28 Move evenOdd to end in kwargs
Should put dimension-related arguments into a group.
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
184a6152f6 Opt out of running doctest 2022-01-11 02:00:38 +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
d0dbbbd3c8 Rename to freetypePen/FreeTypePen 2022-01-10 23:51:28 +09:00
Takaaki Fuji
9a9d0f0895 Remove save() method
As Khaled suggests, 'pen.image().save()' will do.
2022-01-10 23:43:59 +09:00
Takaaki Fuji
e3694b602b Fix another typo in docstring 2022-01-10 23:25:09 +09:00
Takaaki Fuji
bf45aec95f Fix typo 2022-01-10 19:08:11 +09:00
Takaaki Fuji
dd72f7c326 Fix missing call to superclass __init__ 2022-01-10 18:19:58 +09:00
Takaaki Fuji
e4c1deb64f Add documentation
Note that the example covers a ltr/rtl/ttb typesetting with uharfbuzz.
2022-01-08 02:06:14 +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
288d907497 Stop trying to cache modules pointlessly 2022-01-06 22:10:05 +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
55dca28734 Remove execute permission 2022-01-06 17:49:43 +09:00
Takaaki Fuji
e2fad4db11 Add FreeType-based Pen for rasterisation 2022-01-06 09:00:53 +09:00
Cosimo Lupo
9f38d4de12 svgPathPen: forgot to replace remaining str() with self._ntos()
H and V commands were not passed through the custom number-formatting callable.
2021-12-19 10:35:46 +00:00
Cosimo Lupo
fce1fa2da8 svgPathPen: add option to customize number formatting (e.g. rounding)
Using a RoundingPen as a filter doesn't work for TrueType quadratic splines (qCurveTo), because the rounding would occur too early, before these get split into atomic quadratic Bezier segments (by the superclass BasePen.qCurveTo method), thus leaving unwanted floating-point coordinates in the SVG output.
So here we add a 'ntos' parameter (by default simpli calls str()) that takes a Callable[[float], str] and can be used to customize the formatting of the numbers in SVG path coordinates.
2021-12-14 13:19:50 +00:00
Simon Cozens
0f03e6529a
[docs] Fix sphinx warnings (#2453)
* Add default auto doc options

* Ensure all references are unique

* Use anonymous links to avoid duplicate references

* Remove default options, fix wrong module name

* Don’t index repeated class

* Remove repeated classes included through automodule

* Fix warnings

* We don’t use our own static directory

* Correctly format XML in docs

* Fix indentation

* Fix overline

* Bring TOC to top

* Fix definition list

* Offset definition lists and examples

* Fix erroneous markup

* Fix markup

* Already included in automodule

* Fix args markup

* Correct markup for example

* Don’t reindex repeated module

* Correct XML code block markup

* Fix markup errors, change example to doctest

* Correct list markup

* Make ttx docstring both valid RST and valid help output

* Various other boring markup fixes

* Fix example indenting

* Make docstring valid RST and valid help output

* Mock import for reportlab

* It’s ok if manual links don’t appear in toctrees

* Oops typo, I guess doctests are useful
2021-12-02 15:31:49 +00:00
Cosimo Lupo
934349a9c5 ttGlyphPen: handle open contours starting with 'move'; treat them as if they were closed
Fixes #2365
2021-07-15 18:25:19 +01:00
Takaaki Fuji
58d6ccf8ae Fix math.atan2 call
Shouldn't make any difference here, but math.atan2(y, x) should be the
correct order.
2021-06-25 09:47:21 +09:00
Takaaki Fuji
4c22d11aa7 Keep GuessSmoothPointPen in sync with fontPens
Imported 9b7ecb4 from fontPens, which is the version modified to accept
a parameterized tolerance. Recent changes in fontTools such as 2831096,
186e461 and 7d5530e were considered so that the diff will be minimal.
2021-06-25 09:39:58 +09:00
Cosimo Lupo
c995411a60 leave self.glyphSet alone 2021-05-20 14:03:56 +01:00
Cosimo Lupo
1d9f267ad5 make glyphSet required.. but Optional :) 2021-05-20 13:20:45 +01:00
Cosimo Lupo
d4408baf70 ttGlyphPen: fix typing annotation for glyphSet parameter
It is an optional dictionary. Even the ttGlypgPen_test.py or the fontBuilder.py calls TTGlyphPen(None) often.
We caught this because internally we run a type-checker. Originally the glyphSet parameter was not explicitly typed.
Now that it is, make the type hints match the way code is intended to be used.
2021-05-20 12:33:58 +01:00
Cosimo Lupo
d0bcae94dd ttGlyphPen: run black 2021-05-20 12:30:08 +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
Nikolaus Waxweiler
b449686a84 Use TypeError for not enough points 2021-05-01 18:56:38 +01:00
Nikolaus Waxweiler
2831096eeb Introduce PenError, use instead of asserts 2021-04-30 17:19:40 +01:00
Nikolaus Waxweiler
bc2bbe6a98 RecordingPointPen: handle identifier args 2021-04-30 17:19:28 +01: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
Behdad Esfahbod
3a9a2bd4b1 [misc.roundTools] Add noRound(), maybeRound(), and roundFunc()
Moving out of CFF code, to be used in VariationModel().

Part of https://github.com/fonttools/fonttools/issues/2213
2021-03-04 09:20:43 -07:00
Behdad Esfahbod
abc1ba07a4 [misc.roundTools] New module; move otRound() here
Code relying on old place (fixedTools.otRound) still works.
2021-03-04 09:20:43 -07:00
Behdad Esfahbod
ed77aeaebf [cff] Speed-up rounding
We can choose specific round function based on tolerance once,
instead of choosing every time a number is being rounded.
2021-03-03 18:32:30 -07:00
Behdad Esfahbod
28fae1d95f [cff] Simplify rounding logic
No semantic change. Just refactoring and simplification in anticipation
of coming changes.
2021-03-03 18:27:06 -07:00
justvanrossum
2429a187fc Revert ABC changes to Pens, fixes #2198 2021-02-26 20:18:37 +01:00
Nikolaus Waxweiler
f6a62e0db1
Merge pull request #2164 from fonttools/pen-maintenance
Pen maintenance
2021-02-22 10:26:39 +00:00
Nikolaus Waxweiler
f7546baf00 Complete implementation of TTGlyphPen 2021-02-21 10:20:59 +00:00
Nikolaus Waxweiler
8a55182f37 Make NullPen inherit from AbstractPen 2021-02-21 10:20:48 +00:00
Nikolaus Waxweiler
ab1883da1d Turn AbstractPen and AbstractPointPen into ABCs plus typing 2021-02-21 10:20:37 +00:00
Simon Cozens
9cb126b10a Document expected arguments for _TTGlyphSet, _TTGlyph and TTGlyphPen 2021-02-08 11:30:39 +00:00
Nikolaus Waxweiler
a3acb1426b Remove py23 import 2021-01-29 22:23:27 +00:00
Nikolaus Waxweiler
e0de5a8413 Add MissingComponentError for pens 2021-01-12 15:26:57 +00:00