Text Dimensions Are Hard

This blog post natters on about SVG/Emacs font issues, but ends with a question to an Emacs-knowledgeable audience. Feel free to skip to the end if you know Emacs stuff!

Anyway, eplot, the Emacs charting library, needs to know the actual text dimensions for certain things.

Not for the labels on the x axis here — eplot generates SVGs, and SVG can anchor a text to the middle. It even works well with exotic fonts like Jolie Romantique, which is my go-to font for testing weird font rendering artefacts:

Even in the presence of strange things like ligatures that represent swooshes, SVG gets it right with some renderers:

But this fails when using things like rsvg-convert. Hey, Rust Evangelical Strikeforce! Get it together!

Anyway! I wasn’t really going to whine about font rendering, but whine about Emacs. In eplot, I need to see how much space a piece of text will really end up taking, and I need that to calculate how much space I need for things like the Y axes there. And there’s really no other way to determine that than to render the text and see what you get (due to fonts having weird/useless general data, not to mention ligatures and stuff).

For instance, to have these labels centred under each bar, I need to know how tall a typical non-descending character (e.g., “x” and not “g”), because when you specify where to put a text in SVG, the position it renders from is that baseline.

That approach even works with exotic fonts.

So… determining the actual room a text will take is necessary — not only to place the texts at the right place, but to determine how many of the texts we have room for on the axes. We can “eyeball” these things sometimes — we can take the font size and make “guesses” based on that… but in the chart above, the font size used is 60.

And in this chart, where the characters are approximately the same size visually, the font size used is 30!

And that’s the problem I’m whining about here!

OK, if you’re using very normal, boring fonts at lower point sizes, these problems aren’t massive, but once you start stepping up the point sizes, the charts soon look pretty ugly, what with off-centred tick marks and the like.

For instance, did you notice that the vertically rendered x-axis tick marks in the chart above were wrong? Me neither, until I started writing this.

There. Fixed. It was using the height of an “x” to determine the baseline, because that’s generally correct with text (“Thing” both ascends and descends, and you have to be consistent), but if the labels are all numerical, they just ascend from the baseline, making them off-centre.

*phew*

Anyway, an obvious way to see how much space a text takes is to create an SVG, convert it to PNG, strip away the background and then see what’s left. So let’s see how much time it takes.

