TextUnit not implemented in WE?

I am trying to use the TextUnit field in a Graphics object but encounter “This item does exist” error when building the web app. The TextUnit field autocompletes in the editor so I know the IDE knows something about the field.

Anyone have an idea why this is happening? Thanks in advance.

I’d guess that the WebStyle is intended to handle such things for web projects.

Is this on the Mac? Graphics.TextUnit is not available on Mac Carbon builds. And right now web and console apps are Carbon only.

Had to dig into the documentation for that info: http://documentation.xojo.com/index.php/FontUnits_Enumeration

Yes, it is a Mac. Thank you Daniel!

I can’t get DrawString to work on an offscreen buffer (Picture). Could these be as a result of TextUnits not being supported?

[quote=38308:@Michael Morehouse]Yes, it is a Mac. Thank you Daniel!

I can’t get DrawString to work on an offscreen buffer (Picture). Could these be as a result of TextUnits not being supported?[/quote]

You’ve got me on that one. I haven’t had to draw to a buffer in a Xojo console or web project yet. (A lot of my projects are still in RS2012.)

When you say DrawString doesn’t work, what happens?

Nothing as far as text goes. I can draw lines in the buffer with no problem. I’m gonna throw this post out to the web target forum separately but the other bizarre thing thats happening is when I draw the resulting buffer/picture to the canvas (WebCanvas) it triggers a number of Paint events. I’m going to continue researching this one before I post.

Thanks for you help. BTW - I’m using your controls! Pretty cool.

The two things that come to mind are a missing font, or a font that’s not compatible with the console app. Does the code work in a desktop project?

Curious: why not draw everything to a WebCanvas or jCanvas (since you have wcc)? Sending drawing commands to the client browser is almost always faster then sending a bitmap.


I have options to pre-buffer the images and send them as a bitmap or draw directly to the WebCanvas. I have been testing both to see what would be more useful and efficient.

I had a Xojo guy tell me that the DrawPicture to the WebCanvas is causing the browser to generate a number of invalidate events.

Invalidating and painting a region isn’t a concept that’s native to the HTML5 canvas. Obviously the browser is doing something that the Xojo framework is interpreting as a situation requiring a redraw, but I’m not sure what that could be. Maybe it has to do with the buffer image downloading?

Since you have wcc, if you haven’t played with it yet, take a look at the jCanvas control. There’s more to it so you want to sit down with it when you have a bit of free time. And if you decide to work with it directly rather than using the jCanvasToRbGraphics wrapper you’ll have to rework your code a bit. But it can do a lot. You can treat it as a raster (paint) surface or a vector surface. If you treat it as a vector surface you don’t have to redraw everything when a change is made, you just change the object properties. If you want to move a rectangle for example, you just change the coordinates of that object. (In jCanvas terminology a vector object on the canvas is a jCanvasLayer. A bit confusing since in most drawing programs a “layer” is something that holds multiple vector objects, but I wanted the control to closely match the API and terminology of the underlying JavaScript library.)

There’s no “invalidate/paint” event cycle with jCanvas, and with vector objects on the surface I don’t think you would ever have to worry about the browser needing a repaint or refresh. You can also receive mouse events on vector objects. And since this started with a question related to TextUnit, you can obtain font metrics for precise positioning (LoadFontMetrics method and wccFontMetricsLoaded event).

In the online demo I focus too much on animation. Which is cool if you have the client/server bandwidth for it. But I’m not sure I’ve successfully communicated to wcc users that it’s a very powerful drawing surface, and not just something for animation.