How does Emacs choose which glyph to use (i.e. from which font to pick the glyph from) in case the required character is missing from the user's chosen font?

I have noticed that if I use Source Code Pro and insert some greek characters into the buffer, it picks those characters from the font Noto Sans Display instead.

I have a need to do the same thing (I've been implementing a new font renderer for McCLIM) and since Emacs does such a good job with it, I wanted to see how Emacs does it, but I have been unable to find the code where this substitution happens.

Does anyone know where in the Emacs code base this happens, and what the algorithm is?

Regards,
Elias