Archive: System Font


System Font
  Is there a risk in changing the font of the installer?

Normally the default font "MS Shell Dlg" on Windows XP resolves as Tahoma. For "subjective" reasons I believe Microsoft Sans Serif looks better.

What would happen if the local target system does not have Microsoft Sans Serif?


All systems should have Sans Serif. This is so because in CSS, sans-serif is on the list of 'certified fonts' that must exist on all systems as specified by W3C.

Anyway, I'm sure that if the font you specify does not exist, then the default Windows font will be used anyway.

-Stu


There are about three different Sans Serif fonts installed into the Windows Font folder.

Microsoft Sans Serif is not necessarily one of them.

I recently found this on the internet:

These are the only *.ttf fonts you will absolutely need...

arial.ttf
arialbd.ttf
arialbi.ttf
ariali.ttf
courbd.ttf
lucon.ttf
marlett.ttf
micross.ttf
tahoma.ttf
tahomabd.ttf
times.ttf
timesbd.ttf
verdana.ttf
verdanab.ttf
verdanai.ttf
verdanaz.ttf

Just now I've been experimenting with Vogue. I disable Vogue (in Adobe Type Manager) and the installer substitutes it with an illegible font.

This suggests you need to install and register fonts.

Is that true, and is there an easy script for it?

I'm too lazy to search the board, I guess.


I had to make sure I wasn't spreading any lies.

I have a backup image of Windows 95 and the Fonts folder does not include micross.ttf = Microsoft Sans Serif.

That's the truth.

And I found this piece of code on the message board:


nsh

System
::Call "GDI32::AddFontResourceA(t) i ('micross.ttf') .s"
>Pop $0
># $0 is zero if the function failed
>SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0
>
Would the system have time to register the font if a function were to call the code during the initialization in MUI_CUSTOMFUNCTION_GUIINIT?

http://www.kayskreations.net/fonts/fonttb.html

-Stu


Thank you, Stu,

I visited your link.

Windows XP has:

Microsoft Sans Serif
Modern MS Sans Serif

And Windows 95 only has:

MS Sans Serif

That might be a problem.

As to using code or a plug-in to register the font, others have more experience than I do. I consider this a good point to ask:

Can you register a font before an installation so it shows up during the installation?


There's this cool plugin you can use on here (fonts.dll):
http://nsis.sourceforge.net/archive/download.php

You could try calling this in your installer's .onInit function, and then it should appear on your installer.

-Stu


Thanks. The plug-in is worth a shot.

I tested my installer on Windows 95. A version of the installer where I changed the font to Microsoft Sans Serif replaced the missing font with a typeface that was too large. The size of the setup window increased from 503x386 to 668x469 pixels, and bold page headers did not become bigger.

I will spare you the screenshot.

I noticed something else in Windows 95. My code has a glitch, but I can't see what's wrong. I'm trying to hide a checkbox from non-NT Windows.


onInit

UserInfo
::GetAccountType
Pop$1
StrCpy $ACCOUNT"$1" #
StrCmp $ACCOUNT "Admin" showcheckbox 0
StrCmp $ACCOUNT"Power" showcheckbox next
showcheckbox:
StrCpy $ACCOUNT "access" #
next:
>EndFunction

>Function SetCustom
StrCmp $ACCOUNT"access" 0 hidecheckbox
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ready.ini"
Goto end
hidecheckbox:
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "ready.ini"
Pop $MUI_HWND
GetDlgItem$0 $MUI_HWND "1203"
ShowWindow $0 ${SW_HIDE}
!insertmacro MUI_INSTALLOPTIONS_SHOW
end:
>FunctionEnd
>
The checkbox is hidden in Windows 95 (and 98) without the UserInfo::GetAccountType condition, so there must be something wrong with the condition. The code fails.

Should I put this in a new topic under a new post, or is everyone okay with it?

continued from previous

RE: a compatibility issue when asking for the account type on computers which don't have user accounts, Windows 9x and ME.

The proposed work-around, to run an NT check before querying the account type, doesn't work either. I omitted that from the code excerpt. Here is the first function again with the part I left out:


onInit

ClearErrors
UserInfo
::GetName
IfErrors next; an error occurs under Windows 9x!
UserInfo::GetAccountType
Pop$1
StrCpy $ACCOUNT"$1" #
StrCmp $ACCOUNT "Admin" showcheckbox 0
StrCmp $ACCOUNT"Power" showcheckbox next
showcheckbox:
StrCpy $ACCOUNT "access" #
next:
>FunctionEnd
>

I think the reason that it's hidden on 9x is because of this:
ClearErrors
UserInfo::GetName
IfErrors next ; an error occurs under Windows 9x!
Am I correct to assume you generally want those without user accounts enabled (ie Win95) to have access... so you could change your code around a little if that is the case...

