[Gambas-user] gb3: changing the active font

Laurent Carlier lordheavym at ...626...
Thu Nov 3 20:21:21 CET 2011


Le jeudi 3 novembre 2011 15:06:22, Kevin Fishburne a écrit :
> On 11/03/2011 01:14 AM, Fabien Bodard wrote:
> > Have you tried :
> > 
> > Draw.Font = Draw.Font.Load("/home/kevinfishburne/Desktop/Sanctimonia,
> > 
> > because draw.font.load normally not assignate a font to draw.font but
> > just return an object handle to a font object
> 
> Nice, that actually works.
> 
> What's odd is that after some period of time it still halts with the
> error "gb.sdl error: Couldn't open
> /usr/local/share/gambas3/gb.sdl/DejaVuSans.ttf in Render 834". I checked
> the value of Draw.Font after the crash and it reports the Name property
> as being "DejaVuSans.ttf", even though I've only been setting it to
> "Avatar.ttf". I changed the line to this:
> 
> If Draw.Font.Name <> "Avatar.ttf" Then Draw.Font =
> Draw.Font.Load("/home/kevinfishburne/Desktop/Sanctimonia,
> Server/Images/Font/Avatar.ttf")
> 
> and it still crashes. Somehow Draw.Font.Name is being reset to
> "DejaVuSans.ttf". I searched the entire project for "Draw.Font" and
> nothing else is modifying it. Sounds like a bug. I'm using revision 4229.

Sorry for the late reply but i've totaly missed it

Font class act partially like qt's or gtk's one; you cannot use system fonts.


---8<----

Public Sub FooMethod()

  DIM myfont AS FONT

  myFont = Font.Load("/path/to/my/font.ttf")
  Font.Size = 20
  Font.Bold = True

  Draw.Begin(screen)
    Draw.Font = myFont
    blablabla
  Draw.End()

--->8----

Regards
    









More information about the User mailing list