Skip to content

Commit

Permalink
Install fonts (Windows installer)
Browse files Browse the repository at this point in the history
  • Loading branch information
domcorbex committed May 28, 2018
1 parent 2b459d8 commit 0edcffb
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 37 deletions.
75 changes: 38 additions & 37 deletions cpack/windows/XiphosWindowsPkg.cmake
Expand Up @@ -19,13 +19,12 @@

# Generate installer for Windows©


# Disable the component-based installation mechanism.
set(CPACK_MONOLITHIC_INSTALL ON)

# The default installation directory presented to the end user by the
# NSIS installer.
# set(CPACK_NSIS_INSTALL_ROOT "")
# set(CPACK_NSIS_INSTALL_ROOT "${CMAKE_BINARY_DIR}")

# The name of a *.ico file used as the main icon for the generated
# install program
Expand All @@ -35,14 +34,10 @@ set (CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/win32/nsis/pixmaps/icon-install.
# uninstall program
set (CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/win32/nsis/pixmaps/icon-uninstall.ico")

# undocumented, but:
# CPACK_NSIS_INSTALLER_MUI_ICON_CODE is set empty in CPack code
# We could use it to add pixmaps to the installer
#set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE
# "!define XIPHOS_PATH_IMG \"win32\\nsis\\pixmaps\"
# !define MUI_HEADERIMAGE_BITMAP_RTL \"\${XIPHOS_PATH_IMG}\\header-r.bmp\"
# !define MUI_HEADERIMAGE_UNBITMAP_RTL \"\${XIPHOS_PATH_IMG}\\header-uninstall-r.bmp\"
#")
# CPACK_NSIS_INSTALLER_MUI_ICON_CODE is undocumented, but adds code for setting
# up MUI_ICON and MUI_UNICON, we use it for adding the font installer macro.
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/windows/nsis_installer_mui_icon_code.nsh
CPACK_NSIS_INSTALLER_MUI_ICON_CODE)

# The filename of a bitmap to use as the NSIS MUI_WELCOMEFINISHPAGE_BITMAP
set (CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP
Expand All @@ -55,36 +50,24 @@ set (CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP
# Extra NSIS commands that will be added to the beginning of the
# install Section
# set (CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "")
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/windows/nsis_extra_preinstall_commands.nsh
CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS)

# Extra NSIS commands that will be added to the end of the install Section
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
; REG keys to handle url sword:// by Xiphos
!define SWURL_REG_ROOT \"HKCR\" # HKEY_CLASSES_ROOT
!define SWURL_REG_KEY \"sword\"
!define SWURL_REG_KEY_ICON \"\${SWURL_REG_KEY}\\DefaultIcon\"
!define SWURL_REG_KEY_COMMAND \"\${SWURL_REG_KEY}\\shell\\open\\command\"
WriteRegStr \${SWURL_REG_ROOT} \${SWURL_REG_KEY} \"\" \"URL:sword Protocol\"
WriteRegStr \${SWURL_REG_ROOT} \${SWURL_REG_KEY} \"URL Protocol\" \"\"
WriteRegStr \${SWURL_REG_ROOT} \${SWURL_REG_KEY_ICON} \"\" \\
'\"\$INSTDIR\\bin\\\${APP_BINARY_NAME}\"'
WriteRegStr \${SWURL_REG_ROOT} \${SWURL_REG_KEY_COMMAND} \"\" \\
'\"\$INSTDIR\\bin\\\${APP_BINARY_NAME}\" \"%1\"'
")
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/windows/nsis_extra_install_commands.nsh
CPACK_NSIS_EXTRA_INSTALL_COMMANDS)

# Extra NSIS commands that will be added to the uninstall Section
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
; delete handler of url sword://
DeleteRegKey \${SWURL_REG_ROOT} \${SWURL_REG_KEY}
")
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/windows/nsis_extra_uninstall_commands.nsh
CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS)

# The arguments that will be passed to the NSIS SetCompressor command
#set (CPACK_NSIS_COMPRESSOR " /SOLID lzma")

# Modify PATH toggle. If this is set to “ON”, then an extra page will
# appear in the installer that will allow the user to choose whether
# the program directory should be added to the system PATH variable
# set (CPACK_NSIS_MODIFY_PATH "")
set (CPACK_NSIS_MODIFY_PATH "OFF")

# The display name string that appears in the Windows Add/Remove
# Program control pane
Expand All @@ -94,7 +77,7 @@ set (CPACK_NSIS_DISPLAY_NAME "Xiphos")
set (CPACK_NSIS_PACKAGE_NAME "Xiphos")

