Date: Wed, 10 Aug 2005 12:45:51 +0900 (JST) Message-Id: <20050810.124551.01914366.garrigue at math.nagoya-u.ac.jp> To: romildo at uber.com.br Cc: lablgtk at math.nagoya-u.ac.jp Subject: Re: How to specify a font by name? From: Jacques Garrigue In-Reply-To: <20050810032044.GA23086 at malaquias> References: <20050810032044.GA23086 at malaquias> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: romildo at uber.com.br > I am new to lablgtk and would like to construct > a Gdk.font by name. I have tried > > Gdk.Font.load "helvetica" > > but it did not work. Please, how can I do it? > > The font is to be used in the string method of > class drawable: > > method string : string -> font:Gdk.font -> x:int -> y:int -> unit > > I am trying: > > drawing#string "Test" ~font:(Gdk.Font.load "Helvetica 12") ~x:50 ~y:50; > > Any help? With Gdk.Font.load, you must specify an X11 font name, so this should be something like "-*-helvetica-*--12-*". (I'm not sure this works on windows) However, with lablgtk2, the preferred way to choose a font uses Pango, so that you have also access to truetype fonts. This means replacing drawing#string by drawing#put_layout. You can see an example of how to do that in timer.ml (this is a bit complicated, but more powerful.) Jacques