Install PostScript Fonts: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
Line 4: Line 4:


== Function ==
== Function ==
!ifndef GetBaseName
<highlight-nsis>!ifndef GetBaseName
!include FileInc.nsh
!include FileInc.nsh
!insertmacro GetParent
!insertmacro GetParent
!endif
!endif


<highlight-nsis>; !insertmacro InstallType1 "C:\PathTo\MyFontB.pfm" "My Font Bold"
; !insertmacro InstallType1 "C:\PathTo\MyFontB.pfm" "My Font Bold"
!macro InstallType1 FontPath FontName
!macro InstallType1 FontPath FontName
   Push $0
   Push $0

Revision as of 21:32, 26 July 2008

Author: Jan (talk, contrib)


Description

This script is based on the Advanced Font Installation script, it can be used to install a PostScript/Type 1 font

Function

!ifndef GetBaseName
	!include FileInc.nsh
	!insertmacro GetParent
!endif
 
; !insertmacro InstallType1 "C:\PathTo\MyFontB.pfm" "My Font Bold"
!macro InstallType1 FontPath FontName
  Push $0
  Push $R0
  Push $R1
  Push $R2
 
  !define Index 'Line${__LINE__}'
 
  ${GetBaseName} ${FontPath} $0
  !define FontBase $0
 
  SetOutPath $FONTS
  IfFileExists "$FONTS\${FontBase}.pfm" ${Index} "${Index}-New"
 
"${Index}-New:"
  File '${FontPath}'
  goto ${Index}
 
${Index}:
  ClearErrors
  ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
  IfErrors "${Index}-Error" "${Index}-GO"
 
"${Index}-Error:"
  MessageBox MB_OK|MB_ICONEXCLAMATION "PostScript fonts can only be installed in Windows 2000 or later!"
  goto "${Index}-End"
 
"${Index}-GO:"
    ClearErrors
    ${registry::Write} "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Type 1 Installer\Type 1 Fonts" "${FontName}" "T ${FontBase}.pfm ${FontBase}.pfb" "REG_MULTI_SZ" $R0
    System::Call "GDI32::AddFontResourceA(t) i ('${FontBase}.pfm|${FontBase}.pfb') .s"
    goto "${Index}-End"
 
"${Index}-End:"
 
  !undef Index
  !undef FontBase 
 
  Pop $R2
  Pop $R1
  Pop $R0
  Pop $0
!macroend

Changelog

[2008-07-24] first public release

Additional Resources

-t1tools is a collection of programs and batch files useful for handling type 1 fonts on MSDOS and Unix systems.
-PostScript fonts at Wikipedia