Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from i3thuan5/jithe
Browse files Browse the repository at this point in the history
install.nsi tàu 字體
  • Loading branch information
niauah authored May 5, 2020
2 parents c791077 + d5cf7e2 commit a43a8fb
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 1 deletion.
161 changes: 161 additions & 0 deletions output/FontReg.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
var FONT_DIR

!ifndef CSIDL_FONTS
!define CSIDL_FONTS '0x14' ;Fonts directory path constant
!endif
!ifndef CSIDL_FLAG_CREATE
!define CSIDL_FLAG_CREATE 0x8000
!endif

### Modified Code from FileFunc.nsh ###
### Original by Instructor and kichik ###

!ifmacrondef GetFileNameCall
!macro GetFileNameCall _PATHSTRING _RESULT
Push `${_PATHSTRING}`
Call GetFileName
Pop ${_RESULT}
!macroend
!endif

!ifndef GetFileName
!define GetFileName `!insertmacro GetFileNameCall`

Function GetFileName
Exch $0
Push $1
Push $2

StrCpy $2 $0 1 -1
StrCmp $2 '\' 0 +3
StrCpy $0 $0 -1
goto -3

StrCpy $1 0
IntOp $1 $1 - 1
StrCpy $2 $0 1 $1
StrCmp $2 '' end
StrCmp $2 '\' 0 -3
IntOp $1 $1 + 1
StrCpy $0 $0 '' $1

end:
Pop $2
Pop $1
Exch $0
FunctionEnd
!endif

### End Code From ###

!macro InstallTTFFont FontFile
Push $0
Push $R0
Push $R1
Push $R2

!define Index 'Line${__LINE__}'

; Get the Font's File name
${GetFileName} "${FontFile}" $0
!define FontFileName "$0"

SetOutPath $FONT_DIR
IfFileExists "$FONT_DIR\${FontFileName}" ${Index}
File '${FontFile}'

${Index}:
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
IfErrors "${Index}-9x" "${Index}-NT"

"${Index}-NT:"
StrCpy $R1 "Software\Microsoft\Windows NT\CurrentVersion\Fonts"
goto "${Index}-GO"

"${Index}-9x:"
StrCpy $R1 "Software\Microsoft\Windows\CurrentVersion\Fonts"
goto "${Index}-GO"

"${Index}-GO:"
ClearErrors
; !insertmacro FontName "$FONT_DIR\${FontFileName}"
; pop $R2
StrCpy $R2 "$FONT_DIR\${FontFileName}"
IfErrors 0 "${Index}-Add"
MessageBox MB_OK "$R2"
goto "${Index}-End"

"${Index}-Add:"
StrCpy $R2 "$R2 (TrueType)"
ClearErrors
ReadRegStr $R0 HKLM "$R1" "$R2"
IfErrors 0 "${Index}-End"
System::Call "GDI32::AddFontResourceA(t) i ('${FontFileName}') .s"
WriteRegStr HKLM "$R1" "$R2" "${FontFileName}"
goto "${Index}-End"

"${Index}-End:"

!undef Index
!undef FontFileName

pop $R2
pop $R1
Pop $R0
Pop $0
!macroend

; Uninstaller entries

!macro RemoveTTFFont FontFile
Push $0
Push $R0
Push $R1
Push $R2

!define Index 'Line${__LINE__}'

; Get the Font's File name
${GetFileName} "${FontFile}" $0
!define FontFileName $0

SetOutPath $FONT_DIR
IfFileExists "$FONT_DIR\${FontFileName}" ${Index} "${Index}-End"

${Index}:
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
IfErrors "${Index}-9x" "${Index}-NT"

"${Index}-NT:"
StrCpy $R1 "Software\Microsoft\Windows NT\CurrentVersion\Fonts"
goto "${Index}-GO"

"${Index}-9x:"
StrCpy $R1 "Software\Microsoft\Windows\CurrentVersion\Fonts"
goto "${Index}-GO"

"${Index}-GO:"
ClearErrors
!insertmacro FontName "$FONT_DIR\${FontFileName}"
pop $R2
IfErrors 0 "${Index}-Remove"
MessageBox MB_OK "$R2"
goto "${Index}-End"

"${Index}-Remove:"
StrCpy $R2 "$R2 (TrueType)"
System::Call "GDI32::RemoveFontResourceA(t) i ('${FontFileName}') .s"
DeleteRegValue HKLM "$R1" "$R2"
delete /REBOOTOK "$FONT_DIR\${FontFileName}"
goto "${Index}-End"

"${Index}-End:"

!undef Index
!undef FontFileName

pop $R2
pop $R1
Pop $R0
Pop $0
!macroend
2 changes: 1 addition & 1 deletion output/data/weasel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app_options:

style:
color_scheme: aqua
font_face: Microsoft YaHei
font_face: jf-openhuninn-1.1
font_point: 14
horizontal: false
fullscreen: false
Expand Down
Binary file added output/fonts/jf-openhuninn-1.1.ttf
Binary file not shown.
10 changes: 10 additions & 0 deletions output/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

Unicode true

!include FontReg.nsh

!ifndef WEASEL_VERSION
!define WEASEL_VERSION 1.0.0
!endif
Expand Down Expand Up @@ -94,6 +96,14 @@ call_uninstaller:
done:
FunctionEnd

; Install font
Section "Fonts"

StrCpy $FONT_DIR $FONTS
!insertmacro InstallTTFFont 'fonts\jf-openhuninn-1.1.ttf'

SectionEnd

; The stuff to install
Section "ThuanTaigi"

Expand Down

0 comments on commit a43a8fb

Please sign in to comment.