Page 1 of 1

Font Drawing Quality

Posted: Sun Mar 17, 2013 3:14 pm
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.

Re: Font Drawing Quality

Posted: Sun Mar 17, 2013 3:18 pm
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

Re: Font Drawing Quality

Posted: Sun Mar 17, 2013 3:22 pm
by STARGÅTE
I think it is a windows setting (cleartype yes/no).
No problem here on windows 7:
Image

Re: Font Drawing Quality

Posted: Sun Mar 17, 2013 5:08 pm
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.

Re: Font Drawing Quality

Posted: Sun Mar 17, 2013 5:52 pm
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

Re: Font Drawing Quality

Posted: Sun Mar 17, 2013 5:59 pm
by charvista
DrawText work with the older GDI
OK, thank you Stargåte, this makes sense.
So, probably for the next release of PB... :?:

Re: Font Drawing Quality

Posted: Sun Mar 17, 2013 6:05 pm
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).