lokster Posted January 15, 2007 Posted January 15, 2007 I am making a frontend for MEncoder. As a parameter for the subtitle font, mencoder accepts .ttf filename. On my GUI there is a combobox which listst all fonts in some directory. I want to make it when I select some item, the font of a label to change to the selected font. Here is just an example of what I want to do (this is not the real script, it is not finished yet...): expandcollapse popup#include <GUIConstants.au3> #Include <GuiCombo.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=D:\lokster\AutoIt Projects\fonts\AForm1.kxf $Form1 = GUICreate("AForm1", 148, 66, 197, 115) $Combo1 = GUICtrlCreateCombo("", 0, 0, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetOnEvent(-1, "ACombo1Change") $Label1 = GUICtrlCreateLabel("Font Sample", 0, 24, 147, 41, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUISetOnEvent($GUI_EVENT_CLOSE, "Bye") ListFonts(@WindowsDir &"\Fonts\") ;this directory is just for example... While 1 Sleep(100) WEnd Func Bye() Exit EndFunc Func ListFonts($dir) $search = FileFindFirstFile($dir & '*.ttf') if $search <> -1 then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop GUICtrlSetData($Combo1,$file&'|') WEnd EndIf FileClose($search) _GUICtrlComboSetCurSel ( $Combo1, 0) EndFunc Func ACombo1Change() ;here i want to change the font of $Label1 EndFunc
Ármányos Kő Posted January 15, 2007 Posted January 15, 2007 (edited) You may need to install the font to be able to use it. Having the fonts in "some directory" may not be enough. Edited January 15, 2007 by Ármányos Kő
BrettF Posted January 15, 2007 Posted January 15, 2007 You may need to install the font to be able to use it.Having the fonts in "some directory" may not be enough.I think you do.... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
BrettF Posted January 15, 2007 Posted January 15, 2007 To set the font use: GUICtrlSetFont (controlID, size [, weight [, attribute [, fontname]]] ) controlID: The control identifier (controlID) as returned by a GUICtrlCreate... function. size: Fontsize (default is 9). weight : [optional] Font weight (default 400 = normal). attribute: [optional] To define italic:2 underlined:4 strike:8 char format (add together the values of all the styles required, 2+4 = italic and underlined). fontname: [optional] The name of the font to use. Taken from: You guessed it! the help file Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
lokster Posted January 15, 2007 Author Posted January 15, 2007 To set the font use: GUICtrlSetFont (controlID, size [, weight [, attribute [, fontname]]] ) controlID: The control identifier (controlID) as returned by a GUICtrlCreate... function. size: Fontsize (default is 9). weight : [optional] Font weight (default 400 = normal). attribute: [optional] To define italic:2 underlined:4 strike:8 char format (add together the values of all the styles required, 2+4 = italic and underlined). fontname: [optional] The name of the font to use. Taken from: You guessed it! the help file Yes... I know that function, but the fontname parameter is the name of the font, not the filename. I figured out how to get around the problem - list only the installed fonts, and then get the selected font filename by reading it from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts. This is only a workaround for what I initially wanted, but it works, so... topic closed:)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now