[Gambas-user] gb3: changing the active font

Kevin Fishburne kevinfishburne at ...1887...
Fri Nov 4 04:13:48 CET 2011


On 11/03/2011 03:21 PM, Laurent Carlier wrote:
> 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----

Fantastic! That works like a champion. Fonts in SDL are a bit tricky I 
see. Thanks everyone for your help.

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list