require 'phi'
include Phi

def dammy(v)
end

klass = Phi::Font

mf = Metafile.new
mf.width = 200
mf.height = 100
cc = nil
ff = nil
bb = nil
bmp = nil
mf.canvas{|mc|
  dammy(mc)
  mc.text_out(0, 0, 'Apolloでグラフィックス')

  rect = Phi::Rect.new(30,30,50,50)
  mc.brush.color = Phi::CL_RED
  mc.fill_rect(rect) # ← これも NG

  mc.font.size = 20
  cc = mc
  ff = mc.font
  bb = mc.brush
  bb.bitmap=Bitmap.new
  bmp = bb.bitmap
p bmp
}
  bmp = bb.bitmap
p bmp
GC.start
#p cc        #=> #<Phi::MetafileCanvas:0x142cef0>
#p cc.brush  #=> Zombie (IndexError)
#p cc.font   #=> Zombie (IndexError)
#p ff        #=> Zombie (IndexError)
p bb
p bmp
#p bb.bitmap

mf.save('Test.emf') # プレビューで確認可能

form = Phi::Form.new
image = Phi::Image.new form
image.align = AL_CLIENT
mf2 = Phi::Metafile.new
mf2.load('Test.emf')
image.picture.metafile = mf2
image.stretch = true
form.show
mainloop