(benchmark-run
  (cl-loop for size from 0 upto 99
           collect (eplot--text-size-1 "Testing" "futura" 'bold size)))
=> 22.8

Yeah, 22 seconds to do 100 texts using ImageMagick convert to determine the sizes. Because ImageMagick is dog slow on SVGs — it calls out to other programs to do the rendering.

(In practice, this isn’t quite as horrible as it sounds — for a typical chart, eplot only has to measure a couple of strings. And it caches the values.)

(benchmark-run
 (cl-loop for size from 0 upto 99
          collect (eplot--text-size-1 "Testing" "futura" 'bold size)))
=> 4.694829387

But if I do the rendering with rsvg-convert, it takes a fifth of the time. But now we need two external programs, one of which isn’t installed on that many systems…

Emacs does have built-in things to determine the actual width of a text (because I built it into Emacs 😉), so let’s try that:

(benchmark-run
  (cl-loop for size from 0 upto 99
           collect (eplot--text-width-2 "Testing" "futura" 'bold size)))
=> 0.19

Hey, nice! 0.2s is a lot faster than 4.7s (or 22s).

So what am I whining about? Here’s what I’m whining about: Emacs doesn’t have a way to see how tall a text is!

What am I talking about! Of course it does! But no.

Emacs has line-pixel-height, and that’s the room Emacs reserves for a line. (The red box there shows it.)

So that’s the size of the “F”, right?

No, it’s just using the font metrics, and there’s no way to get Emacs to tell me how tall that “o” really is.

I think! Does anybody know how to make Emacs cough out some data on that? It sucks to have to rely on external programs for stuff like this.

C’mon! Emacs power!

Random Comics

Here’s some comics I’ve read over the past few weeks…

Carlos Giménez has been finishing all his various series over the last few years, and this book collects his final Paracuellos albums.

And while the anger against the gruesome, horrible Spanish homes for children is still present, it’s a lot more mediated than in previous installations.

And in the final instalments he’s more writing about all the things he regrets doing himself, and what an absolute ass he could be as a child. So that’s interesting… but the final, long (100+ pages) album here is a bit of a mess structurally. But still, compelling in bits.

I like that Fantagraphics are doing collections of underground comics artists, because there’s a lot of material that’s not been collected at all, and some of it’s even pretty good.

I’m not sure about this George Metzger book, though. The reproduction is great, but somehow whatever charm these books had doesn’t seem to be present here.

I’ve read much of this material before, and I remember it being better than this? Or perhaps I was just younger.

Artwork’s good, though, and there’s some fun strips.

Yes, it’s another issue of the Finnish anthology Kuti.

It’s really good! But as usual I wished they’d flip the Finnish/English text, because reading the comics while having to move your eyes to the bottom of the page all the time is exhausting.

It’s nice though.

And this one is about Palestine.

I’m not really a big Winsor McCay fan…

… and this collects bits and pieces from his early career.

It’s interesting, but I wasn’t really that into it this time either.

I bought all (?) the issues of Det grymma svärdet, a long-running Swedish anthology/fanzine series the other year, and have been going through them slowly. Almost every issue is in a different format, which is fun.

And some have cassettes and stuff.

In this batch, there really isn’t that much comics material — it’s mostly poetry and prose and stuff, but there’s some comics.

Mostly Swedish things.

But also translations of people like Simon Hanselmann.

Speaking of long-running series, I read the newest You Don’t Get There From Here issues (by Carrie McNinch).

We’re at about a four year interval between what she’s writing about and now, but that works really well especially with this bunch — because this takes place at the start of the Covid pandemic, so we get to re-live how that felt.

It’s a really enjoyable read. And the latest issue comes with a Chu-Hi sticker! I guess you can buy it from here or something…

Web of Horror was a short-lived Warren knock-off, but this collects all three issues, the aborted fourth issues, and another issue’s worth of related comics.

The first couple issues make it pretty clear why this magazine didn’t last long, because the writing is, well, awful. The third issue is actually good, though. And the artwork is nice throughout (Bernie Wrightson, William Kaluta, etc).

The better stories in here were reprinted by Eclipse Comics back in the 80s, so I’ve read those bits already.

But still, if you’re a fan of these artists — sure, pick up a copy. But it’s not like this is a lost masterpiece or anything, like the editorial material here seems to exhort the reader into believing…

OK, that’s it. Go about your business.

Film Directors and Consensus

Yesterday I mused (data-scientifically) on whether certain 80s arthouse directors didn’t place on the Sight & Sound 2022 Poll because there just wasn’t much of a consensus yet about which ones of their movies were the best.

And the answer seemed to be “not really”.

But today I started wondering whether there really are directors where that’s a major thing — that is, are there any directors that would have placed highly if everybody that voted for a director’s films voted for the same one from that director’s oeuvre.

Tada!

So this chart plots how much further up the chart a director would be if the poll was computed cumulatively per director instead of per film. And wow, that was unexpected!

The “highest scorer” (or most unlucky director) is somebody named James Benning, who would have placed 1300 places higher up than any of his movies did. And that’s a name I don’t recognise at all! He has 14 (!) movies that somebody have voted for, but none of them received more than two votes.

I’m not familiar with him at all, and he seems to be doing mostly documentaries? Which explains me not being familiar with his work.

Next up is Raúl Ruiz, who would have jumped 800 places. He has 11 movies that received votes, but none more than 4 votes.

He’s from Chile, and I don’t think I’ve seen any of his movies? But he sounds interesting… I should fix that.

Third place is Jim Jarmusch, who would also skip ahead 800 places. He has 6 movies that people have voted for, and the one with the most votes is Stranger than Paradise with four votes.

We also see Wes Anderson (who would advance 640 places), John Houston (543 places) and Clint Eastwood (530 places), and so on. So, yes, there’s definitely a too-many-memorable-movies effect that’s going on.

Conversely, if we ranked directors by total votes, who would sink the most? Yeah, it’s directors that have just one well known movie (like Charles Laughton), or directors where people have pretty much decided on which one is their masterpiece (like Jacques Tati and Playtime).

Anyway. The Sight & Sound poll is about the “best movies”, not about favourite directors… but I thought this was moderately interesting anyway.