Re: New text metric procedure
On Wed, Sep 06, 2000 at 07:58:13PM -0400, Nick Marden <[EMAIL PROTECTED]> wrote: > I was looking through the PDB for a good procedure to return the > metrics of a text string a la gdk_string_extents() but all I could > find was gimp-text-get-extents. Unfortunately it returns the ascent > and descent of the font, not of the characters in the current string. Isn't the first what you want, anyway? I can only guess that the real problem is that gimp-text clips away part of the bounding box. Try using -1 as border size, this should leave the standard ascent and descent space around the charatcers, allowing you to align everything correctly. -- -==- | ==-- _ | ---==---(_)__ __ __ Marc Lehmann +-- --==---/ / _ \/ // /\ \/ / [EMAIL PROTECTED] |e| -=/_/_//_/\_,_/ /_/\_\ XX11-RIPE --+ The choice of a GNU generation | |
RE: New text metric procedure
Oh, something I noticed from using my new procedure: The string metrics returned by gdk_string_extents() aren't always exactly the same as the metrics of the bounding box returned from gimp-text. Apparently gimp-text uses something like gdk_string_extents, but not exactly the same. So far all I have seen is an occasional small height difference, which is easy to correct for progamatically, by comparing the height returned from text-get-string-extents with the height of the floating selection created by gimp-text, and translating the layer accordingly. Of course, that's far from elegant, so I'll get off my butt this weekend and look into why the numbers don't quite jive. Nick Marden - [EMAIL PROTECTED] (New numbers - please note!) (T) 781-455-0675 (C) 781-929-5279 (F) 781-455-6278 BEGIN:VCARD VERSION:2.1 N:Marden;Nick FN:Nick Marden ORG:Mercurial Virtual Supply Chain, Inc. TITLE:CTO TEL;WORK;VOICE:781-455-0675 TEL;HOME;VOICE:781-453-9588 TEL;CELL;VOICE:781-929-5279 TEL;WORK;FAX:781-455-6278 TEL;HOME;FAX:781-455-6278 ADR;WORK:;;32 Mark Lee Road;Needham;MA;02494;US LABEL;WORK;ENCODING=QUOTED-PRINTABLE:32 Mark Lee Road=0D=0ANeedham, MA 02494=0D=0AUS ADR;HOME:;;32 Mark Lee Road;Needham;MA;02494;US LABEL;HOME;ENCODING=QUOTED-PRINTABLE:32 Mark Lee Road=0D=0ANeedham, MA 02494=0D=0AUS URL:http://www.marden.org URL:http://www.bannerama.com KEY;X509;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HBzOi8vd3d3LnZlcmlzaWduLmNvbS9y cGEwEQYJYIZIAYb4QgEBBAQDAgeAMIGGBgpghkgBhvhFAQYDBHgWdmQ0NjUyYmQ2M2YyMDQ3 MDI5Mjk4NzYzYzlkMmYyNzUwNjljNzM1OWJlZDFiMDU5ZGE3NWJjNGJjOTcwMTc0N2RhNWQz ZjIxNDFiZWFkYjJiZDJlODkyMTZhZjZmZjhkMzExNDg5ZmExYmE0NWZjZjNlYTQ1ZmUwMwYD VR0fBCwwKjAooCagJIYiaHR0cDovL2NybC52ZXJpc2lnbi5jb20vY2xhc3MxLmNybDANBgkq hkiG9w0BAQQFAAOBgQANCITZBRQzBQuY79uGvFVlJ+kuOu8Y9zmj5GDhIVZ2NstV5Vf3LOYI 0n9jCzELM/e7bjUvpElm2EROXgypTAjZfzJ/bVCa9k38Y9pr5Yec1Kz33w8gS9RNoSqqw6AM bRVYuIEcDuqckzaDcFzbWAbgvPTzt/uhMdyhUUpF7RmpQo== EMAIL;PREF;INTERNET:[EMAIL PROTECTED] REV:2706T032957Z END:VCARD
New text metric procedure
Hey all. Sorry to just blurt onto the developer list like this, but the nice folks on #GIMP said that this was the place for such contributions. I was looking through the PDB for a good procedure to return the metrics of a text string a la gdk_string_extents() but all I could find was gimp-text-get-extents. Unfortunately it returns the ascent and descent of the font, not of the characters in the current string. So, if you need to align the baselines of two or more strings in potentially different fonts and/or sizes (I do), you're stuck. Maybe there is some way to do it with the functions that are available, but if so then I am too dumb to figure out what that approach might be, and there are probably a lot of people at least as dumb as me out there who would get similarly stuck. The attached patch to 1.1.25 is my solution, two new functions text_get_string_extents and text_get_string_extents_fontname, that provide the "real" ascent and descent info, as well as the lbearing and rbearing of the string. It's really just a map-through to gdk_string_extents(), but it solves my problem so I thought I would throw it out there for general consumption. If someone could tell me how to submit this to the development I would greatly appreciate it. Also, if someone wants to point out the obvious "other" solution that I could have used (if one exists), that would be edifying. Nick Marden - [EMAIL PROTECTED] (New numbers - please note!) (T) 781-455-0675 (C) 781-929-5279 (F) 781-455-6278 patch.string_extents