Is there a way to determine the size of a text sequence?

Just to round this off for anyone else who like me is looking for a way to get the size of a text sequence, the workaround I posted on devtalk:

This feels like an ugly workaround, as it relies on Blender caching / reusing fontids for the same font file; but it works.

The basic approach is:

  1. get filepath property from TextSequence.font (ref)
  2. resolve that to the absolute path via Python’s path.normpath() - just using Blender’s path.abspath() gives an ‘absolute path relative (??!) to the blend’; if you don’t and use the ‘absolute relative’ path you get a new fontid, which should still work for getting the size, but it feels better to have obvious side effects
  3. use that path with blf.load() to get the fontid
  4. set size with blf.size() and theTextSequence.font_size property
  5. finally, get size via blf.dimensions() and the TextSequence.text property

For actual code, you can look at the get_strip_text_size() function in my addon.