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

LocY of text differs from FDK documentation

Explorer ,
Feb 11, 2020 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

486

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

Explorer , Feb 14, 2020 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.

Votes

Translate

Translate
Community Expert ,
Feb 12, 2020 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 Â.

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
Explorer ,
Feb 14, 2020 Feb 14, 2020

Copy link to clipboard

Copied

LATEST

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

LocY - LineAscent - (FontSize / 10)

 

A bit messy, but does the job.

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