# ScreenDC doesn't draw text

**URL:** <https://www.ruby-forum.com/t/screendc-doesnt-draw-text/179883>\
**Category:** wxRuby\
**Created:** [December 6, 2009, 7:17pm UTC](https://www.ruby-forum.com/t/screendc-doesnt-draw-text/179883 "2009-12-06T19:17:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![quintus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/49beb7/32.png) [@quintus](https://www.ruby-forum.com/u/quintus)\
**Post date:** [December 6, 2009, 7:17pm UTC](https://www.ruby-forum.com/t/screendc-doesnt-draw-text/179883/1 "2009-12-06T19:17:45Z")

</div>

Hi,

I’m doing some experiments with the ScreenDC class for on-screen  
drawing. Drawing shapes like a circle or rectangle works fine, but when  
I try to draw text onto the screen, nothing happens. I’m using the  
wxruby-ruby19 gem with ruby 1.9.1p243 (2009-07-16 revision 24175)  
[i686-linux] on an Ubuntu Karmic machine.

## My code looks like this (I know, it doesn’t make much sense, but it’s only to demonstrate the problem):

#!/usr/bin/env ruby  
#Encoding: UTF-8  
require “wx”

class TestApp \< Wx::App  
include Wx

def on\_init

```
Timer.every(1000) do
  sc = ScreenDC.new
  sc.font = NORMAL_FONT #To ensure there's a font to draw with
  sc.draw_rectangle(0, 0, 100, 100) #This gets drawn...
  sc.draw_text("Test", 0, 150) #...but this doesn't
end

```

end

end

## x = TestApp.new x.main\_loop

The rectangle is drawn without problems, but I can’t find the text  
anywhere on my screen.

Is this a bug?

Marvin

---

<div class="post-metadata">

**Author:** ![quintus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/49beb7/32.png) [@quintus](https://www.ruby-forum.com/u/quintus)\
**Post date:** [December 14, 2009, 8:48pm UTC](https://www.ruby-forum.com/t/screendc-doesnt-draw-text/179883/2 "2009-12-14T20:48:06Z")

</div>

Marvin GÃ¼lker wrote:

> The rectangle is drawn without problems, but I can’t find the text  
> anywhere on my screen.
> 
> Is this a bug?
> 
> Marvin

Nobody experiencing the same problem? However, I’ve filed that as a bug  
now:  
[http://rubyforge.org/tracker/index.php?func=detail&aid=27564&group\_id=35&atid=218](http://rubyforge.org/tracker/index.php?func=detail&aid=27564&group_id=35&atid=218)

Marvin

---

<div class="post-metadata">

**Author:** ![quintus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/49beb7/32.png) [@quintus](https://www.ruby-forum.com/u/quintus)\
**Post date:** [December 16, 2009, 2:01pm UTC](https://www.ruby-forum.com/t/screendc-doesnt-draw-text/179883/3 "2009-12-16T14:01:50Z")

</div>

Hi Marvin

Marvin Gülker wrote:

> I’m doing some experiments with the ScreenDC class for on-screen  
> drawing. Drawing shapes like a circle or rectangle works fine, but when  
> I try to draw text onto the screen, nothing happens. I’m using the  
> wxruby-ruby19 gem with ruby 1.9.1p243 (2009-07-16 revision 24175)  
> [i686-linux] on an Ubuntu Karmic machine.
> 
> My code looks like this

…

> ```
> sc.draw_text("Test", 0, 150) #...but this doesn't
> 
> ```

I got round to trying your sample, running it with a debug build on Mac.  
The line above is causing an assertion in Wx to fail, and then a crash.  
The message I get is rather cryptic,:

Assertion failed: ((min.y == p[0].y && max.y == p[order].y) || (min.y ==  
p[order].y && max.y == p[0].y)), function crossing\_count, file  
Paths/path-crossing.c, line 176.  
Abort trap

But I’m not sure if this is because ScreenDC doesn’t work properly on  
Mac, or if there’s something else wrong with the usage. I’ve never tried  
drawing directly on the screen.

sorry i can’t be more hlepful  
alex
