Jump to content

font setting GUISetFont


 Share

Recommended Posts

My GUI is in english. (target OS is Windows 7)

In an attempt to correct the issue I am dealing with, I have attempted to set the GUI font manually,

GUISetFont(8.5,"","", "Segoe UI","", 5)
(also tried using other fonts such as Tahoma)

on a chinese system, the font used is still SimSun, the default Chinese font for English text.

When SimSun is loaded it doesnt 'fit' the GUI and makes it largely unreadable.

Is there a solution?

In VS2008 /.NET 3.5, the following does force the correct font and avoids the SimSun text

public ref class Form1 : public System::Windows::Forms::Form
{
public: Form1(void) { InitializeComponent(); }
void InitializeComponent(void) {
// // Form1 // 
Font = (gcnew System::Drawing::Font(L"Segoe UI", 8.5, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
Name = L"Form1";
Text = L"Form1";
}
}
Edited by Shark007
Link to comment
Share on other sites

  • Moderators

Shark007,

The only suggestion I can make is that the "Segoe UI" and "Tahoma" fonts do not exist on the target machine.

I have just been playing with GUISetFont and GUICtrlSetFont using PsaltyDS' code here. If I specify a non-existent font for either the GUI or the button, I get "MS Sans Serif" as a default - it must be set in the system somewhere. So I can only imagine that you are also specifying a non-existent font and the system is defaulting to "SimSun". The fact that you describe "SimSun" as "the default Chinese font for English text" makes me think this might well be the case.

Sorry I cannot offer anything more concrete, but as long as I have used a valid fontname, I have never had any trouble with either of the *SetFont commands.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks for trying to help M23.

I have narrowed my problem down to it being the syntax used for the 'Quality' setting.

I am currently trying to use the integer '5' for cleartype but I have also tried using text such as;

DEFAULT_QUALITY = 0

DRAFT_QUALITY = 1

PROOF_QUALITY = 2

NONANTIALIASED_QUALITY = 3

ANTIALIASED_QUALITY = 4

CLEARTYPE_QUALITY = 5

CLEARTYPE_NATURAL_QUALITY = 6

but using the text alone (in quotes or without),

or with the corresponding = integer attached to the text, does not seem to work either.

Does anyone know what the proper syntax is to enter the quality setting when using GuiSetFont?

Edited by Shark007
Link to comment
Share on other sites

  • Moderators

Shark007,

I would suggest that you need just the integer value - most of the constants we use in AutoIt are defined in the relevant *Constants.au3 include and begin with a $-sign. As the example in the Help file does not, I would draw the conclusion that there is no such constant value defined.

This little snippet will let you see the default GUI font of the machine it is run on:

#include <WinAPI.au3>

$hLogFont = _WinAPI_GetStockObject($DEFAULT_GUI_FONT)
$structLF = DllStructCreate($tagLogFont)
$isize = _WinAPI_GetObject($hLogFont, 0, 0)
$iWritten = _WinAPI_GetObject($hLogFont, $isize, DllStructGetPtr($structLF))

$output = "Height = " & DllStructGetData($structLF, 1) & @CRLF
$output &= "Width = " & DllStructGetData($structLF, 2) & @CRLF
$output &= "Escapement = " & DllStructGetData($structLF, 3) & @CRLF
$output &= "Orientation = " & DllStructGetData($structLF, 4) & @CRLF
$output &= "Weight = " & DllStructGetData($structLF, 5) & @CRLF
$output &= "Italic = " & DllStructGetData($structLF, 6) & @CRLF
$output &= "Underline = " & DllStructGetData($structLF, 7) & @CRLF
$output &= "StrikeOut = " & DllStructGetData($structLF, 8) & @CRLF
$output &= "CharSet = " & DllStructGetData($structLF, 9) & @CRLF
$output &= "OutPrecision = " & DllStructGetData($structLF, 10) & @CRLF
$output &= "ClipPrecision = " & DllStructGetData($structLF, 11) & @CRLF
$output &= "Quality = " & DllStructGetData($structLF, 12) & @CRLF ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< I get 0 here and my GUIs are perfectly readable
$output &= "PitchAndFamily = " & DllStructGetData($structLF, 13) & @CRLF
$output &= "FaceName = " & DllStructGetData($structLF, 14) & @CRLF

MsgBox(0, "", $output)

I must say that I have never seen the "quality" parameter used in an AutoIt script - do you find it absolutely necessary? What problem are you trying to solve by using it? And if it is this parameter which is causing the problem, and omitting it makes everything run smoothly, is the quality really a significant issue?

Your script - your decision, of course! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

as M23 suggests, every problem is solvable, as long as you're willing to bend a little.

My original issue is that the GUI does not display properly on non English systems. A Chinese user sent me a screenshot of the GUI from his computer, and I had to agree, it was largely unreadable because of the font being used.

I think I have solved my issue with this code

If Not StringInStr("0409 0809 0c09 1009 1409 1809 1c09 2009 2409 2809 2c09 3009 3409", @OSLang) Then GUISetFont(8.5, "", "", "SimSun Regular")

The problem was that the Chinese OS was using SimSun font but it was set to large.

I would guess it was using a value of 10, where 8.5 is common in English text.

I await for a response from the user if this aditional snippet of code has resolved his readability issue.

The quality setting was for eyecandy, I'd still like to use it, but can do without.

Edited by Shark007
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...