User forums > General (but related to Code::Blocks)

font rendering issue when using C::B under windows remote desktop

<< < (2/2)

ollydbg:
OK, problem solved!!! I think I can hack our wxScintilla control to let it have the smooth font option enabled. (If you use Notepad++, you will see there is an option named: Enable smooth font, if you are using Notepad2, you will also see a similar option)

The trick is that the font description string format is changed in the wxWidgets.


--- Code: ---wxString wxNativeFontInfo::ToString() const
{
    wxString s;

    s.Printf(wxS("%d;%s;%ld;%ld;%ld;%ld;%ld;%d;%d;%d;%d;%d;%d;%d;%d;%s"),
             1, // version
             wxString::FromCDouble(pointSize),
             lf.lfHeight,
             lf.lfWidth,
             lf.lfEscapement,
             lf.lfOrientation,
             lf.lfWeight,
             lf.lfItalic,
             lf.lfUnderline,
             lf.lfStrikeOut,
             lf.lfCharSet,
             lf.lfOutPrecision,
             lf.lfClipPrecision,
             lf.lfQuality,
             lf.lfPitchAndFamily,
             lf.lfFaceName);

    return s;
}

--- End code ---

The above code is the current in wx 3.2.1(wxWidgets-3.2.1\src\msw\font.cpp), I believe in the wx forum, mentioned in Font color problem - wxWidgets Discussion Forum and Re: wxWidgets & ClearType, the lf.lfQuality is in index 13(suppose we start from 1), and now, it becomes 14.  ;)

EDIT

I see the font wx sample code works correctly, but I still need to find a way to enable the smooth font in our wxscintilla.

ollydbg:

--- Quote from: ollydbg on October 22, 2022, 04:14:14 pm ---

EDIT

I see the font wx sample code works correctly, but I still need to find a way to enable the smooth font in our wxscintilla.

--- End quote ---

This is the final version which enable the "smooth font" feature for the legacy GDI font render. I just tested in my remote PC, and it works OK!


--- Code: ---From cce9ad5d95b0f2c9f0a9f8b0f12046718b508f33 Mon Sep 17 00:00:00 2001
From: asmwarrior <a@b.com>
Date: Sat, 22 Oct 2022 22:40:27 +0800
Subject: enable the font smooth feature


diff --git a/src/sdk/wxscintilla/src/PlatWX.cpp b/src/sdk/wxscintilla/src/PlatWX.cpp
index f72c8cdc..0cb0bd2b 100644
--- a/src/sdk/wxscintilla/src/PlatWX.cpp
+++ b/src/sdk/wxscintilla/src/PlatWX.cpp
@@ -201,7 +201,28 @@ void Font::Create(const FontParameters &fp) {
         false,
         sci2wx(fp.faceName),
         encoding);
+
+    // enable the smooth font by default
+    // font rendering issue when using C::B under windows remote desktop
+    // https://forums.codeblocks.org/index.php/topic,25146.msg171484.html#msg171484
+
+    wxString nativeDesc = font.GetNativeFontInfoDesc();
+    int index = 0;
+    for (size_t pos = 0, start = 0; pos <= nativeDesc.length(); )
+    {
+        pos = nativeDesc.find(";", start);
+        index++;
+        if (index == 14)
+        {
+            // enable the cleartype option of the font
+            nativeDesc.replace(start, pos - start, "5");
+            bool result = font.SetNativeFontInfo(nativeDesc);
+            break;
+        }
+        start = pos+1;
+    }
     wxFontWithAscent* newFont = new wxFontWithAscent(font);
+
     fid = newFont;
 
 #ifdef HAVE_DIRECTWRITE_TECHNOLOGY

--- End code ---

MortenMacFly:
Thanks for the effort! I tried and it also works for me.

However, just a note: Scintilla is actually something that is very old in our sources meanwhile. Also, the blocking points that stopped us from updating to a newer scintilla code base are no longer present: Native scintilla now also supports line change colouring! So we should actually try once again to update scintilla in or sources. This would also solve this issue, I guess.

ollydbg:

--- Quote from: MortenMacFly on October 23, 2022, 04:45:09 pm ---Thanks for the effort! I tried and it also works for me.

--- End quote ---
Hi, Morten. I think under Windows, there should be an option to let user choose whether they need to enable the "smooth font" in legacy GDI mode. Or, we can just enable this smooth font option by default under Windows. There is no smooth font support for legacy GDI in any wxWidgets port. The Direct2D version do have smooth font support, but it has other crash issue, see this report by me: wxStyledTextCtrl with DirectWrite enabled will crash when user logs in by Windows remote desktop Issue #22872 wxWidgets/wxWidgets


--- Quote ---However, just a note: Scintilla is actually something that is very old in our sources meanwhile. Also, the blocking points that stopped us from updating to a newer scintilla code base are no longer present: Native scintilla now also supports line change colouring! So we should actually try once again to update scintilla in or sources. This would also solve this issue, I guess.

--- End quote ---
Some infor:
1, I see Scintilla 3.21.1 by MaartenBent Pull Request #1331 wxWidgets/wxWidgets, now the Scintilla 3.21.1 is merged to the wxWidgets' trunk yesterday, so I think we should first update our code base to this version.

2, in the above github pull link, you can see there are some discussion that they may create a repo for updating the the modern Scintilla 5.x.

3, We(in our C::B forum) has some discussion before, because the modern Scintilla 5.x need C++ 17 and above

Scintilla and SciTE

--- Quote ---Current development occurs on the default branch as 5.* which requires a recent C++ compiler that supports C++17.
--- End quote ---

For Lexilla

--- Quote ---Current development requires a recent C++ compiler that supports C++17. The testing framework uses some C++20 features but the basic library only uses C++17.
--- End quote ---

If we need to update to the modern scintilla, we at least need C++17.

4, what do you mean by:


--- Quote ---Native scintilla now also supports line change colouring!
--- End quote ---
?
Do you mean changing the background of the text?
Can you show me a link about this feature?






Navigation

[0] Message Index

[*] Previous page

Go to full version