Jump to content

Search the Community

Showing results for tags 'font'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 20 results

  1. This was born in a help topic but then I thought I'd be a good UDF to have. The difference between _ChooseFont() and this _ChooseFontEx() , is that it adds: The use of keyword "Default", as default value. Hide parts of the font choosing GUI Uses the proper default color if no color is declared (default) I tested this UDF to work with AutoIt from v3.2.12.1 and the current v3.3.16.1, so it should work in every version. This also copied the Dll calls from other UDFs to this one, to give it independence from otherwise needed additional includes. The Example: #include <_ChooseFontEx.au3> #include <Array.au3> ; for the example Example() Func Example() Local $hParent = GUICreate("Test GUI", 300, 300, @DesktopWidth / 3) For $i = 1 To 7 GUICtrlCreateLabel("label " & $i, 10, $i * 25) Next GUISetState() Sleep(1000) ; used "Arial" as it is found from WinXP to Win11 Local $aFont = _ChooseFont("Arial", 8, 0, 0, False, False, False, $hParent) _ArrayDisplay($aFont, "Example original") $aFont = _ChooseFontEx("Arial", 8, Default, Default, Default, Default, Default, $hParent) _ArrayDisplay($aFont, "Example # 1") $aFont = _ChooseFontEx("Arial", 8, Default, 600, Default, Default, Default, $hParent, 63, "Please choose a font:") _ArrayDisplay($aFont, "Example # 2") Sleep(1000) GUIDelete() EndFunc ;==>Example The UDF: ;~ Opt("MustDeclareVars", 1) ;~ #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include-once ; if you're gonna use it as UDF #include <Misc.au3> ; for _ChooseFont() ;~ Global $__ChooseFontEx_Hook_WH_CBT = 5, $__ChooseFontEx_Hook_hProc = 0, $__ChooseFontEx_Hook_hHook = 0, _ ; move to "Global" to make it 3.2.12.1 compatible ;~ $__ChooseFontEx_Hook_iHideThese = 3, $__ChooseFontEx_Hook_sNewWinTitle = "", $__ChooseFontEx_Hook_wParamKept = 0, _ ;~ $__ChooseFontEx_Default_iHideThese = 3, $__ChooseFontEx_Default_sNewWinTitle = "", $__ChooseFontEx_Default_hWndOwner = 0 ; #FUNCTION# ==================================================================================================================== ; Name...........: _ChooseFontEx ; Description ...: Creates a Font dialog box that enables the user to choose attributes for a logical font. ; Syntax.........: _ChooseFont([$sFontName = "Courier New"[, $iPointSize = 10[, $iColorRef = 0[, $iFontWeight = 0[, $iItalic = False[, $iUnderline = False[, $iStrikethru = False[, $hWndOwner = 0[, $iHideThese = 7[, $sNewWinTitle = ""]]]]]]]]]]) ; Parameters ....: $sFontName - Default font name ; $iPointSize - Pointsize of font ; $iColorRef - COLORREF rgbColors ; $iFontWeight - Font Weight ; $iItalic - Italic ; $iUnderline - Underline ; $iStrikethru - Optional: Strikethru ; $hWndOwnder - Handle to the window that owns the dialog box ; $iHideThese - Bitwise: Default is 3 ( SysLink and Script ) ; 1: hide SysLink ; 2: hide Script ; 4: hide Color ( if 4 and 8 , also the GroupBox "Effects" will be hidden ) ; 8: hide underline & strikeout ; 16: hide "Font style" ; 32: hide "Font size" ; $sNewWinTitle - Change the WinTitle ; Return values .: Success - Array in the following format: ; |[0] - contains the number of elements ; |[1] - attributes = BitOr of italic:2, undeline:4, strikeout:8 ; |[2] - fontname ; |[3] - font size = point size ; |[4] - font weight = = 0-1000 ; |[5] - COLORREF rgbColors ; |[6] - Hex BGR Color ; |[7] - Hex RGB Color ; Failure - -1 ; Author ........: argumentum ; https://www.autoitscript.com/forum/topic/209809-_choosefontex/ ; Modified.......: ; Remarks .......: Default keyword friendly. Dark Mode friendly. ; Related .......: _ChooseFont() ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _ChooseFontEx($sFontName = "Courier New", $iPointSize = 10, $iFontColorRef = Default, $iFontWeight = 0, _ $bItalic = False, $bUnderline = False, $bStrikethru = False, $hWndOwner = Default, $iHideThese = Default, $sNewWinTitle = Default) Local $aRet, $iErr, $iExt, $COLOR_BTNTEXT = 18 If $iPointSize = Default Then $iPointSize = 10 ; Default as a parameter is not in the Misc.au3 UDF. Added here for convenience. If $iFontColorRef = Default Then $iFontColorRef = 0 $aRet = DllCall("user32.dll", "INT", "GetSysColor", "int", $COLOR_BTNTEXT) ; I use a dark theme, so 0x000000 is not my default. If Not @error Then $iFontColorRef = $aRet[0] EndIf If $iFontWeight = Default Then $iFontWeight = 0 If $bItalic = Default Then $bItalic = False If $bUnderline = Default Then $bUnderline = False If $bStrikethru = Default Then $bStrikethru = False If $hWndOwner = Default Then $hWndOwner = _ChooseFontEx_hWndOwner() ; default = 0 ( no parent gui ) If Not IsHWnd($hWndOwner) Then $hWndOwner = 0 If $iHideThese = Default Then $iHideThese = _ChooseFontEx_HideThese() ; default = 3 ( hide SysLink + hide Script ) If $sNewWinTitle = Default Then $sNewWinTitle = _ChooseFontEx_NewWinTitle() ; default = "" ( no change ) __ChooseFontEx_Hook("StartIt", $iHideThese, $sNewWinTitle) ; logic moved to this func to keep hook variables as local $aRet = _ChooseFont($sFontName, $iPointSize, $iFontColorRef, $iFontWeight, $bItalic, $bUnderline, $bStrikethru, $hWndOwner) $iErr = @error $iExt = @extended __ChooseFontEx_Hook("EndIt", "", "") Return SetError($iErr, $iExt, $aRet) EndFunc ;==>_ChooseFontEx #Region helper func to set new defaults ; #FUNCTION# ==================================================================================================================== ; Name...........: _ChooseFontEx_HideThese() ; Description ...: Set a default value / get value / set "ResetDefault" to Reset default value ( saves you from having to know it ) ; =============================================================================================================================== Func _ChooseFontEx_HideThese($iHideThese = Default) ; set a new default / get value Local $iRet = __ChooseFontEx_Hook("HideThese", $iHideThese, "") Return SetError(@error, @extended, $iRet) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _ChooseFontEx_NewWinTitle() ; Description ...: Set a default WinTitle / get value / set "ResetDefault" to Reset default value ( saves you from having to know it ) ; =============================================================================================================================== Func _ChooseFontEx_NewWinTitle($sNewWinTitle = Default) ; Local $sRet = __ChooseFontEx_Hook("NewWinTitle", $sNewWinTitle, "") Return SetError(@error, @extended, $sRet) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _ChooseFontEx_hWndOwner() ; Description ...: Set a default parent GUI / get value / set "ResetDefault" to Reset default value ( saves you from having to know it ) ; =============================================================================================================================== Func _ChooseFontEx_hWndOwner($hWndOwner = Default) Local $hRet = __ChooseFontEx_Hook("hWndOwner", $hWndOwner, "") Return SetError(@error, @extended, $hRet) EndFunc #EndRegion ; #FUNCTION# ==================================================================================================================== ; Name...........: __ChooseFontEx_Hook ; Description ...: Helper function for _ChooseFontEx() ; Remarks .......: For Internal Use Only ; =============================================================================================================================== Func __ChooseFontEx_Hook($nCode, $wParam, $lParam) ; Tested in XP, 10 and 11 Local Static $__ChooseFontEx_Hook_WH_CBT = 5, $__ChooseFontEx_Hook_hProc = 0, $__ChooseFontEx_Hook_hHook = 0, _ ; move to "Global" to make it 3.2.12.1 compatible $__ChooseFontEx_Hook_iHideThese = 3, $__ChooseFontEx_Hook_sNewWinTitle = "", $__ChooseFontEx_Hook_wParamKept = 0, _ $__ChooseFontEx_Default_iHideThese = 3, $__ChooseFontEx_Default_sNewWinTitle = "", $__ChooseFontEx_Default_hWndOwner = 0 Local $aRet Switch $nCode Case "HideThese" If $wParam = "ResetDefault" Then $__ChooseFontEx_Default_iHideThese = 3 If $wParam <> Default Then $__ChooseFontEx_Default_iHideThese = $wParam Return $__ChooseFontEx_Default_iHideThese Case "NewWinTitle" If $wParam = "ResetDefault" Then $__ChooseFontEx_Default_sNewWinTitle = "" If $wParam <> Default Then $__ChooseFontEx_Default_sNewWinTitle = $wParam Return $__ChooseFontEx_Default_sNewWinTitle Case "hWndOwner" If $wParam = "ResetDefault" Then $__ChooseFontEx_Default_hWndOwner = 0 If $wParam <> Default And IsHWnd($wParam) Then $__ChooseFontEx_Default_hWndOwner = $wParam Return SetError(0, IsHWnd($__ChooseFontEx_Default_hWndOwner), $__ChooseFontEx_Default_hWndOwner) Case "StartIt" $__ChooseFontEx_Hook_sNewWinTitle = $lParam If $wParam < 0 Or $wParam > 63 Or $wParam = Default Then $__ChooseFontEx_Hook_iHideThese = 3 Else $__ChooseFontEx_Hook_iHideThese = Int($wParam) EndIf $__ChooseFontEx_Hook_hProc = DllCallbackRegister("__ChooseFontEx_Hook", "int", "int;int;int") Local $hThreadId = DllCall("kernel32.dll", "dword", "GetCurrentThreadId") If Not @error Then $aRet = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $__ChooseFontEx_Hook_WH_CBT, _ "ptr", DllCallbackGetPtr($__ChooseFontEx_Hook_hProc), "handle", 0, "dword", $hThreadId[0]) If Not @error Then $__ChooseFontEx_Hook_hHook = $aRet[0] EndIf Return Case "EndIt" DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $__ChooseFontEx_Hook_hHook) ;If @error Then ConsoleWrite('! @error ' & @ScriptLineNumber & @CRLF) DllCallbackFree($__ChooseFontEx_Hook_hProc) $__ChooseFontEx_Hook_hHook = 0 $__ChooseFontEx_Hook_hProc = 0 Return EndSwitch ; $nCode = 3 ( 1st control created in the canvas is the window, hance "wParamKept = $wParam" ) If $nCode = 3 And $__ChooseFontEx_Hook_wParamKept = 0 Then $__ChooseFontEx_Hook_wParamKept = $wParam If $nCode = 9 And $__ChooseFontEx_Hook_wParamKept = 1 Then $__ChooseFontEx_Hook_wParamKept = 0 If $nCode = 5 And $__ChooseFontEx_Hook_wParamKept = $wParam Then $__ChooseFontEx_Hook_wParamKept = 1 Local $hWnd = HWnd($wParam) If BitAND($__ChooseFontEx_Hook_iHideThese, 1) Then ControlHide($hWnd, "", "SysLink1") ; <A>Show more fonts</A> If BitAND($__ChooseFontEx_Hook_iHideThese, 2) Then ControlHide($hWnd, "", "Static7") ; Script: ControlHide($hWnd, "", "ComboBox5") ; Script comboBox EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 4) Then ControlHide($hWnd, "", "Static4") ; Color: ControlHide($hWnd, "", "ComboBox4") ; Color comboBox EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 8) Then ControlHide($hWnd, "", "Button2") ; Strikeout: ControlHide($hWnd, "", "Button3") ; Underline: EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 16) Then ; Font style: ControlHide($hWnd, "", "Static2") ControlHide($hWnd, "", "ComboBox2") EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 32) Then ; Size: ControlHide($hWnd, "", "Static3") ControlHide($hWnd, "", "ComboBox3") EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 4) And BitAND($__ChooseFontEx_Hook_iHideThese, 8) Then ControlHide($hWnd, "", "Button1") ; Effects: If $__ChooseFontEx_Hook_sNewWinTitle <> "" Then WinSetTitle($hWnd, "", $__ChooseFontEx_Hook_sNewWinTitle) EndIf $aRet = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $__ChooseFontEx_Hook_hHook, "int", $nCode, "wparam", $wParam, "lparam", $lParam) If Not @error Then Return $aRet[0] Return 0 EndFunc ;==>__ChooseFontEx_Hook #cs #include <Array.au3> ; for the example Example() Func Example() Local $hParent = GUICreate("Test GUI", 300, 300, @DesktopWidth / 3) For $i = 1 To 7 GUICtrlCreateLabel("label " & $i, 10, $i * 25) Next GUISetState() Sleep(1000) ; used "Arial" as it is found from WinXP to Win11 Local $aFont = _ChooseFont("Arial", 8, Default, 0, False, False, False, $hParent) _ArrayDisplay($aFont, "Example original") _ChooseFontEx_NewWinTitle("My default title") $aFont = _ChooseFontEx("Arial", 8, Default, Default, Default, Default, Default, $hParent) _ArrayDisplay($aFont, "Example # 1") $aFont = _ChooseFontEx("Arial", 8, Default, 600, Default, Default, Default, $hParent, 63, "Please choose a font:") _ArrayDisplay($aFont, "Example # 2") Sleep(1000) EndFunc ;==>Example #ce Talking to myself: I don't know if start annoying the MVPs into modifying the default ChooseFont() to include these features in it is well worth it. It should be but I don't wanna push the code uphill ...hmmm. They may just do it if they see this expansion as favorable. At least the default color should be implemented. idk. If you're using this thing, please do leave a like, as to get an idea if is really useful or just not that useful. Thank you.
  2. Hi, I've a script, using WinAPIGdi, checking info on font files for some files, I get the error "C:\DEV\AutoIt3\Include\WinAPIGdi.au3" (2480) : ==> Variable must be of type "Object".: and then the script stops. Is there a way I can either "catch" that error, and let my script continue with the next file or improve something in the WinAPIGdi script? I've searched the forums on error handling, but couldn't immediately find something related tho errors like these which are hardstopping the script P.S. : I'm an AutoIT script newbie..... snippet from WinAPIGdi, line 2480 from the error is this one: $sResult = $tResult.szTTFName ; #FUNCTION# ==================================================================================================================== ; Author ........: funkey ; Modified ......: UEZ, jpm ; =============================================================================================================================== Func _WinAPI_GetFontMemoryResourceInfo($pMemory, $iFlag = 1) Local Const $tagTT_OFFSET_TABLE = "USHORT uMajorVersion;USHORT uMinorVersion;USHORT uNumOfTables;USHORT uSearchRange;USHORT uEntrySelector;USHORT uRangeShift" Local Const $tagTT_TABLE_DIRECTORY = "char szTag[4];ULONG uCheckSum;ULONG uOffset;ULONG uLength" Local Const $tagTT_NAME_TABLE_HEADER = "USHORT uFSelector;USHORT uNRCount;USHORT uStorageOffset" Local Const $tagTT_NAME_RECORD = "USHORT uPlatformID;USHORT uEncodingID;USHORT uLanguageID;USHORT uNameID;USHORT uStringLength;USHORT uStringOffset" Local $tTTOffsetTable = DllStructCreate($tagTT_OFFSET_TABLE, $pMemory) Local $iNumOfTables = _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uNumOfTables")) ;check is this is a true type font and the version is 1.0 If Not (_WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMajorVersion")) = 1 And _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMinorVersion")) = 0) Then Return SetError(1, 0, "") Local $iTblDirSize = DllStructGetSize(DllStructCreate($tagTT_TABLE_DIRECTORY)) Local $bFound = False, $iOffset, $tTblDir For $i = 0 To $iNumOfTables - 1 $tTblDir = DllStructCreate($tagTT_TABLE_DIRECTORY, $pMemory + DllStructGetSize($tTTOffsetTable) + $i * $iTblDirSize) If StringLeft(DllStructGetData($tTblDir, "szTag"), 4) = "name" Then $bFound = True $iOffset = _WinAPI_SwapDWord(DllStructGetData($tTblDir, "uOffset")) ExitLoop EndIf Next If Not $bFound Then Return SetError(2, 0, "") Local $tNTHeader = DllStructCreate($tagTT_NAME_TABLE_HEADER, $pMemory + $iOffset) Local $iNTHeaderSize = DllStructGetSize($tNTHeader) Local $iNRCount = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uNRCount")) Local $iStorageOffset = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uStorageOffset")) Local $iTTRecordSize = DllStructGetSize(DllStructCreate($tagTT_NAME_RECORD)) Local $tResult, $sResult, $iStringLength, $iStringOffset, $iEncodingID, $tTTRecord For $i = 0 To $iNRCount - 1 $tTTRecord = DllStructCreate($tagTT_NAME_RECORD, $pMemory + $iOffset + $iNTHeaderSize + $i * $iTTRecordSize) If _WinAPI_SwapWord($tTTRecord.uNameID) = $iFlag Then ;1 says that this is font name. 0 for example determines copyright info $iStringLength = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringLength")) $iStringOffset = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringOffset")) $iEncodingID = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uEncodingID")) Local $sWchar = "char" If $iEncodingID = 1 Then $sWchar = "word" $iStringLength = $iStringLength / 2 EndIf $tResult = DllStructCreate($sWchar & " szTTFName[" & $iStringLength & "]", $pMemory + $iOffset + $iStringOffset + $iStorageOffset) If $iEncodingID = 1 Then $sResult = "" For $j = 1 To $iStringLength $sResult &= ChrW(_WinAPI_SwapWord(DllStructGetData($tResult, 1, $j))) Next Else $sResult = $tResult.szTTFName EndIf If StringLen($sResult) > 0 Then ExitLoop EndIf Next Return $sResult EndFunc ;==>_WinAPI_GetFontMemoryResourceInfo the function in my script: Func FontGetInfoFromFile($sFile, $n, $sElement) Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n) If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF) If @error Then ConsoleWrite ("ERROR!!!") EndFunc ;==>FontGetInfoFromFile and _WinAPI_GetFontResourceInfo uses _WinAPI_GetFontMemoryResourceInfo as you know any help or hints are welcome Babylon5.ttf Bahamas.ttf
  3. Hi, What should work @ converting the symbol's Unicode point included in windows 10: https://docs.microsoft.com/en-us/windows/uwp/design/style/segoe-ui-symbol-font Some Random Bad example : really Need to jump out sorry .. $hBtn = GUICtrlCreateButton(ChrW(BinaryToString("0xE70E", $SB_UTF16LE) ), 260, 37, 39, 21) GUICtrlSetFont(-1, 13, 600, -1, "SegMDL2") Thanks
  4. I'm trying to create a simple clock widget that automatically scales the text to the size of the window. I came up with the following method, but it doesn't work as well as I'd like. It especially has trouble scaling to the width of the window for some reason (in the example, try resizing the window to be narrow and tall). Does anyone have a better method? #include <Misc.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) Global $_FONT_FAMILY = 'Arial', $_LB_TEXT Main() Func Main() _GDIPlus_Startup() Local $hGUI GUIRegisterMsg($WM_SIZE, WM_SIZE) $hGUI = GUICreate('', 300, 100, Default, Default, $WS_OVERLAPPEDWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $_LB_TEXT = GUICtrlCreateLabel('This is a string', 0, 0, 300, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont($_LB_TEXT, _MeasureString($hGUI, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) GUISetState() Local $iGM While 1 $iGM = GUIGetMsg() Switch $iGM Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GDIPlus_Shutdown() EndFunc Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) GUICtrlSetFont($_LB_TEXT, _MeasureString($hWnd, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) EndFunc Func _MeasureString($hWnd, $sString, $sFont = 'Arial') Local $iError, $aSize, $hGraphic, $hFormat, $hFamily, $tLayout, $iFontSize, $hFont, $aInfo If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf $aSize = WinGetClientSize($hWnd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate($sFont) $tLayout = _GDIPlus_RectFCreate(0, 0, $aSize[0], $aSize[1]) $iFontSize = 0 Do If Not $hFamily Then $iError = 1 $iFontSize = 10 ExitLoop EndIf $iFontSize += 1 $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_FontDispose($hFont) If $aInfo[1] = 0 Then ExitLoop Until DllStructGetData($aInfo[0], 3) >= $aSize[0] Or DllStructGetData($aInfo[0], 4) >= $aSize[1] $iFontSize -= 1 _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) Return SetError($iError, 0, $iFontSize) EndFunc
  5. I am trying to print using a small font, but no mater how I try it, the printed font remains unchanged. I have created a sample script that sets the font to 8. Here are the functions I use to create, then set the font: Func _Printer_SetFont($hDC) Local $hFont If ($a__Printer_Font == 0) Then _Printer_MakeFont() EndIf $hFont = $a__Printer_Font _LogMsg("+++: $hDC & " & $hDC & ", $hFont = " & $hFont) _WinAPI_SetFont($hDC, $hFont) ; <===================== EndFunc ;==>_Printer_SetFont Func _Printer_MakeFont() Local $hFontDC, $err, $errm, $str, $flag, $iHeight $flag = $FW_BOLD $iHeight = 8 $hFontDC = _WinAPI_CreateFont( _ $iHeight, _ 0, _ ; average character width 0, _ ; angle of escape 0, _ ; base-line orientation $flag, _ ; font weight - $FW_NORMAL, $FW_BOLD, etc. False, _ ; italic False, _ ; underline False, _ ; strikeout $DEFAULT_CHARSET, _ ; the character set $OUT_DEFAULT_PRECIS, _ ; the output precision $CLIP_DEFAULT_PRECIS, _ ; the clipping precision $DEFAULT_QUALITY, _ ; the output quality 0, _ ; the pitch and family of the font "courier new") ; typeface name _LogMsg("+++: $hFontDC = 0x" & Hex($hFontDC)) If ($hFontDC <= 0) Then $str = "_WinAPI_CreateFont() failed." & @CRLF $err = _WinAPI_GetLastError() $errm = _WinAPI_GetLastErrorMessage() _LogMsg("+++: " & $err & ", 0) - '" & $errm & "'" & @CRLF & $str) Exit (9) EndIf $a__Printer_Font = $hFontDC EndFunc ;==>_Printer_MakeFont Here is the complete script: #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 Opt('MustDeclareVars', 1) #include <APIDlgConstants.au3> #include <FontConstants.au3> #include <WinAPI.au3> ; #VARIABLES# ================================================================ Global $i__LastLineNum = -1, $i__NextLineNum = -1, $i__ThisLineNum = -1 Global $i__LeftMargin_X, $i__TopMargin_Y, $i__PageWidth, $i__PageHeight Global $i__CurrentPos_X, $i__CurrentPos_Y Global $i__Printer_Char_H = -1, $i__Printer_Char_W = -1 Global $a__Printer_Font = 0 Global $i__x_start, $i__x_end, $i__y_start, $i__y_end ; ============================================================================ ; #CONSTANTS# ================================================================ Global $PHYSICALWIDTH = 110, $PHYSICALHEIGHT = 111 Global $PHYSICALOFFSETX = 112, $PHYSICALOFFSETY = 113 Const $VLINESPACE = 20 ; Number of pixels between lines Global Const $tagPD = "align 1;DWORD lStructSize;" & "HWND hwndOwner;" & "handle hDevMode;" & "handle hDevNames;" & _ "handle hDC;" & "DWORD Flags;" & _ "WORD nFromPage;" & "WORD nToPage;" & "WORD nMinPage;" & "WORD nMaxPage;" & "WORD nCopies;" & _ "handle hInstance;" & "LPARAM lCustData;" & "ptr lpfnPrintHook;" & "ptr lpfnSetupHook;" & _ "ptr lpPrintTemplateName;" & "ptr lpSetupTemplateName;" & "handle hPrintTemplate;" & "handle hSetupTemplate" Global Const $tagDOCINFO = "int Size;" & "ptr DocName;" & "ptr Output;" & "ptr Datatype;" & "dword Type" ; ============================================================================ _Main() Func _Main() Local $hDC, $str, $str2 = "", $linenum $hDC = _Printer_Open(0, Default, "DOCNAME: ++++") _LogMsg("+++: $hPrintDc = 0x" & Hex($hDC)) If (Not $hDC) Then Exit (1) _Printer_SetFont($hDC) For $y = 1 To 10 $str2 &= "123456789." Next $linenum = 30 ; Start in the middle of the page For $x = 1 To 15 $str = "[" & $x & " " & $str2 _LogMsg("+++: $str ==>" & $str & "<==") _Printer_PrintTextLine($hDC, $str, $linenum) $linenum += 1 Next _Printer_Close($hDC) EndFunc ;==>_Main Func _Printer_SetFont($hDC) Local $hFont If ($a__Printer_Font == 0) Then _Printer_MakeFont() EndIf $hFont = $a__Printer_Font _LogMsg("+++: $hDC & " & $hDC & ", $hFont = " & $hFont) _WinAPI_SetFont($hDC, $hFont) ; <===================== EndFunc ;==>_Printer_SetFont Func _Printer_MakeFont() Local $hFontDC, $err, $errm, $str, $flag, $iHeight $flag = $FW_BOLD $iHeight = 8 $hFontDC = _WinAPI_CreateFont( _ $iHeight, _ 0, _ ; average character width 0, _ ; angle of escape 0, _ ; base-line orientation $flag, _ ; font weight - $FW_NORMAL, $FW_BOLD, etc. False, _ ; italic False, _ ; underline False, _ ; strikeout $DEFAULT_CHARSET, _ ; the character set $OUT_DEFAULT_PRECIS, _ ; the output precision $CLIP_DEFAULT_PRECIS, _ ; the clipping precision $DEFAULT_QUALITY, _ ; the output quality 0, _ ; the pitch and family of the font "courier new") ; typeface name _LogMsg("+++: $hFontDC = 0x" & Hex($hFontDC)) If ($hFontDC <= 0) Then $str = "_WinAPI_CreateFont() failed." & @CRLF $err = _WinAPI_GetLastError() $errm = _WinAPI_GetLastErrorMessage() _LogMsg("+++: " & $err & ", 0) - '" & $errm & "'" & @CRLF & $str) Exit (9) EndIf $a__Printer_Font = $hFontDC EndFunc ;==>_Printer_MakeFont Func _Printer_Open($hGUI = 0, $iFlags = Default, $sDocName = "") Local $hDC, $tPD, $err If $iFlags = Default Then $iFlags = 0 $iFlags = BitOR($iFlags, $PD_RETURNDC) $iFlags = BitOR($iFlags, $PD_USEDEVMODECOPIESANDCOLLATE) EndIf $tPD = DllStructCreate($tagPD) DllStructSetData($tPD, "lStructSize", DllStructGetSize($tPD)) DllStructSetData($tPD, "hwndOwner", $hGUI) ; If $hGUI <> 0 Then DllStructGetData($tPD, "hInstance", _WinAPI_GetModuleHandle("")) EndIf DllStructSetData($tPD, "Flags", $iFlags) DllStructSetData($tPD, "nCopies", 2) Local $bRet = DllCall("Comdlg32.dll", "int", "PrintDlgW", "ptr", DllStructGetPtr($tPD)) $err = @error If $err Then $err = _WinAPI_GetLastError() Local $errm = _WinAPI_GetLastErrorMessage() _LogMsg("+++: _Printer_Open() returns: (1, " & $err & ", 0) - '" & $errm & "'") $tPD = 0 Return SetError(1, $err, 0) EndIf If $bRet[0] = True Then $hDC = DllStructGetData($tPD, "hDC") Else Return SetError(2, $err, 0) EndIf $tPD = 0 __Printer_SetupCharWH($hDC) _Printer_GetMetrics($hDC) _Printer_Startup($hDC, $sDocName) Return (SetError(0, 0, $hDC)) EndFunc ;==>_Printer_Open Func _Printer_Startup($hDC, $sDocName) Local $oDocNameStruct, $DOCINFO, $printJobID, $errstr __Printer_SetupCharWH($hDC) ; Get the height and width of a printer character $oDocNameStruct = DllStructCreate("char DocName[" & StringLen($sDocName & Chr(0)) & "]") DllStructSetData($oDocNameStruct, "DocName", $sDocName & Chr(0)) ; Size of DOCINFO structure $DOCINFO = DllStructCreate($tagDOCINFO) ; Structure for Print Document info DllStructSetData($DOCINFO, "Size", 20) ; Size of DOCINFO structure DllStructSetData($DOCINFO, "DocName", DllStructGetPtr($oDocNameStruct)) ; Set name of print job (Optional) _Printer_GetMetrics($hDC) $printJobID = _Printer_StartDoc($hDC, $DOCINFO) ; start new print doc If ($printJobID <= 0) Then $errstr = "_Printer_StartDoc() failed" _LogMsg("+++: _Printer_Startup() returns: @error = 1 - " & $errstr) Return (SetError(1, 0, $errstr)) EndIf Return (SetError(0, 0, $printJobID)) ; print job ID EndFunc ;==>_Printer_Startup Func _Printer_Close($hDC) _Printer_EndPage($hDC) ; End the currend page _Printer_EndDoc($hDC) ; End the print job _WinAPI_DeleteDC($hDC) ; Delete the printer device context EndFunc ;==>_Printer_Close Func _Printer_EndPage($hDC) Local $aResult If ($i__ThisLineNum > 1) Then $aResult = DllCall("GDI32.dll", "long", "EndPage", "hwnd", $hDC) EndIf _Printer_SetInitial_XY() $i__ThisLineNum = -1 Return ($aResult[0]) EndFunc ;==>_Printer_EndPage Func _Printer_EndDoc($hDC) Local $aResult $aResult = DllCall("GDI32.dll", "long", "EndDoc", "hwnd", $hDC) Return ($aResult[0]) EndFunc ;==>_Printer_EndDoc Func _Printer_TextOut($hDC, $iXStart, $iYStart, $sString) Local $aResult $aResult = DllCall("GDI32.dll", _ "long", "TextOut", _ "hwnd", $hDC, _ "long", $iXStart, _ "long", $iYStart, _ "str", $sString, _ "long", StringLen($sString)) Return $aResult[0] ; 0 = fail, 1 = OK EndFunc ;==>_Printer_TextOut Func _Printer_PrintTextLine($hDC, $sText, $iLineNumber = -1) Local $ret, $lines, $ndx If ($iLineNumber <= 0) Then $iLineNumber = $i__ThisLineNum EndIf $sText = StringStripWS($sText, 2) ; Clear trailing whitespace ; Break text into an array of lines, based on any of the ; usual line endings (@CR, @LF, etc.) found in the string. $sText = StringRegExpReplace($sText, "[\\][n]", @CR) $sText = StringReplace($sText, @CRLF, @LF) $sText = StringReplace($sText, @CR, @LF) While (StringRight($sText, 1) == @LF) StringTrimRight($sText, 1) ; remove trailing LF's WEnd $lines = StringSplit($sText, @LF, 2) ; Now print each line in the array of lines, advancing the ; printer line position each time For $ndx = 0 To UBound($lines) - 1 $i__CurrentPos_X = $i__x_start ; $i__LeftMargin_X $i__CurrentPos_Y = (($i__Printer_Char_H + $VLINESPACE) * $iLineNumber) + $i__y_start $ret = _Printer_TextOut($hDC, $i__CurrentPos_X, $i__CurrentPos_Y, $lines[$ndx]) $iLineNumber += 1 $i__ThisLineNum += 1 If ($ret == 0) Then ExitLoop If ($iLineNumber > $i__LastLineNum) Then _Printer_EndPage($hDC) $iLineNumber = 1 $i__ThisLineNum = 1 EndIf Next ; Calculate next x/y position $i__CurrentPos_Y = (($i__Printer_Char_H + $VLINESPACE) * $iLineNumber) Return (SetError(0, 0, $iLineNumber)) EndFunc ;==>_Printer_PrintTextLine Func _Printer_StartDoc($hDC, $tDocInfo) Local $aResult $aResult = DllCall("GDI32.dll", "long", "StartDoc", "hwnd", $hDC, "ptr", DllStructGetPtr($tDocInfo)) _Printer_SetInitial_XY() Return ($aResult[0]) ; >0 = OK, <=0 = Fail EndFunc ;==>_Printer_StartDoc Func _Printer_GetMetrics($hDC) $i__LeftMargin_X = _WinAPI_GetDeviceCaps($hDC, $PHYSICALOFFSETX) $i__TopMargin_Y = _WinAPI_GetDeviceCaps($hDC, $PHYSICALOFFSETY) $i__PageWidth = _WinAPI_GetDeviceCaps($hDC, $PHYSICALWIDTH) $i__PageHeight = _WinAPI_GetDeviceCaps($hDC, $PHYSICALHEIGHT) #Tidy_Off _LogMsg("+++:" & @CRLF _ & "$PHYSICALOFFSETX [" & $PHYSICALOFFSETX & "] $i__LeftMargin_X = " & $i__LeftMargin_X & @CRLF _ & "$PHYSICALOFFSETY [" & $PHYSICALOFFSETY & "] $i__TopMargin_Y = " & $i__TopMargin_Y & @CRLF _ & "$PHYSICALWIDTH [" & $PHYSICALWIDTH & "] $i__PageWidth = " & $i__PageWidth & @CRLF _ & "$PHYSICALHEIGHT [" & $PHYSICALHEIGHT & "] $i__PageHeight = " & $i__PageHeight & @CRLF _ ) #Tidy_On $i__x_start = $i__LeftMargin_X - 75 $i__y_start = $i__TopMargin_Y - 75 $i__x_end = $i__PageWidth - 250 $i__y_end = $i__PageHeight - 200 _Printer_SetInitial_XY() $i__LastLineNum = _Printer_GetLastLineNum() EndFunc ;==>_Printer_GetMetrics Func _Printer_SetInitial_XY() $i__CurrentPos_X = $i__LeftMargin_X $i__CurrentPos_Y = $i__TopMargin_Y * 22 EndFunc ;==>_Printer_SetInitial_XY Func _Printer_GetLastLineNum() Local $x1, $y, $linenumber $linenumber = -1 If ($i__Printer_Char_H > 0) Then For $x1 = 1 To 999 $y = (($i__Printer_Char_H + $VLINESPACE) * ($x1 + 1)) If ($y >= $i__y_end) Then $linenumber = $x1 ExitLoop EndIf Next EndIf If ($linenumber == -1) Then MsgBox(0, "Internal Error", "ERROR: Could not calculate the last line number") Exit (1) EndIf $linenumber -= 1 Return ($linenumber) EndFunc ;==>_Printer_GetLastLineNum Func __Printer_SetupCharWH($hDC) Local $vExtents $vExtents = _WinAPI_GetTextExtentPoint32($hDC, "x") $i__Printer_Char_W = DllStructGetData($vExtents, "X") ; Get the width of a character $i__Printer_Char_H = DllStructGetData($vExtents, "Y") ; Get the height of a character EndFunc ;==>__Printer_SetupCharWH Func _LogMsg($msg, $lnum = @ScriptLineNumber) If (StringLeft($msg, 4) = "+++:") Then $msg = StringTrimLeft($msg, 5) $msg = StringStripWS($msg, 3) ConsoleWrite("+++:" & $lnum & "] " & $msg & @CRLF) EndFunc ;==>_LogMsg Func _Printer_SetFont($hDC) Local $hFont If ($a__Printer_Font == 0) Then _Printer_MakeFont() EndIf $hFont = $a__Printer_Font _LogMsg("+++: $hDC & " & $hDC & ", $hFont = " & $hFont) _WinAPI_SetFont($hDC, $hFont) ; <===================== EndFunc ;==>_Printer_SetFont Func _Printer_MakeFont() Local $hFontDC, $err, $errm, $str, $flag, $iHeight $flag = $FW_BOLD $iHeight = 8 $hFontDC = _WinAPI_CreateFont( _ $iHeight, _ 0, _ ; average character width 0, _ ; angle of escape 0, _ ; base-line orientation $flag, _ ; font weight - $FW_NORMAL, $FW_BOLD, etc. False, _ ; italic False, _ ; underline False, _ ; strikeout $DEFAULT_CHARSET, _ ; the character set $OUT_DEFAULT_PRECIS, _ ; the output precision $CLIP_DEFAULT_PRECIS, _ ; the clipping precision $DEFAULT_QUALITY, _ ; the output quality 0, _ ; the pitch and family of the font "courier new") ; typeface name _LogMsg("+++: $hFontDC = 0x" & Hex($hFontDC)) If ($hFontDC <= 0) Then $str = "_WinAPI_CreateFont() failed." & @CRLF $err = _WinAPI_GetLastError() $errm = _WinAPI_GetLastErrorMessage() _LogMsg("+++: " & $err & ", 0) - '" & $errm & "'" & @CRLF & $str) Exit (9) EndIf $a__Printer_Font = $hFontDC EndFunc ;==>_Printer_MakeFont Here is the full script. Run it to see the problem:
  6. On the above pic. of the ASCII table, one can see in a "normal" size, the characters below 32. I use this chars. to visualize data and comm stuff, and prefer to see it in Terminal, size 9, 400, but in Win 10 looks tiny, forcing me to use a humongous size. I'd like to see it as I did in WinXP. If anyone knows how to go about it, by tweaking something or installing a replacement font, please let me know. Thanks
  7. I use a monospace font for editing AutoIt scripts in SciTE (currently, CourierNew 9pt). Regardless of what font size I set in the configuration, when I start SciTE to resume editing the script text is one size smaller than I specified. When I type Ctrl+<numpad-slash> the text changes to the desired size. The same is true of the output pane, and I have to reset the size for both areas every time I start SciTE. IIRC, I've made few other changes to the configuration (e.g., changed the search highlight color and disabled Tidy), so this behavior seems odd. About SciTE says it's version 3.6.0 (Aug. 4, 2015). Any idea how to fix this?
  8. why some fonts do not appear? in other programs like paint.net the font preview work. Thx #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <file.au3> #include <array.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include<ComboConstants.au3> #include <GUIComboBox.au3> $Form1 = GUICreate("Form1", 300, 200, -1, -1) $iPic = GUICtrlCreatePic("", 0, 0, 300, 60) $hPic = GUICtrlGetHandle($iPic) $Combo1 = GUICtrlCreateCombo("Select Font", 25, 64, 250, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_DROPDOWNLIST)) $s_FontList = _FileListToArray(@WindowsDir & "\Fonts\","*.ttf") $NFontList = UBound($s_FontList)-1 For $ff = 1 to $NFontList GUICtrlSetData($Combo1, StringTrimRight($s_FontList[$ff],4)) Next Global $hGraphic GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hPic) _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit Case $Combo1 EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo If Not IsHWnd($combo1) Then $hWndCombo = GUICtrlGetHandle($Combo1) $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $hWndFrom Case $combo1, $hWndCombo Switch $iCode ; no return value Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box _DebugPrint("$CBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) $sFont = GUICtrlRead($Combo1) $sFontname = _WinAPI_GetFontResourceInfo(@WindowsDir & "\Fonts\" & $sFont & ".ttf") _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0) _GDIPlus_GraphicsDrawString($hGraphic, $sFontname, 10, 10, $sFontname, 10) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint
  9. I try to resolve my question with _WinAPI_AddFontResourceEx(@ScriptDir & "\font\myfont.ttf", $FR_PRIVATE, False) unsuccessful.. THX
  10. Hi, i did some researchs how to set the font and the only way is to overwrite the subclass with WM_DRAWITEM. With WM_SETFONT i can only change the font for all tab pages, but i want to change the font for a specific page. So i have to set the $TCS_OWNERDRAWFIXED style to the tab control to send the WM_DRAWITEM message to the parent window. When i set this style, i can change the fonts, but sadly the tab looses the nice and simple "AutoIt style". I created two child guis, the first is the owner draw tab and the second the "Normal" tab. My questions is, how to create this special "AutoIt style"??? #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <ColorConstants.au3> Global Const $ODT_TAB = 101 Global Const $ODS_SELECTED = 0x0001 Global Const $ODA_DRAWENTIRE = 0x1 Global Const $ODS_FOCUS = 0x0010 $hStrikeOutDefaultFont = _WinAPI_CreateFont(14, 0, 0, 0, 400, False, False, True) ; see system apps module $hGUI = GUICreate("Draw Tab", 500, 600) ; Create child GUIs to hold tabs $hTab_Win0 = GUICreate("", 400, 200, 50, 20, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $hTab_0 = GUICtrlCreateTab(10, 10, 380, 180, $TCS_OWNERDRAWFIXED);BitOR($TCS_OWNERDRAWFIXED, $TCS_TOOLTIPS, $WS_TABSTOP, $WS_CLIPSIBLINGS)) $hTab_00 = GUICtrlCreateTabitem("00") GUICtrlCreateButton("00", 160, 90, 80, 30) $hTab_01 = GUICtrlCreateTabitem("01") GUICtrlCreateButton("01", 160, 90, 80, 30) GUICtrlCreateTabitem ("") GUISetState() $hTab_Win1 = GUICreate("", 400, 200, 50, 250, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $hTab_1 = GUICtrlCreateTab(10, 10, 380, 180) $hTab_10 = GUICtrlCreateTabitem("10") GUICtrlCreateButton("10", 160, 90, 80, 30) $hTab_11 = GUICtrlCreateTabitem("11") GUICtrlCreateButton("11", 160, 90, 80, 30) GUICtrlCreateTabitem ("") GUISetState() GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM") ;~ GUIRegisterMsg($WM_SETFONT, "WM_SETFONT") ;~ GUICtrlSendMsg ( $hTab_1, $WM_SETFONT , $hStrikeOutDefaultFont, 1 ) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_SETFONT($hWnd, $Msg, $wParam, $lParam) ConsoleWrite("$hWnd: " & $hWnd & " $Msg: " & $Msg & " $wParam: " & $wParam & " $lParam: " & $lParam & @CRLF) EndFunc Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) Local $DRAWITEMSTRUCT $DRAWITEMSTRUCT = DllStructCreate("uint cType;uint cID;uint itmID;uint itmAction;uint itmState;" & _ "hwnd hItm;hwnd hDC;dword itmRect[4];dword itmData", $lParam) If DllStructGetData($DRAWITEMSTRUCT, "cType") <> $ODT_TAB Then Return $GUI_RUNDEFMSG Local $cID = DllStructGetData($DRAWITEMSTRUCT, "cID") Local $itmID = DllStructGetData($DRAWITEMSTRUCT, "itmID") Local $itmAction = DllStructGetData($DRAWITEMSTRUCT, "itmAction") Local $itmState = DllStructGetData($DRAWITEMSTRUCT, "itmState") Local $hItm = DllStructGetData($DRAWITEMSTRUCT, "hItm") Local $hDC = DllStructGetData($DRAWITEMSTRUCT, "hDC") If $itmAction <> $ODA_DRAWENTIRE Then Return $GUI_RUNDEFMSG Local $iTextColor, $itmText $iTextColor = 0xFFFFFF Switch $itmID Case 0 $iBrushColor = 0x11AADD Case 1 $iBrushColor = 0xEEBB99 EndSwitch _WinAPI_SetBkMode($hDC, $TRANSPARENT) Local $iBrush = _WinAPI_CreateSolidBrush($iBrushColor) Local $iBrushOld = _WinAPI_SelectObject($hDC, $iBrush) $g_tRECT = DllStructCreate($tagRect, DllStructGetPtr($DRAWITEMSTRUCT, "itmRect")) DllStructSetData($g_tRECT, "Left", DllStructGetData($g_tRECT, "Left")) DllStructSetData($g_tRECT, "Top", DllStructGetData($g_tRECT, "Top")) DllStructSetData($g_tRECT, "Right", DllStructGetData($g_tRECT, "Right")) DllStructSetData($g_tRECT, "Bottom", DllStructGetData($g_tRECT, "Bottom")+10) _WinAPI_FillRect ( $hDC, $g_tRECT, $iBrush ) _WinAPI_SetTextColor($hDC, $iTextColor) _WinAPI_DrawText($hDC, "Item " & $itmID, $g_tRECT, $DT_LEFT) _WinAPI_SelectObject($hDC, $iBrushOld) _WinAPI_DeleteObject($iBrush) Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM Thanks in advance
  11. Hi all, I would like to know how to check if a specific font is installed in user's system. If it is not installed, my program needs to install the font. (Don't worry about the copy right of the font. it's free) I have got some points from google which directs me into _WinAPI_AddFontResourceEx function. But help file says that this function is only for current session. And i also got the _WinAPI_EnumFontFamilies function too. But before trying any of these, i would like to hear from the masters.
  12. Hello, I need help with loading true type fonts(*.ttf), without installing it. (Font: star_jedi.zip) Thanks star_jedi.zip
  13. In my code, I'm using GUICtrlCreateLabel to create a label and GUICtrlSetFont to set the font. Example... $SELlbl = GUICtrlCreateLabel("Hello World", 8, 8, 286, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")This works in my GUI unless display settings are changed in Windows 7 from 100% to 125-150%. Then the text is blown up and is misaligned with my GUI. Is there a simple way to ignore the display setting and force the font size?
  14. Hi all, I am up to change the font of a rich edit control. I need to set an unicode font(Malayalam). But the code doesn't working. see this. Global $EditMallu = _GUICtrlRichEdit_Create ($FormM2M,"", 520, 37, 489, 417) _GUICtrlRichEdit_SetText ($EditMallu, "]co£Ww") _GUICtrlRichEdit_SetFont ($EditMallu, 14, "MLTTRevathi") ;GUICtrlSetColor($EditMallu, 0x0000FF) _GUICtrlRichEdit_SetEventMask($EditMallu, "EditMalluChange") Original name of that font is this = "ML-TTRevathi". What is wrong with it ? Edit - I can't change the font color too.
  15. Derp, accidently it Ok, so when I make some text with GDIplus, it attempts to make it look better by adding hue to the right / left sides of letters. example: The top "this" is the rendered text, the bottom one is the same with the pixels magnified 600% I do not want it to do this! Please help #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _Main() Func _Main() Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout Local $sString = "This is a string", $aInfo ; Create GUI $hGUI = GUICreate("GDI+", 150, 60) ; Draw a string _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics(150,60,$hGraphic) $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) $hBrush2 = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 12, 1) $tLayout = _GDIPlus_RectFCreate(15, 15, 150, 30) _GDIPlus_GraphicsFillRect($hContext,0,0,150,60,$hBrush2) _GDIPlus_GraphicsDrawStringEx($hContext, $sString, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_ImageSaveToFile($hBitmap,"This is an image.png") ShellExecute("This is an image.png") ; Clean up resources _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush2) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>_Main
  16. I have encountered that the font weight does not seem to scale the way I would have expected. The degree of "bold" does not always increase with the weight value but even reverses e.g. 700 being less bold than 600 ? Does anyone have an idea? Code and screenshot below. Cheers #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $f_size = 9 Local $h_win = GUICreate ( "TEST GUI ... FONT weight", 400, 350) GUISetBkColor(0xffffff, $h_win) GUISetFont(10, 400, 0, "Arial", $h_win, 2) GUICtrlCreateLabel("Test FONT weight ...", 10, 10) GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 200)", 10, 60, 380, 20) GUICtrlSetFont(-1, $f_size, 200) GUICtrlSetColor(-1, 0x000099) GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 400)", 10, 90, 380, 20) GUICtrlSetFont(-1, $f_size, 400) GUICtrlSetColor(-1, 0x000099) GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 500)", 10, 120, 380, 20) GUICtrlSetFont(-1, $f_size, 500) GUICtrlSetColor(-1, 0x000099) GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 600)", 10, 150, 380, 20) GUICtrlSetFont(-1, $f_size, 600) GUICtrlSetColor(-1, 0x000099) GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 700)", 10, 180, 380, 20) GUICtrlSetFont(-1, $f_size, 700) GUICtrlSetColor(-1, 0x000099) GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 800)", 10, 210, 380, 20) GUICtrlSetFont(-1, $f_size, 800) GUICtrlSetColor(-1, 0x000099) GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 900)", 10, 240, 380, 20) GUICtrlSetFont(-1, $f_size, 900) GUICtrlSetColor(-1, 0x000099) Local $button = GUICtrlCreateButton("Close", 160, 310, 80, 20) GUISetState(@SW_SHOW) While 1 Local $msg_pop = GUIGetMsg() Select Case $msg_pop = $GUI_EVENT_CLOSE ExitLoop Case $msg_pop = $button ExitLoop EndSelect WEnd GUIDelete() EndFunc
  17. I do not like Charmap, it's too small and you can't test a character with another font, you only get all chars for each font so it's not very handy. SpecialCharactersViewer permit with the Segoe UI Symbol font to display a maximum ( not all! ) of Ascii and Unicode characters. Simple click on a char and the corresponding Chr or ChrW code is displayed. Free to you to choose another font for see if the selected character can be used with. Windows XP do not have Segoe UI Symbol font, so it's more for Win7/Win8 users... Previous downloads : 100 Source : SpecialCharactersViewer v1.0.1.0.au3 Executable : SpecialCharactersViewer.exe.html (Once this html file downloaded, double click on it for start the download) Will be added to the next version of SciTE Hopper. Hope it can help !
  18. On desktop I click in a Properties and in Appearance tab there is an option Font Size = Very Large in My program I have a button and for this button I use GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetFont(-1, 8, 400, 0, 'MS Sans Serif') but this do not help Question: Why system change font size in control or How to prevent changing font size in control (button)
  19. Hi, i found several examples and also some UDF's, but they didnt helped me really well. Can someone give me an broad hint, how to automate the following neccessary process in a word file thorugh an AutoIT script? find all places/strings which have the (font.color grey25% or grey50%) and are striken through and make it hidden (FontEffectsHidden Text) find all places/strings which are in font.color red and change their font.color into black Thanks...
  20. I'm trying to create an edit control with Terminal as the font. I'm a big fan of Terminal at the 6x8 size, but I can't figure out a way to set it using GUICtrlSetFont. It seems as though the weight parameter is ignored, and setting the size to anything below 6 gives you the nearly unreadable 4x6 size. Setting it to 6, 7, or 8 gives the hideously distorted 16x8 size, and 9 or 10 sets it as the default, 8x12. Anyone used Terminal 6x8 in an edit control? Any suggestions?
×
×
  • Create New...