The only workaround I can think of so far to get a fontid
for blf
that matches a text strip would be to grab the TextSequence.font.filepath
, which could be resolved to an absolute filesystem path passed to blf.load()
to get a fontid
which definitely corresponds to the font in the text strip.
Update: I can confirm the workaround works (see below), but I would prefer a more direct way of doing this if possible!
def get_fontid_from_filepath(filepath=None) -> int:
# use normpath() as blf.load() treats different representations
# of the same path as different, resulting in a new fontid
return blf.load(
os.path.normpath(
bpy.path.abspath(filepath)
))
# with a text strip selected in VSE
>>> get_fontid_from_filepath(C.selected_editable_sequences[0].font.filepath)
27