# A path to the executable that contains the installer icon
set (CPACK_NSIS_INSTALLED_ICON_NAME "bin/${PROJECT_NAME}.exe")
set (CPACK_NSIS_INSTALLED_ICON_NAME "bin\\${PROJECT_NAME}.exe")

# URL to a web site providing assistance in installing your application
set (CPACK_NSIS_HELP_LINK "${XIPHOS_WEBSITE}/Help")
Expand All @@ -106,6 +89,16 @@ set (CPACK_NSIS_URL_INFO_ABOUT "${XIPHOS_WEBSITE}")
# process
set (CPACK_NSIS_CONTACT "${XIPHOS_BUG_REPORT}")

# Additional NSIS commands for creating start menu shortcuts.
#set(CPACK_NSIS_CREATE_ICONS_EXTRA "")
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/windows/nsis_create_icons_extra.nsh
CPACK_NSIS_CREATE_ICONS_EXTRA)

# Additional NSIS commands to uninstall start menu shortcuts.
#set(CPACK_NSIS_DELETE_ICONS_EXTRA "")
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/windows/nsis_delete_icons_extra.nsh
CPACK_NSIS_DELETE_ICONS_EXTRA)

# Creating NSIS start menu links assumes that they are in ‘bin’ unless
# this variable is set. For example, you would set this to ‘exec’ if
# your executables are in an exec directory
Expand All @@ -115,27 +108,35 @@ set (CPACK_NSIS_CONTACT "${XIPHOS_BUG_REPORT}")
# of the NSIS installer
# set (CPACK_NSIS_MUI_FINISHPAGE_RUN "")

# Specify links in [application] menu. This should contain a list of pair “link”
# “link name”. The link may be an URL or a path relative to installation prefix.
set (CPACK_NSIS_MENU_LINKS
"bin\\utils.bat" "Sword")

# Lists each of the executables and associated text label to be used to
# create Start Menu shortcuts
set (CPACK_PACKAGE_EXECUTABLES "xiphos" "Xiphos")
set (CPACK_PACKAGE_EXECUTABLES
"xiphos" "Xiphos")

# Installation directory on the target system. Added to
# the default installation directory ${CPACK_NSIS_INSTALL_ROOT}
set (CPACK_PACKAGE_INSTALL_DIRECTORY "Crosswire\\${PROJECT_NAME}")

# If this is set to “ON”, then an extra page will appear in the installer
# that will allow the user to choose whether the program directory should be
# added to the system PATH variable.
set (CPACK_NSIS_MODIFY_PATH OFF)

# Ask about uninstalling previous versions first.
set (CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)

# License to be embedded in the installer. It will typically be displayed
# to the user by the produced installer (often with an explicit “Accept”
# button, for graphical installers) prior to installation.
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")

# ReadMe file to be embedded in the installer. It typically describes in some
# detail the purpose of the project during the installation.
set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/RELEASE-NOTES")

# Registry key used when installing this project. This is only used by installer
# for Windows. The default value is based on the installation directory.
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "HKLM")

# CPack generator to use. NSIS will produce graphical installers built
# on Windows using the Nullsoft Installation System.
Expand Down
14 changes: 14 additions & 0 deletions cpack/windows/nsis_create_icons_extra.nsh
@@ -0,0 +1,14 @@
#
#
######################################
#
# CPACK_NSIS_CREATE_ICONS_EXTRA
#
#######################################
#
#

#
#
######################################

14 changes: 14 additions & 0 deletions cpack/windows/nsis_delete_icons_extra.nsh
@@ -0,0 +1,14 @@
#
#
######################################
#
# CPACK_NSIS_DELETE_ICONS_EXTRA
#
#######################################
#
#

#
#
######################################

81 changes: 81 additions & 0 deletions cpack/windows/nsis_extra_install_commands.nsh
@@ -0,0 +1,81 @@
#
#
######################################
#
# CPACK_NSIS_EXTRA_INSTALL_COMMANDS
#
#######################################
#
#

; Install fonts

StrCpy $FONT_DIR $FONTS

; Libertine font
!insertmacro InstallTTFFont "${PATH_FONT}\LinLibertine_Re.ttf" \
"Linux Libertine (TrueType)"
!insertmacro InstallTTFFont "${PATH_FONT}\LinLibertine_Bd.ttf" \
"Linux Libertine Bold (TrueType)"
!insertmacro InstallTTFFont "${PATH_FONT}\LinLibertine_It.ttf" \
"Linux Libertine Italic (TrueType)"
!insertmacro InstallTTFFont "${PATH_FONT}\LinLibertine_BI.ttf" \
"Linux Libertine Bold Italic (TrueType)"

; GNU Unifont - contains all unicode characters
!insertmacro InstallTTFFont "${PATH_FONT}\unifont-5.1.20080907.ttf" \
"GNU Unifont (TrueType)"

