ND2: improve text annotation parsing

Fixes #10420.