Skip navigation
arenol
Currently Being Moderated

Getting the global position matrix for each text character

Feb 24, 2012 2:53 AM

Tags: #glyph #coordinates #matrix #ilustrator #ate

This post is a follow up to this related post.

 

I need to get the position and orientation of the first and the last character in a text frame art, that is, I need its  matrix.

 

There are a number of functions in the API that is supposed to help you; here's a snippet from the 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, ASRealMatrix* ret);

 

Hence, getting the matrix of the first character or glyph should look something like this:

 

AIErr

VMGetFirstTextMatrix(  AIArtHandle textArt, AIRealMatrix *matrix)

{

    ASRealMatrix frameMatrix, glyphMatrix;

    ASRealPoint firstPoint;

    try

    {

        TextFrameRef ateTextRef;

        sAITextFrame->GetATETextFrame( textArt, &ateTextRef);

        ITextFrame textFrame( ateTextRef);

 

        ITextLinesIterator lnItr = textFrame.GetTextLinesIterator();

        ITextLine txtLine = lnItr.Item();   

       

        IGlyphRunsIterator grItr = txtLine.GetGlyphRunsIterator();

        IGlyphRun glyphRun = grItr.Item();

       

        IArrayRealPoint pointArray = glyphRun.GetOrigins();

        firstPoint = pointArray.Item(0);   // comes out with wrong values!!!

       

        frameMatrix = textFrame.GetMatrix();

        glyphMatrix = glyphRun.GetMatrix();

 

              

        sMath->AIRealMatrixConcatTranslate( &glyphMatrix,

                        firstPoint.h, firstPoint.v);

        sMath->AIRealMatrixConcat( (AIRealMatrix*) &glyphMatrix,

                   (AIRealMatrix*) &frameMatrix,

                   matrix);

                      

        return kNoErr;

 

    }

    catch (ATE::Exception e)

    {

        return e.error;

    }

   

        return kNoErr;

}

 

But the coordinates, either returned in frameMatrix (tx and ty) or the firstPoint are obviously wrong. It appears that they an offset which is allmost constant.  The x-values are approx 7664 points too large (give and take a few decimals), and the y-values are approx 7893 too large (also give and take a few decimals).

 

I'm reall puzzled by this, because I need to get accurate positions...

 
Replies
  • Currently Being Moderated
    Feb 24, 2012 4:11 AM   in reply to arenol

    Like I said in the other thread.... it sounds like you need to convert between hard and soft coordinates.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points