Graphics.TextHeight returns 0 on Catalina with Xojo2019R2

Graphics.TextHeight and Graphics.TextWidth return 0 in a Web App built with Xojo2019R2 running in debugger on Catalina. The issue occurs with both Safari and Chrome browsers.

This code demonstrates the issue.

Dim p As New Picture(100, 100, 32)
dim H as integer

p.Graphics.TextFont = “Arial”
p.Graphics.TextSize = 12
H = p.Graphics.TextHeight


When this code is built with Xojo2019R1 and runs on Mac OS 10.13.6, it displays “TextHeight=18” as expected.

This code works fine in a Desktop app built with Xojo2019R2 and running on Catalina.

Any idea how to get TextHeight and TextWidth of Web App running on Catalina?

It’s likely that the Arial font doesn’t exist on the server.

1 Like

After further investigation, it appears that the only font supported on Mac Catalina (regardless of browser) when drawing to a Picture is “Times Roman” regardless of what Xojo version I use. Text drawn with an unsupported font is not visible in the picture and TextHeight and TextWidth returns 0.

If you set TextFont to “System” (or provide nothing) does it draw with the system font?

This must be a Catalina issue, as it works as expected on my Mojave install:

dim p as new Picture( 32, 32 ) p.Graphics.TextFont = "Arial" p.Graphics.ForeColor = &cFFFFFF p.Graphics.FillRect( 0, 0, p.Width, p.Height ) p.Graphics.ForeColor = &c000000 p.Graphics.DrawString( "Test", 0, p.Graphics.TextAscent, 1000 ) dim intHeight as Integer = p.Graphics.TextHeight break
intHeight = 18

You should create a Feedback Report and include a sample project.

Check to see if the font you are looking for by checking the System.FontAt method.

There’s a good example on the doc page for what you want to do:

No one told you to avoid the use of Xojo 2019r2 ???

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.