• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Acessing the transformation matrix of each character in a textobject

Community Beginner ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

I am trying to replace all characters in my text with a manually skeletonized version of said text. I get cleaner, more flexible and faster results in milling, laser marking and embroidery this way. So i would like to find the transformation matrix of each individual character so that I can lookup that caharacter in a reference document and get the skeleton and transform it to replace the text.

 

lookup.png

Ok so far so good. Ive found some scripting tools like this script by Carlos Canto that unfortunately does not work for all cases and does not account for kerning properly. Is there a wat transformation matrix of each character in the scripting engine? If not, is it possible to get this in the SDK? Or do i really have to expand the text, get two points as reference for each character, calculat ethe transform and then copy?

 

Any ideas.

TOPICS
Scripting , SDK

Views

348

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , May 21, 2023 May 21, 2023

Yeah I found a more in depth description of how to do this with the API here. Seems that its a bit badly documented indeed. I would have wished to try to avoid using the API for this becasue it would just make it harder for me to deploy the thing.

Votes

Translate

Translate
Community Expert ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

Hi @J5E74, I have no experience with the prcoesses you mention, so please forgive me if I have too many questions due to my ignorance. Here goes.

 

1. What is a "skeletonized" character? Can you show in outline mode maybe? Do you mean a single stroked line making up the glyph? That wouldn't be easy to script at all.

 

2. Are you sure you mean "transformation matrix"? In a given text frame item, every glyph has the same transformation matrix. I can't imagine why finding the transformation matrix would help with anything. Maybe you are thinking of another term?

 

3. What is the reference document? Sounds very interesting!

 

4. The script of Carlos' you linked-to, seems to divide up a text frame into individual characters. Is that what you want? I have written my own version of a text divider—if you post a sample file (save as pdf to post here)—I can try it out. Or let me know if you want me to post the script.

 

5. You mention getting two points as reference for each character and calculating the transform? Can you show an example of what you are doing? It is hard to picture without more information.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

 

 

quote

1. What is a "skeletonized" character? Can you show in outline mode maybe? Do you mean a single stroked line making up the glyph? That wouldn't be easy to script at all.

 

Its the midline of a character. Im not asking how to do this ive allready done this part. And yes i know how to also do this automatically in most cases, but thst not the cleanest solution so i prefer to draw a clean midline (and sometimes not follow it like in the B character example). Besides i might not want the skeleton as i might want to do a zigzag for embroidery.

 

If i would be in outline mode you'd see even less than now on account of characters being solid in outline mode and the lines that are now in red would be black, really hard to see black on black. But that image is as close as a outline mode as you can get.

quote

2. Are you sure you mean "transformation matrix"?

 

Yes, absolutely, transformation matix has all the full info.  In text frames sure the orientation is the same, but translation and rotation may be changed by character. Clearly in a text to curve object each character is separate orientation.

 

quote

3. What is the reference document? Sounds very interesting!

 

Any document that has the individual glyph data and what it should be replaced with.

 

quote

4. The script of Carlos' you linked-to, seems to divide up a text frame into individual characters. Is that what you want? I have written my own version of a text divider—if you post a sample file (save as pdf to post here)—I can try it out. Or let me know if you want me to post the script.

 

Sort of, it does nearly what i want, but it does not attack text on curve objects and it does not account for kerning or individual character skaling or rotation.

 

quote

5. You mention getting two points as reference for each character and calculating the transform? Can you show an example of what you are doing? It is hard to picture without more information.

 

An affine 2D transformation matrix has 6 degrees of freedom. Two points have 4 degrees of freedom. If I assume that the shape has not been skewed then thats enough (unlike indesign illustrator does not allow for skewing of characters independently of base object). Since i can solve for rotation with dot product between original 2 points and new 2 points. I can solve for scale by calculating magnitude. Postion is just the first point to point difference. But yes i could take 3 points if i want to solve skew.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

LATEST

Thanks for the detailed response @J5E74. Very interesting. I've never thought about some of those details before and you have opened my eyes a bit. It makes sense that via the SDK you can get the transform matrix of each glyph—that the scripting API doesn't seem to provide. I am the same as Dirk, too, in that I have never encountered the hard/soft points idea. Also the idea that there are references to render (or convert?) glyphs for different processes, eg. embroidery—well this seems sort of obvious now that you say it, but it is a concept I've never thought about.

 

Anyway, all the best with your project.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

From the SDK, file ATESuites.h

/** Return transformation matrix of this run.
The matrix returned spesify the full transformation of the given run.  You need to transform the origin by IGlyphRun::GetOrigins() and concat with ITextFrame::GetMatrix() in order to get the location of the glyphs.
*/
ATEErr (*GetMatrix) ( GlyphRunRef glyphrun, ATETextDOM::FloatMatrix* ret);

 

file IText.h

/** Retrieves the transformation matrix of this run, which specifies the full transformation. To get the location of an individual glyph, you must transform the origin by the value in the \c #GetOrigins() array, then concatinate this matrix with
the text frame matrix, returned by \c ITextFrame::GetMatrix().
@Return The transformation matrix.
*/
 

So either way you can retrieve the matrix of a run and concat the tx per glyph in the run. A new rotation in your type on path would give you a new run. Note that this is talking about glyphs, so it might differ from characters at the scripting level e.g. when multiple characters are combined into a ligature, or the opposite way (dependent on the font's implementation). Therefor you'd deal with glyph shapes at the same level.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

Yeah I found a more in depth description of how to do this with the API here. Seems that its a bit badly documented indeed. I would have wished to try to avoid using the API for this becasue it would just make it harder for me to deploy the thing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

Interesting, I had not yet come across the concept of hard/soft points.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines