Wrong draw text on Android Smartphones and Tablets when display is zoomed

Just starting out? Need help? Post your questions and find answers here.
Stefan
Posts: 248
Joined: Mon Feb 05, 2018 9:44 pm

Wrong draw text on Android Smartphones and Tablets when display is zoomed

Post by Stefan »

Code: Select all


Enumeration
  #window
  #temppic
  #gadget
  #font
EndEnumeration


;  !document.body.style.zoom = 1 / window.devicePixelRatio * 100 + "%"

OpenWindow(#window,10,10,600,600,"Test")
CreateImage(#temppic,300,300,32,RGB(200,200,200))
StartDrawing(ImageOutput(#temppic)) 
DrawingMode(#PB_2DDrawing_Transparent)
LoadFont(#font,"Arial",22)
DrawingFont(FontID(#font))
s.s="This is line 1"
DrawText(1,1,s)
DrawText(1,1+TextHeight(s),"This is line 2")
StopDrawing()
ImageGadget(#gadget,10,10,ImageWidth(#temppic),ImageHeight(#temppic),ImageID(#temppic))
With this code, drawtext looks like this:
https://doko-cafe.de/test/drawtestnotzoomed.jpeg
With !document.body.style.zoom = 1 / window.devicePixelRatio * 100 + "%" it looks so:
https://doko-cafe.de/test/drawtestzoomed.jpeg
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Wrong draw text on Android Smartphones and Tablets when display is zoomed

Post by Fred »

You shouldn't use this zoom code as said here: viewtopic.php?t=2663&hilit=document.body.style.zoom
Stefan
Posts: 248
Joined: Mon Feb 05, 2018 9:44 pm

Re: Wrong draw text on Android Smartphones and Tablets when display is zoomed

Post by Stefan »

I haven't found a working alternative to this yet.
Post Reply