; FreeSans font
!insertmacro InstallTTFFont "${PATH_FONT}\FreeSans.ttf" \
"Free Sans (TrueType)"
!insertmacro InstallTTFFont "${PATH_FONT}\FreeSansBold.ttf" \
"Free Sans Bold (TrueType)"
!insertmacro InstallTTFFont "${PATH_FONT}\FreeSansOblique.ttf" \
"Free Sans Oblique (TrueType)"
!insertmacro InstallTTFFont "${PATH_FONT}\FreeSansBoldOblique.ttf" \
"Free Sans Bold Oblique (TrueType)"

; FreeSerif font
!insertmacro InstallTTFFont "${PATH_FONT}\FreeSerif.ttf" \
"Free Serif (TrueType)"
!insertmacro InstallTTFFont "${PATH_FONT}\FreeSerifBold.ttf" \
"Free Serif Bold (TrueType)"
!insertmacro InstallTTFFont "${PATH_FONT}\FreeSerifItalic.ttf" \
"Free Serif Italic (TrueType)"
!insertmacro InstallTTFFont "${PATH_FONT}\FreeSerifBoldItalic.ttf" \
"Free Serif Bold Italic (TrueType)"

; Notify Windows applications about new fonts
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000


; Shared folder for Sword modules must exist
SetShellVarContext all
; Shared Sword Folder
SetOutPath '$APPDATA\${INSTPATH_SWORD}'
; set to default value
SetShellVarContext current


!define APP_BINARY_NAME "xiphos.exe"

; Xiphos as default handler of url sword://
;WriteRegStr HKCR "sword" "" "URL:sword Protocol"
;WriteRegStr HKCR "sword" "URL Protocol" ""
;WriteRegStr HKCR "sword\DefaultIcon" "" \
;'"$INSTDIR\bin\${APP_BINARY_NAME}"'
;WriteRegStr HKCR "sword\shell\open\command" "" \
;'"$INSTDIR\bin\${APP_BINARY_NAME}" "%1"'

WriteRegStr ${SWURL_REG_ROOT} ${SWURL_REG_KEY} "" "URL:sword Protocol"
WriteRegStr ${SWURL_REG_ROOT} ${SWURL_REG_KEY} "URL Protocol" ""
WriteRegStr ${SWURL_REG_ROOT} ${SWURL_REG_KEY_ICON} "" \
'"$INSTDIR\bin\${APP_BINARY_NAME}"'
WriteRegStr ${SWURL_REG_ROOT} ${SWURL_REG_KEY_COMMAND} "" \
'"$INSTDIR\bin\${APP_BINARY_NAME}" "%1"'

#
#
######################################

13 changes: 13 additions & 0 deletions cpack/windows/nsis_extra_preinstall_commands.nsh
@@ -0,0 +1,13 @@
#
#
######################################
#
# CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS
#
######################################
#
#

#
#
######################################
17 changes: 17 additions & 0 deletions cpack/windows/nsis_extra_uninstall_commands.nsh
@@ -0,0 +1,17 @@
#
#
######################################
#
# CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
#
#######################################
#
#

; delete handler of url sword://
DeleteRegKey ${SWURL_REG_ROOT} ${SWURL_REG_KEY}

#
#
######################################

38 changes: 38 additions & 0 deletions cpack/windows/nsis_installer_mui_icon_code.nsh
@@ -0,0 +1,38 @@
#
#
######################################
#
# CPACK_NSIS_INSTALLER_MUI_ICON_CODE
#
#######################################
#
#

; Re-create settings defined by the original code
!define MUI_ICON "..\..\..\..\win32\nsis\pixmaps/icon-install.ico"
!define MUI_UNICON "..\..\..\..\win32\nsis\pixmaps\icon-uninstall.ico"

; Our own settings:

; Add RTL header image
!define MUI_UI_HEADERIMAGE_RTL "..\..\..\..\win32\nsis\pixmaps\header-r.bmp"

;
!define INSTPATH_SWORD "Sword"

; REG keys to handle url sword:// by Xiphos
!define SWURL_REG_ROOT "HKCR" # HKEY_CLASSES_ROOT
!define SWURL_REG_KEY "sword"
!define SWURL_REG_KEY_ICON "${SWURL_REG_KEY}\DefaultIcon"
!define SWURL_REG_KEY_COMMAND "${SWURL_REG_KEY}\shell\open\command"


; Include Macro for registering fonts
!define INCL_DIR "..\..\..\..\win32\nsis\include"
!define PATH_FONT "..\..\..\..\win32\fonts"
!include "${INCL_DIR}\fontreg.nsh"

#
#
######################################

0 comments on commit 0edcffb

Please sign in to comment.