Archive: How set charset for font in Installation?


How set charset for font in Installation?
  How set charset for font in Installation?

I need set charset in Installation after selection of language in language dialog.

How can I do it?

Thank you


SetFont "fontname" size

Setting the font is not the same as settting the charset.

As far as I'm aware, NSIS can only use the system charset. So basically, only users with Shift-JIS as their system charset can see Japanese text, etc.

Of course, this is dependant on the end-user system, not the system the installer was compiled on.


I need set CHARSET of font! but not size


Who knows how I can do it?


It's always DEFAULT_CHARSET. If you want to change it, you can call CreateFont using the System plug-in and set the font for all the controls on your own.


Pleeese, give small example of using function CreateFont for setting CHARSET.

Thank you


kichik, please, give example of using function CreateFont from System plug-in.

Thank you


It's not that hard...


This full list of charset defines might come in handy. Values taken from the help file for Delphi 7 and verified with MSDN Library April 2003.


define ANSI_CHARSET 0

>!define DEFAULT_CHARSET 1
>!define SYMBOL_CHARSET 2
>!define MAC_CHARSET 77
>!define SHIFTJIS_CHARSET 128
>!define HANGEUL_CHARSET 129
>!define JOHAB_CHARSET 130
>!define GB2312_CHARSET 134
>!define CHINESEBIG5_CHARSET 136
>!define GREEK_CHARSET 161
>!define TURKISH_CHARSET 162
>!define VIETNAMESE_CHARSET 163
>!define HEBREW_CHARSET 177
>!define ARABIC_CHARSET 178
>!define BALTIC_CHARSET 186
>!define RUSSIAN_CHARSET 204
>!define THAI_CHARSET 222
>!define EASTEUROPE_CHARSET 238
>!define OEM_CHARSET 255
>

I have next code


Function SetCustomOwn
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "${PAGE_OWN}"

Pop $hwnd

GetDlgItem $DlgItem $hwnd ${ITEM_GROUPBOX_OWN}
System::Call "gdi32::CreateFont(i 0, i 0, i 0, i 0, i 0, i 0, i 0, i 0, \
i ${EASTEUROPE_CHARSET}, i ${OUT_DEFAULT_PRECIS}, \
i ${CLIP_DEFAULT_PRECIS}, i ${DEFAULT_QUALITY}, \
i ${DEFAULT_PITCH}, t 'Tahoma') i .r0"
SendMessage $DlgItem ${WM_SETFONT} $0 0
; SendMessage $DlgItem ${WM_SETFONT} $0 1

!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd


BUT it has no effect.
What's problem?

Thank you

Does $DlgItem contain a valid value? Did you include WinMessages.nsh? Did you try setting another font but the default Tahoma to see if it's just the charset that's not set? Would be easier to see why it has no effect with a full example.


$DlgItem contains valid value - I checked it by using

ShowWindow $DlgItem 0

WinMessages.nsh was included.
I've tried "Tahoma", "Arial", "Courier New" but result the same.
Function SetCustomA
!insertmacro MUI_INSTALLOPTIONS_WRITE "${PAGE_DATABASE}" \
"${FLD_IMG_EXISTING_DATABASE}" "Text" \
"$TEMP\${IMG_EXISTING_DATABASE}"

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE_DATABASE)"
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "${PAGE_DATABASE}"

Pop $hwnd ; hwnd of dialog

GetDlgItem $DlgItem $hwnd ${ITEM_GROUPBOX_DB}
SendMessage $DlgItem ${WM_SETTEXT} 0 "STR:$(CAPTION_GROUPBOX_DB)"

System::Call "gdi32::CreateFont(i 0, i 0, i 0, i 0, i 0, i 0, i 0, i 0, \
i 0, i ${OUT_DEFAULT_PRECIS}, \
i ${CLIP_DEFAULT_PRECIS}, i ${DEFAULT_QUALITY}, \
i ${DEFAULT_PITCH}, t 'Courier New') i .r0"
SendMessage $DlgItem ${WM_SETFONT} $0 0

