Bug with fonts for StringGadgets?

Windows specific forum
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Bug with fonts for StringGadgets?

Post by Dude »

[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: Select all

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.
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Bug with LoadFont?

Post by Little John »

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.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Bug with LoadFont?

Post by Dude »

I'm using Win 7 Ultimate (64-bit) with PureBasic 5.70 beta 2 (32-bit). Obviously a bug then, between versions.
breeze4me
Enthusiast
Enthusiast
Posts: 511
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Bug with LoadFont?

Post by breeze4me »

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.
ccode
User
User
Posts: 99
Joined: Sat Jun 23, 2018 5:21 pm

Re: Bug with LoadFont?

Post by ccode »

Hello Dude!

Fonts sometimes behave mysteriously.

Code: Select all

;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.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Bug with LoadFont?

Post by Dude »

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.
ccode
User
User
Posts: 99
Joined: Sat Jun 23, 2018 5:21 pm

Re: Bug with fonts for StringGadgets?

Post by ccode »

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.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Bug with fonts for StringGadgets?

Post by Dude »

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.
ccode
User
User
Posts: 99
Joined: Sat Jun 23, 2018 5:21 pm

Re: Bug with fonts for StringGadgets?

Post by ccode »

Hi Dude! :mrgreen:

This is even more mysterious.
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.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Bug with fonts for StringGadgets?

Post by #NULL »

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(?)
ccode
User
User
Posts: 99
Joined: Sat Jun 23, 2018 5:21 pm

Re: Bug with fonts for StringGadgets?

Post by ccode »

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.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Bug with fonts for StringGadgets?

Post by #NULL »

@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.
ccode
User
User
Posts: 99
Joined: Sat Jun 23, 2018 5:21 pm

Re: Bug with fonts for StringGadgets?

Post by ccode »

You have to experiment with the "character set" -parameters and the "output precision" -parameters.

After that you are smarter;)

Code: Select all

;....
;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/window ... reatefontw
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Bug with fonts for StringGadgets?

Post by Fred »

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.
ccode
User
User
Posts: 99
Joined: Sat Jun 23, 2018 5:21 pm

Re: Bug with fonts for StringGadgets?

Post by ccode »

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.
Post Reply