Crazy algorithm for displaying text size value

By Adrian Smith18 Jul 2008500 words3 mins to read

Anyone who has written any graphics or text manipulation software will know the following problem:

And there we have it: the user selects two pieces of text, one is 12pt, the other 18pt, and opens the "font size" dialog. What size is it to display? There are a number of solutions to this problem, none particularly elegant:

However, amazingly enough, I came across a new solution in the graphics program Inkscape. And it's worse than any of the above! It has a certain elegance about it, and for sure this lead to the developers thinking its a good idea, but it's certainly completely useless in practice.

The solution used by Inkscape is to display the average of the values. So if you have a character at 18pt and a character at 12pt, then display 15pt in the dialog. This is really confusing, as none of the characters you've selected actually are 15pt.

So if e.g. you have an 18pt character followed by lots of 12pt characters, as you shift-right and select more and more of the 12pt characters, the size displayed in the dialog slowly becomes less, displaying most of the time various fractional values, tending towards 12pt.

In fact–that's wrong. It's even more interesting than that. In writing this post I tried it out to check what was really happening. In fact it takes the average of the sizes of constant-sized spans of characters. For example if you have an 18pt char and a 12pt char, then it displays 15pt; if you have 18pt then 12pt then 18pt it displays 16pt; if you have 18pt then 18pt then 12pt, it displays 15pt, as there is one span of 18pt, and one span of 12pt, the average of 18pt and 12pt being 15pt.

It's crazy stuff. It took me about 20 minutes to work out that this algorithm was what was being used. With my wedding tomorrow, one would imagine I should be concentrating on things other than font size display algorithms at the moment!

This article was written by Adrian Smith on 18 Jul 2008

Follow me: Facebook | Twitter | LinkedIn | Email

More on: FAIL | Requirements & UX