Locate center of multiple characters/lines of text?

Post questions on how to use or achieve an effect in Inkscape.
jimls
Posts: 13
Joined: Sat Mar 02, 2013 4:35 am

Locate center of multiple characters/lines of text?

Postby jimls » Sun Nov 29, 2015 11:31 pm

I am making a pattern for an embossing die which has three short lines of text. The font size and length of the lines are different. I would like to find the center of this (centroid I think would be the precise term) since this is the center of pressure when pressing this (or at least a close approximation of it). Rather than just estimate the location is there a way to determine it? I don't need an exact location but would like to use something better than "eyeballing" it and guessing. The two ways I can think of that might be possible are:

1. Determine the length of path around each character (deformation occurs along this path so length is proportional to pressure) and location (just using the center of each letter would be reasonably close). Then pick an arbitrary x and y reference line and calculate the center of the sum of path lengths:

(X offset1 * path length 1 + X offset 2 * path length2 +...)
________________________________________________ = offset of center of pressure
(path length 1 + path length 2 + ...)

And do the same for Y direction.

2. Do a similar calculation but use area of each letter.

I think #1 would give a more accurate result but I think either one would be close enough. My choice may come down to which is easier to do - i.e. how easy is it to get path length, area, etc from Inkscape. Is there any function in Inkscape that does these or similar calculations to make this easier?

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Locate center of multiple characters/lines of text?

Postby brynn » Mon Nov 30, 2015 6:41 am

I probably can't help much. But I do want to understand what you're saying a little better. Maybe will lead to an answer.

Without giving us the specific text (unless you can share it without copyright/trademark issue) can you show us a representative example? Like maybe just use lorem ipsum (or "quick brown fox" or "cow jumped over the moon"), so we can see the different font size and length of the lines.

Would the center of the entire text object work? Or the rotation center? Those aren't necessarily the same point. But both can be determined....because it's possible to snap to either center of object or center of rotation. I wouldn't be surprised if there's an extension that finds the center of an object. But I don't actually know of one.

When you say
Determine the length of path around each character

do you mean the length of the red path, like around the "t" below? Like if it were a circle, the circumference? Or do you mean the width of the character, like the "c" or "a" below? Or do you mean the combined width of character plus the space between them?

cat.png
cat.png (18.6 KiB) Viewed 1127 times

jimls
Posts: 13
Joined: Sat Mar 02, 2013 4:35 am

Re: Locate center of multiple characters/lines of text?

Postby jimls » Mon Nov 30, 2015 10:50 am

I put together the attached example with some random words with word lengths and size similar to my project. The final tool will press sheet metal to raise the letters. The force is proportional to the length of the outside of the letters. The length for an 'O' would be the circumference of the outside (it is fairly close to a circle) plus the circumference of the inner edge. In my example the center of the whole block is about the center of the 'e' in the middle of 'statehood'. But there is clearly more, bigger lettering above that than below. Also more to the left than the right. Just by looking at it I would estimate the center to be near the top of the second 't' in statehood. If I apply pressure at the center of the 'e' the pressure from the bigger length/area on the left and top will tip the tool toward the bottom right. The press will obviously have to be stiff enough to resist some offset pressure but by placing the press at the center of the forces (and also the length of the outlines) the tipping forces will be minimized. I am wanting to determine the approximate center of the force needed.

I discovered that there is an extension that may do just what I want.

Extensions > Visualize path > Measure path > Measure path > length

I need to spend some time checking that this gives what I think it does. If so it will be the first step of my calculations.

If I can get the total length of the outline for each letter I can consider it all being at the physical center of the letter - not exactly accurate but close. I can then total up area x distance from an arbitrary line and then figure out the center of the force in horizontal and vertical direction. The center of the press will be positioned there.

Hope that helps explain what I am wanting to do.

Center of rotation might give the center of the areas. Not as good at locating center of pressure but still might be useful if the length function doesn't work.... Will check it out.
Attachments
CenterExample.svg
(2.5 KiB) Downloaded 180 times

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Locate center of multiple characters/lines of text?

Postby brynn » Mon Nov 30, 2015 7:34 pm

The Measure Path extension does 2 things. It measure the length of the path, and it creates a new text object, essentially printing the measurement on the page. I'm guessing you probably don't need the text??

Have you found the new Measurement tool? Image It should be superior to the extension, for straight line distances. I'm not sure if you told us which version of Inkscape you're using, but Measurement tool is new in version 0.91.

However, it won't measure around a curved path. So maybe the extension is ideal after all. You can always just delete the text, once you note the distance.

Edit
OH! I see there is a new option in that Measure Path dialog, since the last time I looked at it. It used to be just for length and area. Now it has Center of Mass!

Isn't that exactly what you need??

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Locate center of multiple characters/lines of text?

Postby brynn » Mon Nov 30, 2015 7:51 pm

Note the center of mass indication is a really small "+" I can't seem to make it work on groups though - only individual objects.

Edit
Also doesn't appear to work on text unless text is converted to path. But hopefully can still be helpful.


Return to “Help with using Inkscape”