From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA29541; Thu, 7 Aug 2003 21:41:50 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA28690 for ; Thu, 7 Aug 2003 21:41:49 +0200 (MET DST) Received: from mz2.forethought.net (mzpi4.forethought.net [216.241.36.13]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h77Jflf23651 for ; Thu, 7 Aug 2003 21:41:48 +0200 (MET DST) Received: from [216.241.35.41] (helo=swordfish) by mz2.forethought.net with esmtp (Exim 4.14) id 19kqdu-0003yZ-S4 for caml-list@pauillac.inria.fr; Thu, 07 Aug 2003 13:41:46 -0600 Received: from matt by swordfish with local (Exim 3.35 #1 (Debian)) id 19kqdj-0002wd-00 for ; Thu, 07 Aug 2003 13:41:35 -0600 Date: Thu, 7 Aug 2003 13:41:35 -0600 From: Matt Gushee To: caml-list@pauillac.inria.fr Subject: [Caml-list] Multi-keyed lookup table? Message-ID: <20030807194135.GB21983@swordfish> Reply-To: Matt Gushee Mail-Followup-To: caml-list@pauillac.inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.27i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; gushee:01 all--:01 font:99 ,15:99 10646:01 serif:99 sansserif:99 helvetica:99 englewood:01 manure:01 mgushee:01 havenrock:01 ignores:01 --lao:01 merel:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, all-- I am trying to decide on a data structure that allows efficient lookup of fonts according to various font properties. I am thinking that the data structures describing fonts will be something like this: type font_weight = | Medium | Bold | Light type font_style = | Roman | Italic | Oblique type font_width = | Normal | Expanded | Condensed type encoding = string * int (* e.g. : ("iso8859",15)) type font_ref = string (* reference to the font file *) type font_family = ((font_weight * font_style * font_width * encoding) * font_ref) list (* Example font family *) let arial = [ ((Medium, Roman, Normal, ("iso10646",1)), "arial.ttf"); ((Bold, Roman, Normal, ("iso10646",1)), "arialb.ttf"); ... ];; (* based on the 5 types used in CSS and other Web standards *) type font_class = | Serif | SansSerif | Monospaced | Cursive | Fantasy What I would like to have is a data structure that contains descriptions of all fonts available on a particular system, such that an application can do something like: get_font_by_class ~weight:Bold ~style:Italic ~encoding:("iso8859",1) SansSerif or get_font_by_family ~weight:Bold "Helvetica" And obtain the font file name that matches the specified characteristics. As I mentioned above, efficient lookup is important; efficient creation of the data structure is probably not important; and since there are no large objects involved, and the data refers to font collections that may have hundreds of members, but probably not thousands, I don't think memory usage is really an issue. So, does anyone have an idea what sort of data structure would work best? TIA for your suggestions. -- Matt Gushee When a nation follows the Way, Englewood, Colorado, USA Horses bear manure through mgushee@havenrock.com its fields; http://www.havenrock.com/ When a nation ignores the Way, Horses bear soldiers through its streets. --Lao Tzu (Peter Merel, trans.) ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners