I don't think there is a general solution. Once the text has been rendered, there's no reason why any component of the system would have kept the information of what font it was rendered from around.
So I'll add some tools that can help:
The output should be such as:
/usr/share/fonts/opentype/mathjax/MathJax_SansSerif-Regular.otf: MathJax_SansSerif:style=Regular
/usr/share/fonts/opentype/urw-base35/NimbusRoman-Italic.otf: Nimbus Roman:style=Italic
/usr/share/fonts/truetype/dejavu/DejaVuSans-BoldOblique.ttf: DejaVu Sans:style=Bold Oblique
/usr/share/fonts/truetype/kacst/KacstOffice.ttf: KacstOffice:style=Medium
/usr/share/fonts/type1/gsfonts/n019003l.pfb: Nimbus Sans L:style=Regular
/usr/share/fonts/truetype/abyssinica/AbyssinicaSIL-Regular.ttf: Abyssinica SIL:style=Regular
where:
/usr/share/fonts/opentype/mathjax/MathJax_SansSerif-Regular.otf File name
: Separator
MathJax_SansSerif Font name
: Separator
style=Regular The font 'style'
check man fc-list
for more details
chek man find
for more details...