Delivered-To: lablgtk at yquem.inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:to:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; bh=ghXhKfYoRQGkjt41MFlsAS3cWFZUDIjsvgW7vwnchEI=; b=JtGEO3rp6+a2JP3eUkfN2IxaAjOgW+oAqq+dM352lJHhCLUXUuEqiZZESPZOKG4a3aetVpDgG0Dwj/NOGCUph2Zq8x4fdevtyb81umO8mqireNjmaMSZEo9J1hZnrGM76W/ntLVUnYaVl7IAyZO0IuiQYUm7qqPC8ZYuswGEm7g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:to:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; b=hhouIs4OTamMy8oroeFu73lhIkTh64JQbjEMeoeC0qxJMmw5h4YamXYZ6x8Df7uVLomjqEjltpydAkXrKmxWd2qAUSNI0MVVK31GEeqxe8FgBy5sFCl7aOVahaVAE+SnV8uhmE9zIGWhL+CUQGr/qhAtghah7zB40aXhyC+6Qeo= Date: Tue, 13 Nov 2007 18:06:31 +0100 To: lablgtk at yquem.inria.fr Subject: Re: [Lablgtk] Predicting width of rendered text Message-ID: <20071113170631.GA14227 at localhost> Mail-Followup-To: Julien Moutinho , lablgtk@yquem.inria.fr References: <4739B9D3.3080105 at janestcapital.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4739B9D3.3080105 at janestcapital.com> From: Julien Moutinho Content-Type: text/plain; charset=utf-8 Content-Length: 1147 On Tue, Nov 13, 2007 at 09:50:59AM -0500, Adam Chlipala wrote: > [...] > Can anyone suggest code that would let me measure the pixels needed to > render a string in the font that is being used in all of my widgets? AFAICS there is the (deprecated) Gdk.Font module: http://plus.kaist.ac.kr/~shoh/ocaml/lablgtk2/lablgtk-2.4.0/doc/html/Gdk.Font.html And the Pango.Layout GPango.context machinery: http://plus.kaist.ac.kr/~shoh/ocaml/lablgtk2/lablgtk-2.4.0/doc/html/Pango.Layout.html http://plus.kaist.ac.kr/~shoh/ocaml/lablgtk2/lablgtk-2.4.0/doc/html/GPango.context.html % lablgtk2 Objective Caml version 3.10.1+dev0 (2007-05-21) # let text = "On l'appelait Margot la ventouse Elle avait des yeux de velours." in GtkMain.Rc.parse_string "gtk-font-name = \"Sans 8\""; let window = GWindow.window () in let layout = window#misc#pango_context#create_layout in Pango.Layout.set_text layout text; Pango.Layout.get_pixel_size layout;; - : int * int = (131, 20) HTH, Julien. _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk