Get localised font name
From NSIS Wiki
Jump to navigationJump to search
Author: Afrow UK (talk, contrib) |
Description
The FontName plug-in only gets the English name of a font rather than the name for the current language. The plug-in could be updated to get the font name for a specified language ID but here is an alternative.
This was made for jiake who found the undocumented GetFontResourceInfo API himself. See forum post.
The Function
Function GetFontName Exch $R0 Push $R1 Push $R2 System::Call *(i${NSIS_MAX_STRLEN})i.R1 System::Alloc ${NSIS_MAX_STRLEN} Pop $R2 System::Call gdi32::GetFontResourceInfoW(wR0,iR1,iR2,i1)i.R0 ${If} $R0 == 0 StrCpy $R0 error ${Else} System::Call *$R2(&w${NSIS_MAX_STRLEN}.R0) ${EndIf} System::Free $R1 System::Free $R2 Pop $R2 Pop $R1 Exch $R0 FunctionEnd
Usage
Push verdana.ttf Call GetFontName Pop $R0 ; Verdana