Skip to main content
Inspiring
February 11, 2020
Answered

LocY of text differs from FDK documentation

  • February 11, 2020
  • 2 replies
  • 587 views

Hi,

 

I have a function that gets the x-y co-ordinates of the first text character in a paragraph:

function topLeftPoint(targetDoc, targetPgf) {
	// get loc of first text character in the pgf
	var firstCharOffset = (targetPgf.GetText(Constants.FTI_String))[0].offset;
	var txtLoc = new TextLoc(targetPgf, firstCharOffset);

	// get top-left Point relative to the parent SubCol
	return new Point(
		targetDoc.GetTextVal(txtLoc, Constants.FP_LocX).ival,
		targetDoc.GetTextVal(txtLoc, Constants.FP_LocY).ival
	);
}

 

The FDK docs say that LocY gives the "Offset of the top of a character from the
top of the subcolumn", but it actually seems to get the y pos of the baseline.

 

 

 

 

 

 

 

 

 

 

Am I doing something wrong, or is the documentation just inacurate?

And does anyone know how to get the y pos of the top?

The best I've managed is to subtract the FP_LineAscent, but that's not quite the top 😞

This topic has been closed for replies.
Correct answer ReedError

I was able to get it in the end by doing:

LocY - LineAscent - (FontSize / 10)

 

A bit messy, but does the job.

2 replies

ReedErrorAuthorCorrect answer
Inspiring
February 14, 2020

I was able to get it in the end by doing:

LocY - LineAscent - (FontSize / 10)

 

A bit messy, but does the job.

K.Daube
Community Expert
Community Expert
February 12, 2020

Hi ReedError,

From the work with graphic textlines I know this:

 

 

 

 

I do not know which font property gives the distance from baseline to the upper bound of the line. It may be the font-size, but I'm not certain. The pink highlight is created with the character format Background. Keep in mind that there must be room for accents, such as Â.