Get localised font name: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Created page with '{{PageAuthor|Afrow UK}} == 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 updat…')
 
 
Line 4: Line 4:
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.
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.
This was made for '''jiake''' who found the undocumented GetFontResourceInfo API himself. [http://forums.winamp.com/showthread.php?t=319648 See forum post].


== The Function ==
== The Function ==

Latest revision as of 12:01, 4 June 2010

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