30 Commits

Author SHA1 Message Date
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +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
f05691246a {fixed,round}Tools: factor out nearestMultipleShortestRepr
extract the code from fixedToStr into its own function (defined in roundTools), to be used for serializing fractional F2Dot14 angles for COLRv1 PaintRotate etc.
2021-07-06 17:35:03 +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
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
Simon Cozens
775dc6074e
fontTools.misc.* documentation, part 2 (#1981)
* Document misc.filenames
* Document misc.fixedTools
* Document misc.intTools
* Document misc.loggingTools
* Document misc.macCreatorType
* Document misc.macRes
* Document misc.plistlib
2020-06-08 15:53:48 +01:00
Cosimo Lupo
550711e106
move MAX_F2DOT14 constant to fixedTools 2019-10-23 16:50:12 +01:00
Cosimo Lupo
6fd31d47ec
fixedTools: use simple divison in fixedToFloat; add floatToFixedToStr, strToFixedToFloat, etc.
Fixes #737
2019-10-08 13:40:03 +01:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Cosimo Lupo
d570fc038a
use otRound when rounding visual coordinates or deltas
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
2018-06-14 17:40:11 +01:00
Cosimo Lupo
585b87023f
fixedTools: add otRound to round floats to nearest int towards +Infinity
https://github.com/fonttools/fonttools/issues/1248
2018-06-14 17:15:47 +01:00
Cosimo Lupo
94c79e4cbd [fixedTools] add floatToFixedToFloat to __all__ 2017-10-22 12:22:56 +01:00
Cosimo Lupo
28bb992c1f replace int(round(...)) with round(...)
We don't need to cast to int when using the round function from py23,
as this is a backport of python3's built-in round and thus it returns
an int when called with a single argument.
2017-10-22 12:03:52 +01:00
Behdad Esfahbod
117f8f0eb3 [varLib.mutator] Quantize normalized location to F2Dot14 2017-10-20 20:13:14 -04:00
Behdad Esfahbod
e9eb1f3297 Fix __all__ entry
Fixes https://github.com/fonttools/fonttools/issues/920
2017-04-13 15:49:01 -07:00
moyogo
f591e8c503 fixedTools: add ensureVersionIsLong() and versionToFixed() 2016-10-18 18:18:09 +02:00
Miguel Sousa
a7aef47695 fix "indentation contains mixed spaces and tabs" errors reported by Landscape 2015-08-09 00:33:50 -07:00
Cosimo Lupo
d7d59c527d [fixedTools] make sure fixedToFloat function returns float on both python 2 and 3 2015-07-24 16:48:07 +01:00
Behdad Esfahbod
8963f3bbed Simplify fixedToFloat() a bit more 2015-06-08 17:26:59 -07:00
Behdad Esfahbod
a09d96f6a2 Leave values unchanged in fixed → float → fixed round-trip conversions
Fixes https://github.com/behdad/fonttools/issues/286
Fixes https://github.com/behdad/fonttools/pull/287
2015-06-08 11:35:40 -07:00
Sascha Brawer
2019cfa180 Move fixedTools tests to unittests
Lifted from https://github.com/behdad/fonttools/pull/287

Adds new roundtrip tests, but they are disabled.
2015-06-08 11:11:36 -07:00
Behdad Esfahbod
b30e12ae00 More whitespace 2015-04-26 02:01:01 -04:00
Behdad Esfahbod
bd67253118 Some more whitespace fixes from pep8 tool 2015-04-26 01:59:01 -04:00
Behdad Esfahbod
467a0369e4 Fix test on Python 2.6 2015-03-03 16:05:25 -08:00
Behdad Esfahbod
e02b9ea05b Fix tests to return failures 2015-03-03 10:47:40 -08:00
Behdad Esfahbod
d86755bd45 Really fix fixedToFloat() this time
And simplify.  Fixes regression introduced two commits ago.

Fixes https://github.com/behdad/fonttools/issues/205
2014-12-29 11:56:39 -08:00
Behdad Esfahbod
db3b2817bf Add more tests to fixedToFloat(), showing previous commit is broken
Fix coming.
2014-12-29 11:30:48 -08:00
Behdad Esfahbod
97a07ce536 Improve fixedtoFloat()
Fixes https://github.com/behdad/fonttools/issues/205
2014-12-28 23:52:46 -08:00
Behdad Esfahbod
1ae29591ef from __future__ import absolute_import
Such that our Python 2 is closer to Python 3.

Part of https://github.com/behdad/fonttools/issues/77
2014-01-14 15:07:50 +08:00
Behdad Esfahbod
2d67a188b1 py23 Add fixedTools: Smart fixedToFloat() and floatToFixed()
Apparently Python 2 and Python 3 have different default
print precisions for floats.  Or at least with my build it
is the case.   As such, for example with amiri-regular.ttf
I see these annoying differences in the ttx output of the
two versions:

77203c77203
<       <component ... scale="0.5999755859375" flags="0x1004"/>
---
>       <component ... scale="0.599975585938" flags="0x1004"/>

That's just gross.  Specially when these numbers are show to
humans, while we know that's just 0.6.  The fixedToFloat()
routine in this module is smart enough to do that.

Not used yet.
2013-11-28 18:53:30 -05:00