Function .onInit 
ClearErrors
UserInfo::GetName
IfErrors next ; an error occurs under Windows 9x!
UserInfo::GetAccountType
Pop $ACCOUNT
StrCmp $ACCOUNT "Admin" next
StrCmp $ACCOUNT "Power" next
StrCpy $ACCOUNT "noaccess" #
next:
FunctionEnd

Function SetCustom
StrCmp $ACCOUNT "noaccess" hidecheckbox
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ready.ini"
Goto end
hidecheckbox:
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "ready.ini"
Pop $MUI_HWND
GetDlgItem $0 $MUI_HWND "1203"
ShowWindow $0 ${SW_HIDE}
!insertmacro MUI_INSTALLOPTIONS_SHOW
end:
FunctionEnd


-Stu

I'd like to hide the checkbox. When a user ticks it, the shortcut folder will be put in the common startmenu folder for all users.

That part of the code should be skipped by Windows 95, 98 and Windows ME. $ACCOUNT should equal "" on those systems; "access" should be defined for Administrators and Power Users only.

Maybe this is a topic for a new post.

Better news on the original topic. If you change the installer font to "MS Sans Serif" instead of "Microsoft Sans Serif", it displays correctly in Windows 95, and Windows XP!


Have you used my code?

-Stu


Sorry, no.

I wasn't paying attention.

Your code is better than mine, isn't it?

I haven't tried it yet. I'll get on it.

Thanks.

ps: this should take about half an hour, if you want to hang around.


I'll be out of commission for a few days I have a feeling.

Either my motherboard short-circuited or the CPU. The whole computer is dead.

No condolence messages, please.

I might be up and running again sooner than you think.

Then again, maybe not.

ps: I'm sending this from a laptop in case you're wondering.

pps: Be careful when you switch those harddisks.


It's practically the same except I've allowed those without user accounts (ie with no User Name) access for your check-box.

-Stu


Stu, I'm back. In part.

UserInfo::GetName fails to return an error... despite your slight variation. Thanks for the input (above).

I think there is something perverse about the UserInfo plug-in. Wish I could put my finger on it.

- Tom


UserInfo::GetName fails to return an error
I have used the UserInfo plugin on Windows 9x systems and found that it does not return an error:

UserInfo::GetName returns the Windows login name
UserInfo::GetAccountType returns "Admin"

The source code for the plugin shows that GetAccountType will return "Admin" if used on Win9x systems. I think an earlier version of the UserInfo plugin did return an error but that was a long time ago (the current source code file is dated November 2003).

It's supposed to return an error (and skip to next). On Windows 9x there are no users. GetUserName is followed by the IfErrors line.

Concerning the source code, I agree with you. UserInfo::GetAccountType returns "Admin" on Win 9x systems. Again, why doesn't it just return "", which would be more accurate?


On Windows 9x there are no users.
This is not true - Win9x systems can have several users, each with their own Start Menu and desktop, etc.
Again, why doesn't it just return "", which would be more accurate?
I do not agree. On Win9x every user is an Administrator, i.e. they usually have full access to the system.
GetUserName is followed by the IfErrors line.
If you are referring to the UserInfo.nsi script, that script is dated six months before the source code for the plugin - it seems the example script was not updated when the plugin was changed to return "Admin" on Win9x systems.

I am referring to the example.nsi. I took for granted that an error would be returned.

I thought GetAccountType would detect the type of user account on NT-based OSes.

There should be a plug-in to find out whether the user is on a non-NT-based OS.


I prefer happy endings and practical solutions.

A solution to what?

Well, if you have been following this thread, you will be aware that the example script for the UserInfo plug-in is somewhat outdated and somewhat misleading. I was misled into believing you could adopt the script in order to hide a checkbox under Windows 9x and Windows ME. You can't, but here's what you can do:

1. Create a custom page (see ..\NSIS\Contrib\InstallOptions\Readme.html - "InstallOptions 2")
2. Create a checkbox field (edit the INI file)
3. Label the checkbox, for example: Make shortcuts available to all users
4. Insert the code below into your *.nsi script

; Variables
Var ACCOUNT

Function .onInit
ClearErrors
ReadRegStr $0 HKLM \
"SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
IfErrors next ; an error occurs under Windows 9x & Windows ME!
UserInfo::GetAccountType
Pop $ACCOUNT
StrCmp $ACCOUNT "Admin" end
StrCmp $ACCOUNT "Power" end
next:
StrCpy $ACCOUNT "noaccess" #
end:
FunctionEnd

; Ready to install page
Page custom SetCustom ValidateCustom "" ; Custom page. InstallOptions gets called in SetCustom.

Function SetCustom
StrCmp $ACCOUNT "noaccess" hidecheckbox
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ready.ini"
Goto end
hidecheckbox:
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "ready.ini"
Pop $MUI_HWND
GetDlgItem $0 $MUI_HWND "1203" ; 1200 + field number - 1
ShowWindow $0 ${SW_HIDE}
!insertmacro MUI_INSTALLOPTIONS_SHOW
end:
FunctionEnd
Disclaimer: I'm only a junior member. I make mistakes.

THE END