From richard.spindler at gmail.com Mon Jan 30 14:45:01 2006 From: richard.spindler at gmail.com (Richard Spindler) Date: Mon Jan 30 14:45:13 2006 Subject: [linux-graphics-dev] simple, yet powerful Text to Bitmap Lib??? Message-ID: <4af8d6ff0601301145x51e3d5b2r@mail.gmail.com> Hi, I'm currently looking for a way to render some text onto an in memory bitmap for handling in my application. It should be as simple as possible, while maintaining the ability to lookup all fonts available on the system. (This is important) It seems as if the only way to make this happen, is to use one of the big Toolkits like GTK+ or Qt. While these options might be a decent choice for most situations, I am already using a different toolkit, and I'd like to keep dependencies down to a minimum. As far as I know the way to go would be to access freetype, fontconfig and pango directly. Unfortunatly these libraries are rather lowlevel, and I'd prefer to not mess with them. Is there any simple font library that fits these needs? If there isn't, I might be able to come up with such a thing, maybe there are other people that are interested too? I already created a basic api proposal, about how I think a simple font-api should look like. cheers -Richard -----8<----------------------------- typedef struct _font_list_struct { const char* name; const char* id; } font_list; struct _font_object_struct; int init_fonts (); void close_fonts (); _font_object_struct* create_font(); /* * NULL terminated font list */ font_list* get_all_fonts (); /* * returns 0 on sucess and -1 on error */ int set_font_face ( struct _font_object_struct* o, const char* font_id ); /* * ditto */ int set_font_size ( struct _font_object_struct* o, int size ); void set_font_regular ( struct _font_object_struct* o ); void set_font_bold ( struct _font_object_struct* o ); void set_font_italic ( struct _font_object_struct* o ); void set_font_align_left ( struct _font_object_struct* o ); void set_font_align_right ( struct _font_object_struct* o ); void set_font_align_center ( struct _font_object_struct* o ); /* * values are between 0.0 and 1.0 */ void set_font_color ( struct _font_object_struct* o, float r, float g, float b ); void set_background_color ( struct _font_object_struct* o, float r, float g, float b ); void get_font_dimensions ( struct _font_object_struct* o, int& w, int& h, const char* text ); /* * allocates an array of the size WxHx4 * and renderes the text to this buffer. * with alpha channel (RGBA) */ unsigned char* render_font ( struct _font_object_struct* o, const char* text ); unsigned char* render_font_no_alpha ( struct _font_object_struct* o, const char* text ); void free_font ( struct _font_object_struct* o ); From leonardr at lazerware.com Mon Jan 30 20:34:45 2006 From: leonardr at lazerware.com (Leonard Rosenthol) Date: Mon Jan 30 20:34:55 2006 Subject: [linux-graphics-dev] simple, yet powerful Text to Bitmap Lib??? In-Reply-To: <4af8d6ff0601301145x51e3d5b2r@mail.gmail.com> Message-ID: <000001c62606$850d2bd0$065da8c0@LDRZiVA> > I'm currently looking for a way to render some text onto an in memory > bitmap for handling in my application. It should be as simple as > possible, while maintaining the ability to lookup all fonts available > on the system. (This is important) > I don't believe that any of the "simple libraries", such as GD or IM/GM includes the ability to query fonts available on the OS - since that type of info is outside their "cross platform" aspects. Could you, perhaps, handle that yourself via fontconfig and then use GD or IM/GM once you have a path to the font in question? Leonard From richard.spindler at gmail.com Tue Jan 31 05:31:51 2006 From: richard.spindler at gmail.com (Richard Spindler) Date: Tue Jan 31 05:31:55 2006 Subject: [linux-graphics-dev] simple, yet powerful Text to Bitmap Lib??? In-Reply-To: <000001c62606$850d2bd0$065da8c0@LDRZiVA> References: <4af8d6ff0601301145x51e3d5b2r@mail.gmail.com> <000001c62606$850d2bd0$065da8c0@LDRZiVA> Message-ID: <4af8d6ff0601310231l16a8b5a7x@mail.gmail.com> 2006/1/31, Leonard Rosenthol : > Could you, perhaps, handle that yourself via fontconfig and then use > GD or IM/GM once you have a path to the font in question? That would be a viable approuch, but I also found an interesting snippet in the MLT source, that uses pango to render to a bitmap, maybe I can use this. -Richard