GetDlgItem $DlgItem $hwnd ${ITEM_EXISTING_DATABASE}
SendMessage $DlgItem ${WM_SETTEXT} 0 "STR:$(CAPTION_EXISTING_DATABASE):"
GetDlgItem $DlgItem $hwnd ${ITEM_DATABASE_DESCRIPTION}
SendMessage $DlgItem ${WM_SETTEXT} 0 "STR:$(MSG_DATABASE_DESCRIPTION)"

SendMessage $DlgItem ${WM_SETFONT} $0 0

!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd

Seems fine. I'd try with 1 in lParam. Doesn't hurt updating it the control. If it still doesn't work, attach a complete example.


I've tried, but result the same.

Sorry, but I can't attach a complete example, because it's policy of our company.
I can attach screenshot, but I don't know how I can do it.
Please, say to me how.

Thank you


You're not being asked to post the entire script you're working on. You're only being asked to show a script that shows the problem. The script doesn't have to do anything else, but it needs to be compileable as-is. Alternatively, use the code you've already posted to create a new, otherwise unrelated script around that function that still shows the problem.

If your company has a policy against that, you wouldn't even have been allowed to post that function above.


You can see problem code above.


You seem to be misunderstanding me.

If we're to help properly, we'll need you to create a new, complete script that uses the function, but which doesn't work as intended. It is not enough to just see the function, as the reason it fails may be due to something you do before calling the function.

Because YOU are having the problem, YOU will have to make a complete working example script (obviously showing the problem) that we can compile and test without any modifications.


I very well understand you.
But problem only in one function CreateFont.


Originally posted by anonym
I very well understand you.
But problem only in one function CreateFont.
If you say the problem is only in that function, you don't understand Pidgeot. The problem might be in another part of the script. That function is far from being stand-alone.

I'm sorry.
Please, see problem code below


Name font
OutFile font.exe

XPStyle on

Var hwnd
Var DlgItem

Section
!include WinMessages.nsh

!define GREEK_CHARSET 161
!define EASTEUROPE_CHARSET 238

!define OUT_DEFAULT_PRECIS 0
!define CLIP_DEFAULT_PRECIS 0
!define DEFAULT_QUALITY 0
!define DEFAULT_PITCH 0

System::Call "gdi32::CreateFont(i 0, i 0, i 0, i 0, i 0, \
i 0, i 0, i 0, i ${EASTEUROPE_CHARSET}, i ${OUT_DEFAULT_PRECIS}, \
i ${CLIP_DEFAULT_PRECIS}, i ${DEFAULT_QUALITY}, \
i ${DEFAULT_PITCH}, t 'Tahoma') i .r0"

GetDlgItem $1 $HWNDPARENT 1
SendMessage $1 ${WM_SETFONT} $0 1

GetDlgItem $DlgItem $HWNDPARENT 1028
SendMessage $DlgItem ${WM_SETFONT} $0 1
SendMessage $DlgItem ${WM_SETTEXT} 0 "STR:***283;š***269;***345;žýáíéú***367;"
SectionEnd

Still works fine for me when changing EASTEUROPE_CHARSET to HEBREW_CHARSET and changing the text to Hebrew. Make sure the file is saved with the correct codepage. Try saving it using Notepad and select ANSI encoding in the save dialog.


It works on your computer because you have Hebrew Windows.
You try my code without changes.


I can't try your code without changes because my non-Unicode codepage is Hebrew and because the characters I copy from the web browser depend on its selected codepage which is probably not the same as yours.

If it doesn't work on your computer because you don't have eastern european codepage selected, then that's the problem. You can't display characters of a different codepage then your selected codepage without Unicode. NSIS is not Unicode enabled.


I know that NSIS is not Unicode, but Delphi 7 also is not Unicode, but it can displays in different codepages by using different charsets. Charsets uses special for it.


I don't know exactly what Delphi does, but if it's does not create a full blown Unicode application, it can still call the Unicode version of the API.

As far as I can tell, what you're trying to do is not possible. Even if you select the charset, the codepage must fit. For example, how will it decode MBCS without the correct codepage?

But, if you can show me a piece of C code that does this, I'll translate it to NSIS script for you.