MacScript Posted June 24, 2014 Posted June 24, 2014 Hi all - I have read on the forums about font smoothing when using text with a transparent background. None of the examples I have found seem to include having the text being displayed in a Rich Edit control. I need to use the Rich edit control so that different lines of text can have color text and potentially different font/size. Best way to describe this application is a Console to monitor scroll text. Every time a new line of text is added to the end of the file it is read and then evaluated for specific keywords. Depending on the keywords, the text color, font and size will be adjusted prior to the line of text being outputted to the Rich Edit control. The problem that I am currently having is that the outside of the font seems to be fuzzy or I almost say white-ish. Which is making almost impossible to read. I made a very quick example snippet of script to share Any help would be appreciated. Thanks ahead of time. expandcollapse popup#include <GuiRichEdit.au3> #include <WindowsConstants.au3> $style1 = BitXOr($WS_POPUP, $WS_EX_LAYERED) $style2 = BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_LAYERED) $hGUI = GUICreate("RichEdit Transparent field", 500, 500, -1, -1, $style1, $style2) Global $Input2 = GUICtrlCreateEdit("", 20, 40, 450, 350) GUICtrlSetBkColor($Input2, 0xABCDEF) GUICtrlSetResizing(-1, 802) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 20,40,460,400, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL), $WS_EX_TRANSPARENT) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255) GUISetState(@SW_SHOW, $hGUI) ; Makes GUI Visible _GUICtrlRichEdit_SetFont($hRichEdit, 12, "Verdana") _GUICtrlRichEdit_WriteLine($hRichEdit, "This is a test" , +0, "", 0x008000) sleep(2000) _GUICtrlRichEdit_SetFont($hRichEdit, 12, "Arial") _GUICtrlRichEdit_WriteLine($hRichEdit, "This is a test" , +0, "", 0x3C0FF0) sleep(2000) _GUICtrlRichEdit_SetFont($hRichEdit, 12, "Arial") _GUICtrlRichEdit_WriteLine($hRichEdit, "This is a test" , +0, "", 0x00FF00) sleep(2000) Sleep(5000) Func _GUICtrlRichEdit_WriteLine($hWnd, $sText, $iIncrement = 0, $sAttrib = "", $iColor = -1) ; Count the @CRLFs StringReplace(_GUICtrlRichEdit_GetText($hWnd, True), @CRLF, "") Local $iLines = @extended ; Adjust the text char count to account for the @CRLFs Local $iEndPoint = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) - $iLines ; Add new text _GUICtrlRichEdit_AppendText($hWnd, $sText & @CRLF) ; Select text between old and new end points _GuiCtrlRichEdit_SetSel($hWnd, $iEndPoint, -1) ; Convert colour from RGB to BGR $iColor = Hex($iColor, 6) $iColor = '0x' & StringMid($iColor, 5, 2) & StringMid($iColor, 3, 2) & StringMid($iColor, 1, 2) ; Set colour If $iColor <> -1 Then _GuiCtrlRichEdit_SetCharColor($hWnd, $iColor) ; Set size If $iIncrement <> 0 Then _GUICtrlRichEdit_ChangeFontSize($hWnd, $iIncrement) ; Set weight If $sAttrib <> "" Then _GUICtrlRichEdit_SetCharAttributes($hWnd, $sAttrib) ; Clear selection _GUICtrlRichEdit_Deselect($hWnd) EndFunc
lorenkinzel Posted June 25, 2014 Posted June 25, 2014 No issues with the text here, it's got nice crisp edges. Tried it with several different desktop background colors. Sorry, that's not much help. WinXP, 3.3.9.22
mpower Posted June 25, 2014 Posted June 25, 2014 the only line that seems somewhat *fuzzy* is the last one, but that might be due to the brightness of the colour, the first two look fine. it looks even better on black background. so I would say it might be the contrast issue between the chosen background colour and the font colours. If you are not getting similar view to above then perhaps you need to check your windows settings to see if font smoothing is turned on etc..
UEZ Posted June 25, 2014 Posted June 25, 2014 (edited) Modify the transparent color (0xABCDEF) to see the differencies. Further it depends on the background how anti aliasing (smoothing) looks. Br, UEZ Edited June 25, 2014 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
MacScript Posted June 25, 2014 Author Posted June 25, 2014 Modify the transparent color (0xABCDEF) to see the differencies. Further it depends on the background how anti aliasing (smoothing) looks. Br, UEZ I am new to using transparent colors. I thought the only transparent color one can use is (0xABCDEF). What other ones can I use? How do I code my program to do anti aliasing? the only line that seems somewhat *fuzzy* is the last one, but that might be due to the brightness of the colour, the first two look fine. it looks even better on black background. so I would say it might be the contrast issue between the chosen background colour and the font colours. If you are not getting similar view to above then perhaps you need to check your windows settings to see if font smoothing is turned on etc.. Your screen shot is against a solid background. Here is a screen shot with the types of backgrounds I need to deal with -> So thought on how to fix this issue? Thanks ahead of time for all those who have contributed to this thread to help.
lorenkinzel Posted June 25, 2014 Posted June 25, 2014 Tried it at work & I had the same issue as your screen shot. I turned font smoothing off & the problem went away. http://www.thewindowsclub.com/disable-font-smoothing-windows
MacScript Posted June 25, 2014 Author Posted June 25, 2014 Tried it at work & I had the same issue as your screen shot. I turned font smoothing off & the problem went away. http://www.thewindowsclub.com/disable-font-smoothing-windows This option will not work, I can't ask 20 + people to disable font-smoothing on their computers for all applications. I need a way to make this occur for my application. I have seen comments on the forums about font smoothing for edit fields. just cant seem to find a solution for a rich edit. Thank you for your reply and suggestions.
Solution MacScript Posted June 25, 2014 Author Solution Posted June 25, 2014 I would like to thank UEZ for his help. it looks like by changing out the transparent background colors to one of these has helped the situation ([["Bright", 0xFEFEFE], ["Normal", 0xABCDEF], ["Dark", 0x2F2F2F]]).., Further testing is required to see if this has completely resolved the issue.
mpower Posted June 25, 2014 Posted June 25, 2014 (edited) I found that setting it the background transparent colour to absolute black ( 0x000000 ) produced the best results when the underlying background image had mostly black/dark colours, similarly setting it to absolute white ( 0xFFFFFF) produced the best result when the background image had mostly white/light colours. Perhaps there is a way you can analyse the underlying background and achieve an average pixel colour or similar and then set the appropriate transparency colour? Just a thought. EDIT: This might help: '?do=embed' frameborder='0' data-embedContent>> Edited June 25, 2014 by mpower
MacScript Posted June 26, 2014 Author Posted June 26, 2014 I found that setting it the background transparent colour to absolute black ( 0x000000 ) produced the best results when the underlying background image had mostly black/dark colours, similarly setting it to absolute white ( 0xFFFFFF) produced the best result when the background image had mostly white/light colours. Perhaps there is a way you can analyse the underlying background and achieve an average pixel colour or similar and then set the appropriate transparency colour? Just a thought. EDIT: This might help: '?do=embed' frameborder='0' data-embedContent>> Is there a specific list of colors for the background when using a transparent gui or can any color background be used? UEZ gave me 3 colors, and mpower gave 2 more. Thanks for information
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