• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

behdad / fonttools / 932
70%
master: 72%

Build:
Build:
LAST BUILD BRANCH: opentype-gx
DEFAULT BRANCH: master
Ran 17 Apr 2016 09:33PM UTC
Jobs 1
Files 164
Run time 5s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
932

push

travis-ci

behdad
[WIP] TTFont: Use mmap if possible

As discussed here:
https://github.com/behdad/fonttools/issues/580#issuecomment-211110222

Before:
$ python -m timeit 'from fontTools.ttLib import TTFont; TTFont("sazanami-gothic.ttf")'
10 loops, best of 3: 66.9 msec per loop

After:
$ python -m timeit 'from fontTools.ttLib import TTFont; TTFont("sazanami-gothic.ttf")'
10000 loops, best of 3: 110 usec per loop

That's a 600x speedup!

Fixes https://github.com/behdad/fonttools/issues/482

HOWEVER, it reintroduces https://github.com/behdad/fonttools/issues/302
Or worse, we'll crash when overwriting:

$ cp Lobster.ttf t.ttf
$ ./ttx -o ./t.ttf ./t.ttf
Dumping "./t.ttf" to "./t.ttf"...
Dumping 'GlyphOrder' table...
Bus error (core dumped)

IMO we should fix this by changing both XML and font output routines to,
instead of calling open, use os.tmpfile(), create output in a new file
and then rename it to the final destination.  It has the benefit of not
leaving a half-written output file behind if an exception occurs.  The
tempfile.NamedTemporaryFile also comes handy.

While checking those out, tempfile.SpooledTemporaryFile also comes handy,
when it's available, to replace BytesIO in the following part of TTFont.save():

	# write to a temporary stream to allow saving to unseekable streams
	tmp = BytesIO()

Looks like we need to start misc.fileTools to abstract the details away.

10 of 10 new or added lines in 1 file covered. (100.0%)

19101 of 27131 relevant lines covered (70.4%)

0.7 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
2
100.0
Lib/fontTools/ttLib/__init__.py
Jobs
ID Job ID Ran Files Coverage
13 932.13 (TOXENV=coveralls) 17 Apr 2016 09:33PM UTC 0
70.4
Travis Job 932.13
Source Files on build 932
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Travis Build #932
  • 02e023e2 on github
  • Next Build on mmap (#934)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc