strings in webpictures go missing

I am creating pictures that contain strings as well as drawn lines, converting these to webpictures and displaying using a WebImageView. When I run the app to test it, all works well. But when I deploy it, the lines appear but the strings disappear. Thoughts?

Can you share some sample code? I think it will be easier for people to find an alternative.

Perhaps the webserver doesn’t have the font you’re asking it to draw with?

I am using Arial. Tested on Chrome, and when deployed and checked on Chrome, the strings disappear.

Some of the code that creates the strings:

dim i, j, k, xOff, yOff, TrianglePoints(6), RectanglePoints(8), PentagonPoints(10), HexagonPoints(12), OctagonPoints(16) As Integer
Dim g As Graphics
dim ShapeText(8) As String

ShapeText(1) = “triangles”
ShapeText(2) = “rectangles”
ShapeText(3) = “circles”
ShapeText(4) = “plus signs”
ShapeText(5) = “pentagons”
ShapeText(6) = “hexagons”
ShapeText(7) = “octagons”
ShapeText(8) = “snowflakes”

g = AnswerImage.Graphics

g.ForeColor = RGB(255, 255, 255)
g.FillRect(0, 0, PixelImageView.Width, PixelImageView.Height)

g.ForeColor = RGB(0, 0, 0)
g.TextSize = 20
g.TextFont = “Arial”

if CorrectNumber = True and CorrectShape = True then
g.DrawString("Correct! There were " + str(numShape) + " " + ShapeText(iShape) + “.”, 20, 40)
elseif CorrectNumber = True and CorrectShape = False then
g.DrawString("Close! There were " + str(numShape) + " " + ShapeText(iShape) + “.”, 20, 40)
elseif CorrectNumber = False and CorrectShape = True then
g.DrawString("Almost! There were " + str(numShape) + " " + ShapeText(iShape) + “.”, 20, 40)
elseif CorrectNumber = False and CorrectShape = False then
g.DrawString("Try Again. There were " + str(numShape) + " " + ShapeText(iShape) + “.”, 20, 40)
end
g.DrawString(“Round " + str(RoundsPLayed) + " of 5 completed.”, 20, 492)

and code converting picture to webpicture:

Dim wp As WebPicture = AnswerImage
PixelImageView.Picture = wp

I have tried creating AnswerImage using

AnswerImage = new Picture(512, 512, 32) and
AnswerImage = new Picture(512, 512)

Which didn’t change the results.

Thanks,

John

The browser doesn’t matter. If the font isn’t installed on the server itself, nothing will be drawn.

Just tried preloading the webpictures after they were created. It didn’t change the results. Quite odd to work while running the program but not while deployed on Xojo cloud.

Set up sftp and upload Arial.ttf from your computer into the Fonts directory on your Xojo Cloud server.

I am using CyberDuck to sftp, but I can’t login to my Xojo Cloud server. Do I need to create a SSH private key?

No, but you do need to turn it on in your control panel. If you continue to have trouble, send an email to hello@xojo.com and someone in tech support will help you directly.

Well, that was the problem. Works fine now. Many thanks!

But I don’t understand. I have written other apps that use drawstring with the Arial font in a canvas and this works fine when the app was deployed. But when I create a picture that included drawstrings and set this equal to a webpicture, the font failed to appear. Why wasn’t the font needed on my server for the use with a canvas?

Again, much appreciated for the help.

John

When you’re drawing a picture, the server is doing the drawing. The server will need any fonts you wish to use to draw with.
When you use a font in the interface, the browser is displaying it. The user will need any fonts you wish to use in the browser.

This only applies to the Web framework.

With Desktop apps, the user will still need the font installed. Arial is pretty standard for desktop operating systems, but not for web servers which usually don’t need fonts at all.

Thanks, Tim - this is really helpful!