Font Drawing Quality

Just starting out? Need help? Post your questions and find answers here.
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Font Drawing Quality

Post by charvista »

Hello,

I discovered a noticeable difference in the font quality:

Code: Select all

If OpenWindow(1,100,100,800,640,"Font Quality Test")
    
    LoadFont(112,"Segoe UI",9)
    
    TextGadget(3,10,210,630,16,"This is using Segoe UI 9 using text gadget")
    SetGadgetFont(3,FontID(112))
    CanvasGadget(4,10,210+16,630,16)
    StartDrawing(CanvasOutput(4))
    FillArea(0,0,-1,$F0F0F0)
    DrawingFont(FontID(112))
    DrawText(0,0,"This is using Segoe UI 9 using drawing",$000000,$F0F0F0)
    StopDrawing()
    
    
    Repeat
        Event = WaitWindowEvent()
        Select Event
            Case #PB_Event_CloseWindow
                Q=#True
        EndSelect
    Until Q
EndIf
The font in the CanvasGadget is less rounded while using DrawText (thus lesser quality) than in the TextGadget.
How can we get the same high font quality using DrawText?

Thanks.
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Font Drawing Quality

Post by IdeasVacuum »

On Windows you can by using GDI+ to draw the text instead of PB's DrawText command. Danilo has written a fabulous lib:
GDI+ Lib
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Font Drawing Quality

Post by STARGÅTE »

I think it is a windows setting (cleartype yes/no).
No problem here on windows 7:
Image
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Font Drawing Quality

Post by charvista »

@IdeasVacuum
Thanks for the link - I need to study that, as it is very large. Thanks Danilo for sharing! What a huge work you have made there!

@Stargåte
There is a difference. The second line is bolder. And the characters are slighlty trouble, too.
[Your screenshot were magnified, so it does not represents the real display.] Edit: not true, it was my internet browser which was enlarged :oops:
Anyway, even if it is a question of clear type, BOTH displays should be identical!

For the fun, I wrote a comparison program - interesting point is the way I did the wrapping.

Code: Select all

If OpenWindow(1,0,0,1030,400,"Font Quality Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
    
    LoadFont(112,"Segoe UI",9)
    Text.s="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "+
           "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor "+
           "in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, "+
           "sunt in culpa qui officia deserunt mollit anim id est laborum."+
           "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae "+
           "ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur "+
           "aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem "+
           "ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam "+
           "quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi "+
           "consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem "+
           "eum fugiat quo voluptas nulla pariatur?"+
           "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et "+
           "quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum "+
           "et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil "+
           "impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et "+
           "aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic "+
           "tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."
    
    TextGadget(3,10,10,500,380,"")
    SetGadgetFont(3,FontID(112))
    SetGadgetText(3,Text)
    
    
    CanvasGadget(4,520,10,500,380)
    StartDrawing(CanvasOutput(4))
    FillArea(0,0,-1,$F0F0F0)
    DrawingFont(FontID(112))
    Wrap.s=Text.s
    G=0 : L=0
    While Wrap
        For i=1 To Len(Wrap)
            Tgw=TextWidth(Left(Wrap,G+1))
            If Tgw<=500
                G+1
            Else
                If Mid(Wrap,G+1,1)<>" "
                    For j=1 To Len(Wrap)
                        If Mid(Wrap,G-j+1,1)=" "
                            G-j
                            Break
                        EndIf
                    Next
                EndIf
                Break
            EndIf
        Next
        DrawText(0,L,Mid(Wrap,1,G),$000000,$F0F0F0)
        Wrap=Trim(Mid(Wrap,G+1))
        G=0
        L+15
    Wend
    StopDrawing()
    
    Repeat
        Event = WaitWindowEvent()
        Select Event
            Case #PB_Event_CloseWindow
                Q=#True
        EndSelect
    Until Q
EndIf
WARNING: it needs PB 5.10 at least, because I have used multi-line for the text in latin.
Last edited by charvista on Sun Mar 17, 2013 9:13 pm, edited 1 time in total.
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Font Drawing Quality

Post by STARGÅTE »

DrawText work with the older GDI, the TextGadget is from windows and work with GDI+, so the output is different:
Example with no-clear type:
Image
it can't look identical because different render engines are used
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Font Drawing Quality

Post by charvista »

DrawText work with the older GDI
OK, thank you Stargåte, this makes sense.
So, probably for the next release of PB... :?:
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
Puffolino
User
User
Posts: 49
Joined: Thu Jan 05, 2012 12:27 am

Re: Font Drawing Quality

Post by Puffolino »

Font quality may change when using different drawing modes: DrawText is able to produce high quality output using certain modes, but worse results with others (especially alpha blend).
Post Reply