I suggest using this plugin developed by me, vim-simple-guifont
: https://github.com/awvalenti/vim-simple-guifont
Then you can do:
" This check avoids loading plugin when Vim is running on terminal
if has('gui_running')
silent! call simple_guifont#Set(
\['Cascadia Code PL', 'JetBrains Mono', 'Hack'], 'Consolas', 14)
endif
For more details, please check the plugin page on GitHub.