Install PostScript Fonts: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
|||
(17 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{PageAuthor|Jan}} | |||
== Description == | == Description == | ||
This script is based on the [[Advanced Font Installation]] script, it can be used to install a PostScript/Type 1 font. It requires the [http://forums.winamp.com/showthread.php?s=&threadid=223066&highlight=registryWrite Registry Plugin] by Instructor | |||
== Function == | == Function == | ||
<highlight-nsis>; !insertmacro | <highlight-nsis>!ifndef GetBaseName | ||
!macro | !include FileFunc.nsh | ||
!insertmacro GetBaseName | |||
!endif | |||
; requires the Registry plugin by Instructor | |||
!macro registry::Write _PATH _VALUE _STRING _TYPE _ERR | |||
registry::_Write /NOUNLOAD `${_PATH}` `${_VALUE}` `${_STRING}` `${_TYPE}` | |||
Pop ${_ERR} | |||
!macroend | |||
!define registry::Write `!insertmacro registry::Write` | |||
; !insertmacro InstallPostScript "C:\PathTo\MyFontB.pfm" "My Font Bold" | |||
!macro InstallPostScript FontPath FontName | |||
Push $0 | Push $0 | ||
Push $R0 | Push $R0 | ||
!define Index 'Line${__LINE__}' | |||
${GetBaseName} "${FontPath}" $0 | |||
!define FontBase $0 | |||
SetOutPath $FONTS | SetOutPath $FONTS | ||
IfFileExists "$FONTS\${FontBase}.pfm" ${Index} | IfFileExists "$FONTS\${FontBase}.pfm" ${Index} "${Index}-New" | ||
"${Index}-New:" | |||
File '${FontPath}' | |||
goto ${Index} | |||
${Index}: | ${Index}: | ||
ClearErrors | ClearErrors | ||
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion" | ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion" | ||
IfErrors "${Index}-Error" "${Index}-GO" | IfErrors "${Index}-Error" "${Index}-GO" | ||
"${Index}-Error:" | "${Index}-Error:" | ||
MessageBox MB_OK|MB_ICONEXCLAMATION "PostScript fonts can only be installed in Windows 2000 or later!" | MessageBox MB_OK|MB_ICONEXCLAMATION "PostScript fonts can only be installed in Windows 2000 or later!" | ||
goto "${Index}-End" | goto "${Index}-End" | ||
"${Index}-GO:" | "${Index}-GO:" | ||
ClearErrors | 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 | ${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" | System::Call "GDI32::AddFontResourceA(t) i ('${FontBase}.pfm|${FontBase}.pfb') .s" | ||
goto "${Index}-End" | goto "${Index}-End" | ||
"${Index}-End:" | "${Index}-End:" | ||
!undef Index | !undef Index | ||
!undef FontBase | |||
Pop $R0 | Pop $R0 | ||
Pop $0 | Pop $0 | ||
!macroend</highlight-nsis> | !macroend | ||
</highlight-nsis> | |||
== Changelog == | |||
[2008-07-26] updated to require less parameters, included dependencies | |||
[2008-07-24] first public release | |||
== Additional Resources == | == Additional Resources == | ||
-[http://www.ctan.org/tex-archive/fonts/utilities/t1tools/ t1tools] is a collection of programs and batch files useful for | -[http://www.ctan.org/tex-archive/fonts/utilities/t1tools/ t1tools] is a collection of programs and batch files useful for | ||
handling type 1 fonts on MSDOS and Unix systems. | handling type 1 fonts on MSDOS and Unix systems.<br/> | ||
-[http://en.wikipedia.org/wiki/PostScript_fonts PostScript fonts] at Wikipedia | -[http://en.wikipedia.org/wiki/PostScript_fonts PostScript fonts] at Wikipedia | ||
[[Category:System Related Functions]] |
Latest revision as of 23:17, 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. It requires the Registry Plugin by Instructor
Function
!ifndef GetBaseName !include FileFunc.nsh !insertmacro GetBaseName !endif ; requires the Registry plugin by Instructor !macro registry::Write _PATH _VALUE _STRING _TYPE _ERR registry::_Write /NOUNLOAD `${_PATH}` `${_VALUE}` `${_STRING}` `${_TYPE}` Pop ${_ERR} !macroend !define registry::Write `!insertmacro registry::Write` ; !insertmacro InstallPostScript "C:\PathTo\MyFontB.pfm" "My Font Bold" !macro InstallPostScript FontPath FontName Push $0 Push $R0 !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 $R0 Pop $0 !macroend
Changelog
[2008-07-26] updated to require less parameters, included dependencies [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