Lisp HUG Maillist Archive

Draw-string and font

Hi,

I'm new to LispWorks and to CAPI. I have a basic difficulty. I should  
build a pane and draw strings on it with different fonts and sizes.

Question: How can I inform a pane with fcn draw-string about a  
certain font, size etc.?

I understand that I can build an instance of a pane and define my  
wishes with make-font-description. And I understand that I can form  
something like

- (gp:draw-string pane "Affenbaum" 100 150) and get the information  
given by make-font-description. I understand that I can change this  
information with something like

(gp:draw-string pane "Affenbaum" 100 150 :font "Sonata")

But how can I add to fcn draw-string my other wishes? Something like

(gp:draw-string pane "Affenbaum" 100 150 :font "Sonata" :size  
48 :weight :very-large) ?

I've read now during two days in the CAPI manuals but I seem to be  
too dumb to find a solution.

Thanks in advance!

Max


Re: Draw-string and font

Hi,

I think you need to use gp:make-font-description with gp:find-best-font or 
gp:find-matching-fonts

For example:

(defun foo (pane)
                (let ((font (gp:find-best-font pane 
(gp:make-font-description :family "Sonata" :size 48 :weight :bold))))
                  (capi:apply-in-pane-process pane (lambda () 
(gp:draw-string pane "Test" 100 150 :font font)))))

Font descriptions are discussed in 11.7 of the LispWorks CAPI User Guide.

hope this helps

paulm

At 14:42 09/02/2006, Max Haas wrote:

>Hi,
>
>I'm new to LispWorks and to CAPI. I have a basic difficulty. I should
>build a pane and draw strings on it with different fonts and sizes.
>
>Question: How can I inform a pane with fcn draw-string about a
>certain font, size etc.?
>
>I understand that I can build an instance of a pane and define my
>wishes with make-font-description. And I understand that I can form
>something like
>
>- (gp:draw-string pane "Affenbaum" 100 150) and get the information
>given by make-font-description. I understand that I can change this
>information with something like
>
>(gp:draw-string pane "Affenbaum" 100 150 :font "Sonata")
>
>But how can I add to fcn draw-string my other wishes? Something like
>
>(gp:draw-string pane "Affenbaum" 100 150 :font "Sonata" :size
>48 :weight :very-large) ?
>
>I've read now during two days in the CAPI manuals but I seem to be
>too dumb to find a solution.
>
>Thanks in advance!
>
>Max



Re: Draw-string and font

You have to give a font-description or a font object to the arg :font

Something like :

(gp:draw-string pane "Affenbaum" 100 150 :font (gp:make-font-description
:family "Sonata" :size 48 :weight :bold)

;see the capi user manual -> graphics-port -> portable fonts description for
details

When the port exists you can construct a font object like this

(gp:find-best-font port font-description)

If you give a font-description to the gp:draw-string function the call to
gp:find-best-font is implicit. So it's really faster to store the font
object somewhere and give it to the function, particularly if you have to
make many changes

Best

Denis

Le 9/02/06 15:42, « Max Haas » <Max.Haas@unibas.ch> a écrit :

> 
> Hi,
> 
> I'm new to LispWorks and to CAPI. I have a basic difficulty. I should
> build a pane and draw strings on it with different fonts and sizes.
> 
> Question: How can I inform a pane with fcn draw-string about a
> certain font, size etc.?
> 
> I understand that I can build an instance of a pane and define my
> wishes with make-font-description. And I understand that I can form
> something like
> 
> - (gp:draw-string pane "Affenbaum" 100 150) and get the information
> given by make-font-description. I understand that I can change this
> information with something like
> 
> (gp:draw-string pane "Affenbaum" 100 150 :font "Sonata")
> 
> But how can I add to fcn draw-string my other wishes? Something like
> 
> (gp:draw-string pane "Affenbaum" 100 150 :font "Sonata" :size
> 48 :weight :very-large) ?
> 
> I've read now during two days in the CAPI manuals but I seem to be
> too dumb to find a solution.
> 
> Thanks in advance!
> 
> Max
> 
> 



----------------------------------------------------
Denis Pousseur
6 clos du Drossart
1180 Bruxelles, Belgique

Mail :  denis.pousseur@compositeurs.be
Website : http://compositeurs.be
----------------------------------------------------




Updated at: 2020-12-10 08:48 UTC