LocY of text differs from FDK documentation

Explorer ,
Feb 11, 2020

Copy link to clipboard

Copied

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.

 

top-left.png

 

 

 

 

 

 

 

 

 

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 😞

TOPICS
Scripting

Views

393

Likes

Translate

Translate

Report

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

1 Correct Answer

Explorer , Feb 14, 2020
ReedError Explorer , Feb 14, 2020
I was able to get it in the end by doing:LocY - LineAscent - (FontSize / 10) A bit messy, but does the job.

Likes

Translate

Translate
Jump to answer Jump to answer
Advocate ,
Feb 12, 2020

Copy link to clipboard

Copied

Hi ReedError,

From the work with graphic textlines I know this:

TextLine-properties.png

 

 

 

 

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 Â.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 14, 2020

Copy link to clipboard

Copied

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

LocY - LineAscent - (FontSize / 10)

 

A bit messy, but does the job.

Likes

Translate

Translate

Report

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