Problem printing some unicode characters to canvas gadget

Post bugreports for the Windows version here
TassyJim
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Problem printing some unicode characters to canvas gadget

Post by TassyJim »

PB6.20 and PB6.21 beta6
I have a strange problem printing some Unicode characters to a canvas gadget.
The characters I have found so far are
Chr($2370)+Chr($23fb)+Chr($23f5)+Chr($2315)+Chr($29f2)
They render as a hollow box unless I include a "magic" character in the string.

One of the magic characters is Chr($23fa)

Code: Select all

testtxt.s = "*"+Chr($23fb)+Chr($23fa)+Chr($23fb)+Chr($23fb)+"*"
testtxt2.s = "*"+Chr($23fb)+Chr($23fb)+Chr($23fb)+Chr($23fb)+"*"
problemch.s= Chr($2370)+Chr($23fb)+Chr($23f5)+Chr($2315)+Chr($29f2)

If OpenWindow(0, 0, 0, 420, 180, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 10, 10, 400, 100)
  TextGadget(2,0,120,250,40,testtxt+"  "+testtxt2+"  "+problemch)
  LoadFont(1,"Courier New",14)
  If StartDrawing(CanvasOutput(0))
    DrawingFont(FontID(1))
    
    DrawText(10,50,testtxt)
    DrawText(150,50,testtxt2)
    DrawText(300,50,problemch+Chr($23fa))
    DrawText(300,10,problemch)
    StopDrawing()
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
    
  Until Event = #PB_Event_CloseWindow
EndIf
Changing font doesn't seem to make any difference.
No problems printing to a TextGadget.

Jim
User avatar
STARGÅTE
Addict
Addict
Posts: 2226
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Problem printing some unicode characters to canvas gadget

Post by STARGÅTE »

Image
Confirmed.

However, if I use e.g. Segoe UI, DrawText renders the characters also without the magic character, but the size is different:
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
TassyJim
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: Problem printing some unicode characters to canvas gadget

Post by TassyJim »

I notice that your TextGadget text is not correct either.
You don't seem to have Chr($23fb) available. (looks like a power switch)

I just tested Vector text and it DOES print the characters correctly.

Jim
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Problem printing some unicode characters to canvas gadget

Post by Fred »

Just for info, was it working in previous PB version (6.1x) ?
User avatar
STARGÅTE
Addict
Addict
Posts: 2226
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Problem printing some unicode characters to canvas gadget

Post by STARGÅTE »

Fred wrote: Sun Apr 20, 2025 9:57 am Just for info, was it working in previous PB version (6.1x) ?
No. I think it is a problem with character replacement, when a character is not present in the used font.
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
TassyJim
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: Problem printing some unicode characters to canvas gadget

Post by TassyJim »

Fred,
V6.10 has the same issue.
I don't have any earlier version installed.
Characters are displayed correctly in a TextGadget but not on the canvas.
Vector graphics display correctly so the characters are present in the font.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Problem printing some unicode characters to canvas gadget

Post by Fred »

We just use TextOut_() to draw the font so I guess the problem lies here
User_Russian
Addict
Addict
Posts: 1516
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Problem printing some unicode characters to canvas gadget

Post by User_Russian »

Maybe function DrawText() won't have this problem.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [Done] Problem printing some unicode characters to canvas gadget

Post by Fred »

Fixed.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [Done] Problem printing some unicode characters to canvas gadget

Post by Fred »

Reverted the fix as it creates slowness. I will probably introduce a new flag to have a fast vs precise drawtext in 6.30.
TassyJim
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: Problem printing some unicode characters to canvas gadget

Post by TassyJim »

Thanks for trying Fred.
I can work around it for now.

Edit
The fix I implemented is

Code: Select all

 Procedure DrawTextEx(hDc,x, y, Text.s, FrontColor, BackColor)
 Protected chRect.RECT
  chRect\left = x
  chRect\top = y
  chRect\right = x +  VT\CharPixelW
  chrect\bottom = y +  VT\CharPixelH

  SetTextColor_(hdc, frontColor)
  SetBkColor_(hdc, backColor)

  DrawText_(hDC, Text, Len(Text), @chRect.Rect, #DT_SINGLELINE )
 
EndProcedure
Thanks to mk-soft in the drawText() is very slow thread.
Post Reply