It is currently Sun Dec 15, 2019 9:39 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Bug with fonts for StringGadgets?
PostPosted: Sat Dec 08, 2018 6:43 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1904
[Edited title, because this bug only appears to occur with StringGadgets].

When I run this code, only the first StringGadget font is underlined, at size 17. The size 13 font doesn't get underlined, so it seems the underline only occurs with certain font sizes? The size 13 also doesn't underline if I use the #PB_Font_HighQuality flag.

I note that Paint Shop Pro (bottom image) does underline size 13 though, so I assume this might be a PureBasic bug?

Code:
OpenWindow(0,200,200,350,120,"test",#PB_Window_SystemMenu)

StringGadget(1,10,10,330,35,"This is underlined")
SetGadgetFont(1,LoadFont(1,"@DFPOP1-W12",17,#PB_Font_Underline))

StringGadget(2,10,70,330,35,"But this isn't. Why?")
SetGadgetFont(2,LoadFont(2,"@DFPOP1-W12",13,#PB_Font_Underline))

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow

Image

Image


Last edited by Dude on Sun Dec 09, 2018 2:10 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with LoadFont?
PostPosted: Sat Dec 08, 2018 8:15 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3717
Location: Berlin, Germany
Which operating system and which PB version did you use?

When running your above code with my computer on Windows 10, using PB 5.62 (x64) or PB 5.70 beta 3 (x64), the text in both StringGadgets is underlined, as expected.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with LoadFont?
PostPosted: Sat Dec 08, 2018 8:21 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1904
I'm using Win 7 Ultimate (64-bit) with PureBasic 5.70 beta 2 (32-bit). Obviously a bug then, between versions.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with LoadFont?
PostPosted: Sat Dec 08, 2018 8:42 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Mar 09, 2006 9:24 am
Posts: 263
Location: S. Kor
The same problem here, using PB 5.70 beta 3 x64/x86 on Windows 10 home rs5(1809) x64 Korean.

It seems to occur when the vertical size of a font is 1 2 5 6 7 12 13.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with LoadFont?
PostPosted: Sat Dec 08, 2018 5:14 pm 
Offline
User
User

Joined: Sat Jun 23, 2018 5:21 pm
Posts: 99
Hello Dude!

Fonts sometimes behave mysteriously.

Code:
;Windows Bug ?

;Under Windows, it no longer works with font sizes: (1 2 4 5 6 7 11 12 13 18 .....)

;For whatever reason ?

;Font-URL: https://www.fontyukle.net/en/DFPOP1-W12.ttf

;It could be tested on Mac.
;(Please adjust)
;(I do not have a Mac)

Global Test_FontSize.i = 18

OpenWindow(0,200,200,400,140,"test",#PB_Window_SystemMenu)

;StringGadget(1,10,10,380,50,"")
EditorGadget(1,10,10,380,50)
SetGadgetText(1,"This is underlined")

;StringGadget(2,10,70,380,50,"")
EditorGadget(2,10,70,380,50)
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  SetGadgetText(2,"And that is also underlined (under Linux)")
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
  If FindString("1 2 4 5 6 7", Str(Test_FontSize)) Or Test_FontSize = 11 Or Test_FontSize = 12 Or Test_FontSize = 13 Or Test_FontSize = 18 ;......
    SetGadgetText(2,"But this isn't. Why?")
  Else
    SetGadgetText(2,"And that is also underlined (under Windows)")
  EndIf
CompilerEndIf

SetGadgetFont(1,LoadFont(1,"DFPOP1-W12",17,#PB_Font_Underline))
SetGadgetFont(2,LoadFont(2,"DFPOP1-W12",Test_FontSize,#PB_Font_Underline))

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  CompilerIf Subsystem("qt")
    QtScript(~"gadget(1).styleSheet = \"text-decoration: underline\" ")
    QtScript(~"gadget(2).styleSheet = \"text-decoration: underline\" ")
  CompilerElse
    Enumeration
      #PANGO_UNDERLINE_NONE
      #PANGO_UNDERLINE_SINGLE
      #PANGO_UNDERLINE_DOUBLE
      #PANGO_UNDERLINE_LOW
      #PANGO_UNDERLINE_ERROR
    EndEnumeration
    ImportC ""
      gtk_entry_set_attributes(*entry, *attrList)
      pango_attr_underline_new(underline.l)
      pango_attr_list_insert(*attrList, *attr.PangoAttribute)
      pango_attr_list_new()
    EndImport
    If PeekS(gtk_widget_get_name_(GadgetID(1)), -1, #PB_UTF8) = "GtkEntry"
      ;StringGadget 1
      *attrList = pango_attr_list_new()
      *underline.PangoAttribute = pango_attr_underline_new(#PANGO_UNDERLINE_SINGLE)
      pango_attr_list_insert(*attrList, *underline)
      gtk_entry_set_attributes(GadgetID(1), *attrList)
    EndIf
    If PeekS(gtk_widget_get_name_(GadgetID(2)), -1, #PB_UTF8) = "GtkEntry"
      ;StringGadget 2
      *attrList = pango_attr_list_new()
      *underline.PangoAttribute = pango_attr_underline_new(#PANGO_UNDERLINE_SINGLE)
      pango_attr_list_insert(*attrList, *underline)
      gtk_entry_set_attributes(GadgetID(2), *attrList)
    EndIf
    If PeekS(gtk_widget_get_name_(GadgetID(1)), -1, #PB_UTF8) = "GtkTextView" Or PeekS(gtk_widget_get_name_(GadgetID(2)), -1, #PB_UTF8) = "GtkTextView"
      Define.GtkWidget *gTextView1, *gTextView2
      Define.GtkTextBuffer *gBuffer1, *gBuffer2
      Define.GtkTextIter s_iter, e_iter
     
      *gTextView1 = GadgetID(1) : *gTextView2 = GadgetID(2)
      *gBuffer1 = gtk_text_view_get_buffer_(*gTextView1) : *gBuffer2 = gtk_text_view_get_buffer_(*gTextView2)
      gtk_text_buffer_create_tag_(*gBuffer1, "underline", "underline", #PANGO_UNDERLINE_SINGLE)
      gtk_text_buffer_create_tag_(*gBuffer2, "underline", "underline", #PANGO_UNDERLINE_SINGLE)
      gtk_text_buffer_get_bounds_(*gBuffer1, @s_iter, @e_iter)
      gtk_text_buffer_apply_tag_by_name_(*gBuffer1, "underline", @s_iter, @e_iter)
      gtk_text_buffer_get_bounds_(*gBuffer2, @s_iter, @e_iter)
      gtk_text_buffer_apply_tag_by_name_(*gBuffer2, "underline", @s_iter, @e_iter)
    EndIf
  CompilerEndIf
CompilerEndIf

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow


Last edited by ccode on Sun Dec 09, 2018 1:50 pm, edited 4 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with LoadFont?
PostPosted: Sun Dec 09, 2018 2:12 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1904
ccode wrote:
Fonts sometimes behave mysteriously

Hmm, yes, it appears to work correctly with EditorGadgets in your example, but not with StringGadgets as per my example. Title edited in my first post to reflect this.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with fonts for StringGadgets?
PostPosted: Sun Dec 09, 2018 10:09 am 
Offline
User
User

Joined: Sat Jun 23, 2018 5:21 pm
Posts: 99
Dude wrote:
Hmm, yes, it appears to work correctly with EditorGadgets in your example, but not with StringGadgets as per my example. Title edited in my first post to reflect this.


Under Windows, it no longer works with font sizes: ( 1 2 4 5 6 7 11 12 13 18 ..... ).

Windows Bug ?


Last edited by ccode on Sun Dec 09, 2018 1:39 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with fonts for StringGadgets?
PostPosted: Sun Dec 09, 2018 12:15 pm 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1904
ccode wrote:
This has nothing to do with the gadget.

StringGadget or EditorGadget does not matter.

Under Windows, it no longer works with font sizes <= 13.0

Well, my experience differs. If I use the font with size <=13 with StringGadgets (say: 10), then it's NOT underlined for StringGadgets; but size 10 IS underlined for EditorGadgets. This is using your own code above and commenting/uncommenting the gadgets as required for testing. So for me, it is a gadget issue.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with fonts for StringGadgets?
PostPosted: Sun Dec 09, 2018 12:24 pm 
Offline
User
User

Joined: Sat Jun 23, 2018 5:21 pm
Posts: 99
Hi Dude! :mrgreen:

This is even more mysterious.

Quote:
for StringGadgets; but size 10 IS underlined for EditorGadgets

You're right!

It seems to occur when the vertical size of a font is 1 2 4 5 6 7 11 12 13 18 ....

Under Linux, it works.


Last edited by ccode on Sun Dec 09, 2018 1:39 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with fonts for StringGadgets?
PostPosted: Sun Dec 09, 2018 12:59 pm 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1165
Location: right here
I don't know if this is related but when using editor Geany in Linux I sometimes don't see underscores, i.e. they look like spaces and become visiblibe when changing the zoom or font size. This also depends on the Font used. I guess it's a similar rendering issue(?)


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with fonts for StringGadgets?
PostPosted: Sun Dec 09, 2018 1:22 pm 
Offline
User
User

Joined: Sat Jun 23, 2018 5:21 pm
Posts: 99
Quote:
I don't know if this is related but when using editor Geany in Linux I sometimes don't see underscores, i.e. they look like spaces and become visiblibe when changing the zoom or font size. This also depends on the Font used. I guess it's a similar rendering issue(?)


Hello #Null!

How can I check this ?
I only occasionally see rendering problems that seem to be related to the GPU and the use of OpenGL in text rendering.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with fonts for StringGadgets?
PostPosted: Sun Dec 09, 2018 1:42 pm 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1165
Location: right here
@ccode
I can't reproduce it now. I think it was this site that helped me at the time. I did not remember that they said it was a font bug in that case (maybe fixed by now) but maybe that's true for DFPOP1-W12 as well. Anyway an underscore is an actual character where underline is probably done differently, i don't really know.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with fonts for StringGadgets?
PostPosted: Sun Dec 09, 2018 2:26 pm 
Offline
User
User

Joined: Sat Jun 23, 2018 5:21 pm
Posts: 99
You have to experiment with the "character set" -parameters and the "output precision" -parameters.

After that you are smarter;)

Code:
;....
;StringGadget(2,10,70,380,50,"")
EditorGadget(2,10,70,380,50)
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  SetGadgetText(2,"And that is also underlined (under Linux)")
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
  If FindString("1 2 4 5 6 7", Str(Test_FontSize)) Or Test_FontSize = 11 Or Test_FontSize = 12 Or Test_FontSize = 13 Or Test_FontSize = 18 ;......
    SetGadgetText(2,"But this isn't. Why?")
  Else
    SetGadgetText(2,"And that is also underlined (under Windows)")
  EndIf
;   hf = CreateFont_( 13, 0, 0, 0, 0, 1, 1, 0, #DEFAULT_CHARSET, #OUT_TT_PRECIS, #CLIP_DEFAULT_PRECIS, #PROOF_QUALITY, #DEFAULT_PITCH, @"DFPOP1-W12")
 
  hf = CreateFont_( 13, 0, 0, 0, 0, 0, 1, 0, #SHIFTJIS_CHARSET, #OUT_TT_PRECIS, #CLIP_DEFAULT_PRECIS, #PROOF_QUALITY, #DEFAULT_PITCH, @"DFPOP1-W12")
CompilerEndIf


SetGadgetFont(1,LoadFont(1,"DFPOP1-W12",17,#PB_Font_Underline))
SetGadgetFont(2,hf) ; Look here !

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  CompilerIf Subsystem("qt")
;....


https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createfontw


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with fonts for StringGadgets?
PostPosted: Mon Dec 10, 2018 8:20 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13662
Location: France
I don't think it's a PB issue, but mostlikely a Windows one. We don't use separate code path for Windows 10 or Windows 7, so it should behave the same. On Windows on my computer it display both with underline.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug with fonts for StringGadgets?
PostPosted: Mon Dec 10, 2018 9:12 pm 
Offline
User
User

Joined: Sat Jun 23, 2018 5:21 pm
Posts: 99
I also do not see it as a bug.
One can easily make special adjustments (for special cases (for example, certain Japanese fonts)) with the Windows Api directly.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye