Menu

#2246 Text rendering problem, if line numbering is disabled (SciTE v5.0.1)

Bug
closed-fixed
nobody
5
2021-04-23
2021-04-18
No

Windows 10 x64, (Scintilla:Notepad3, SciTE release v5.0.1, x64)
Using latest Scintilla release (v5.0.1) I discovered following text rendering issue:
Using German text with "Umlauts" (äöüÄÖÜß) , disabling line numbering (SCI_SETMARGINWIDTHN(n,0) - zero(0) should be invisible according to documentation - the "Umlauts" changed their appearance as if the UTF-8 Encoding has bee reinterpreted as ISO-8851-1 Encoding, if caret enters the line with the "Umlauts" and get back to correct visualization, when the caret leaves the line (e.g. ü <-> ü, ä <-> ä, see attached .jpg)

Example text to copy:

Hallo,
vielen Dank für die schnelle Rückmeldung. Ich habe die aktuellste Version v5.21.416.1 beta (Version wunschgemäß kopiert, siehe unten). Leider tritt das Problem nach wie vor auf. Jedes Mal, wenn man einen neuen Buchstaben eintippt, wird die Darstellung für den Bruchteil einer Sekunde normal, doch dann verwandeln sich die Umlaute wieder in die zwei Sonderzeichen.

1 Attachments

Discussion

  • Pairi Daiza

    Pairi Daiza - 2021-04-18

    Hello,
    I would like to add a ".zip" file with a French text in UTF-8 as example with SciTE v5.0.1
    Likewise, the problem goes away completely if Line Numbers or Line Endings are enabled.

    Also more details on this issue in: https://github.com/rizonesoft/Notepad3/issues/3337
    PS: SciTE v5.0.0 and earlier do not have this problem.

    SciTE_Scarlet_UTF-8.png

     

    Last edit: Pairi Daiza 2021-04-18
  • Zufu Liu

    Zufu Liu - 2021-04-18

    debugging shows codePageText is zero in SurfaceD2D::DrawTextTransparent() when line number is disable. codePageText is only set in SetFont().

    For all text, set breakpoint condition in SurfaceD2D::DrawTextCommon() to codePageDraw==0, following is the stacktrace:

    Scintilla::SurfaceD2D::DrawTextCommon(Scintilla::PRectangle rc, const Scintilla::Font * font_, double ybase, std::basic_string_view<char,std::char_traits<char>> text, int codePageDraw, unsigned int fuOptions) Line 2448  C++
    Scintilla::SurfaceD2D::DrawTextTransparent(Scintilla::PRectangle rc, const Scintilla::Font * font_, double ybase, std::basic_string_view<char,std::char_traits<char>> text, Scintilla::ColourAlpha fore) Line 2501  C++
    Scintilla::EditView::DrawForeground(Scintilla::Surface * surface, const Scintilla::EditModel & model, const Scintilla::ViewStyle & vsDraw, const Scintilla::LineLayout * ll, __int64 lineVisible, Scintilla::PRectangle rcLine, Scintilla::Range lineRange, __int64 posLineStart, int xStart, int subLine, Scintilla::ColourOptional background) Line 2177  C++
    Scintilla::EditView::DrawLine(Scintilla::Surface * surface, const Scintilla::EditModel & model, const Scintilla::ViewStyle & vsDraw, const Scintilla::LineLayout * ll, __int64 line, __int64 lineVisible, int xStart, Scintilla::PRectangle rcLine, int subLine, Scintilla::DrawPhase phase) Line 2360  C++
    Scintilla::EditView::PaintText(Scintilla::Surface * surfaceWindow, const Scintilla::EditModel & model, Scintilla::PRectangle rcArea, Scintilla::PRectangle rcClient, const Scintilla::ViewStyle & vsDraw) Line 2560 C++
    Scintilla::Editor::Paint(Scintilla::Surface * surfaceWindow, Scintilla::PRectangle rcArea) Line 1819    C++
    
     
  • Zufu Liu

    Zufu Liu - 2021-04-18

    The problem is codePageText is used before set (in SetFont() method), so the bug apples to all other calls to DrawTextCommon().

     
  • Zufu Liu

    Zufu Liu - 2021-04-18

    A simple fix is remove codePageText, use mode.codePage directly like SurfaceGDI.

     
  • Neil Hodgson

    Neil Hodgson - 2021-04-18

    This was caused by trying to unify the DrawTextCommon and DrawTextCommonUTF8 methods in [94e7ff] without handling the side effects of SetFont correctly.

    I think the simplest change while preserving the code sharing is to change the name of the codePageDraw parameter to codePageOverride then use that if it is non-0:

    diff -r 605cb2d81911 win32/PlatWin.cxx
    --- a/win32/PlatWin.cxx Sun Apr 18 09:59:24 2021 +1000
    +++ b/win32/PlatWin.cxx Mon Apr 19 09:02:13 2021 +1000
    @@ -1354,7 +1354,7 @@
    
        std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) override;
    
    -   void DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, int codePageDraw, UINT fuOptions);
    +   void DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, int codePageOverride, UINT fuOptions);
    
        void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
        void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
    @@ -2303,10 +2303,11 @@
        return std::make_unique<ScreenLineLayout>(screenLine);
     }
    
    -void SurfaceD2D::DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, int codePageDraw, UINT fuOptions) {
    +void SurfaceD2D::DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, int codePageOverride, UINT fuOptions) {
        SetFont(font_);
    
        // Use Unicode calls
    +   const int codePageDraw = codePageOverride ? codePageOverride : codePageText;
        const TextWide tbuf(text, codePageDraw);
        if (pRenderTarget && pTextFormat && pBrush) {
            if (fuOptions & ETO_CLIPPED) {
    @@ -2340,7 +2341,7 @@
        if (pRenderTarget) {
            FillRectangleAligned(rc, back);
            D2DPenColourAlpha(fore);
    -       DrawTextCommon(rc, font_, ybase, text, codePageText, ETO_OPAQUE);
    +       DrawTextCommon(rc, font_, ybase, text, 0, ETO_OPAQUE);
        }
     }
    
    @@ -2349,7 +2350,7 @@
        if (pRenderTarget) {
            FillRectangleAligned(rc, back);
            D2DPenColourAlpha(fore);
    -       DrawTextCommon(rc, font_, ybase, text, codePageText, ETO_OPAQUE | ETO_CLIPPED);
    +       DrawTextCommon(rc, font_, ybase, text, 0, ETO_OPAQUE | ETO_CLIPPED);
        }
     }
    
    @@ -2360,7 +2361,7 @@
            if (ch != ' ') {
                if (pRenderTarget) {
                    D2DPenColourAlpha(fore);
    -               DrawTextCommon(rc, font_, ybase, text, codePageText, 0);
    +               DrawTextCommon(rc, font_, ybase, text, 0, 0);
                }
                return;
            }
    
     

    Related

    Commit: [94e7ff]

  • Rainer Kottenhoff

    Hello Neil,

    thank you for your quick response - the supplied patch works fine.

    Best regards
    Rainer

     
  • Neil Hodgson

    Neil Hodgson - 2021-04-19
    • labels: Scintilla, SciTE --> scintilla, win32, direct2d
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2021-04-19

    Fix committed as [0cf964] .

     

    Related

    Commit: [0cf964]

  • Neil Hodgson

    Neil Hodgson - 2021-04-23
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.