Debian Bug report logs - #312379
Important performance patch that speeds things up over 10x for CJK fonts

version graph

Package: fonttools; Maintainer for fonttools is Paul Wise <>; Source for fonttools is src:fonttools.

Reported by: Tomasz Wegrzanowski <>

Date: Tue, 7 Jun 2005 20:03:02 UTC

Severity: normal

Tags: patch

Fixed in version 1.99+2.0b1+cvs20031014-1

Done: Paul Wise <>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox

Report forwarded to, Anthony Fok <>:
Bug#312379; Package fonttools. Full text and rfc822 format available.

Acknowledgement sent to Tomasz Wegrzanowski <>:
New Bug report received and forwarded. Copy sent to Anthony Fok <>. Full text and rfc822 format available.

Message #5 received at (full text, mbox):

From: Tomasz Wegrzanowski <>
To: Debian Bug Tracking System <>
Subject: Important performance patch that speeds things up over 10x for CJK fonts
Date: Tue, 07 Jun 2005 21:54:31 +0200
[Message part 1 (text/plain, inline)]
Package: fonttools
Version: 1.99+2.0b1+cvs20031014-1
Severity: normal
Tags: patch

ttx accidentally uses a O(n^2) algorithm for converting hexdump to binary:
  hexdata = ""
  for chunk in content:
    if type(chunk) == type(""):
      hexdata = hexdata + chunk

This *copies* hexdata on every line. The mistake is understandable,
as the code looks similar to perl's (and few other languages') idiom
  for $chunk(@content) { $hexdata .= $chunk if something($chunk) }
that works in place.

For Western fonts, that are usually in ~100kB size range, the O(n^2)
behaviour is not very problematic, but the CJK fonts are often 5-10MB
or larger, so it takes about forever for the hexdump to binary conversion
on ttx->ttf to finish (I don't know how long exactly, I ^C-ed the program
and started debugging after about 25 minutes on 6MB Sazanami Gothic font)

The patch replaces 2 instances of:
	data = ""
		data = data + something
	return data
with semantically equivalent, but O(n):
	data = []
	return "".join(data)

Actually I converted readHex to more pythonesque list-comprehension format
instead of appending in loop (it's equivalent to the loop, after compilation),
but this isn't very important.

In a different thread,
fonttools seems to have many other bugs that appear when I try to process CJK fonts
with it, and the last release on was in 2002. Is it abandoned ?
[performance_patch_for_cjk_fonts.diff (text/plain, attachment)]

Reply sent to Paul Wise <>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Tomasz Wegrzanowski <>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #10 received at (full text, mbox):

From: Paul Wise <>
Subject: fontools 1.99+2.0b1+cvs20050624-2 fixes these bugs
Date: Fri, 07 Oct 2005 12:26:21 +0800
[Message part 1 (text/plain, inline)]
Version: 1.99+2.0b1+cvs20031014-1

I've adopted this package and found a sponsor to upload the new package,
which fixes all these bugs.

[signature.asc (application/pgp-signature, inline)]

Bug archived. Request was from Debbugs Internal Request <> to (Tue, 26 Jun 2007 16:46:21 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.

Debian bug tracking system administrator <>. Last modified: Fri Apr 18 21:14:38 2014; Machine Name:

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.