Jump to content

Copyfitline not working as expected. Points?


mjlongo

Recommended Posts

Hello,

 

I'm working with a test document trying to get the copyfitline to work and I am getting unexpected results.

 

FusionPro version: 9.3.6

 

I created a text box exactly 1 inch wide therefore point size should be 72.

 

I first placed the LastName field in the box (no rule used) with data that contains long last names. I determined that 12 point font works fine for the shorter names and the long names do not fit. Then I reduced the font point size to 7 and tested that the long names will fit at that size.

 

I then built the copy fit rule and applied it to the same text box:

 

return CopyfitLine("", Field("LastName"), "Helvetica", 12, 72, 7, false);

 

However, the long last names absolutely will not reduce/fit into the frame unless I start dropping the point size down. I have to get down to around 55 before the last name will actually reduce. I have no idea why this is.

 

I also attempted to try applying GetsettableTextWidth lines to the rule in order to auto find the frame size but this didn't work either.

 

var mywidth = GetSettableTextWidth(FindTextFrame(FusionPro.Composition.CurrentFlow.name))/100;
return CopyfitLine("", Field("LastName"), "Helvetica", 12, mywidth, 7, false);

 

Tried this with a span tag as suggested in another post as well but it still didn't work:

 

var mywidth = GetSettableTextWidth(FindTextFrame(FusionPro.Composition.CurrentFlow.name))/100;
return "<span accumulate=false>" + CopyfitLine("", Field("LastName"), "Helvetica", 12, mywidth, 7, false) + "<span>";

 

Any ideas why the point size is not working in this case? Are there other boxes that need to be checked? I tried to both select and unselect the "Re-Evaluate..." and "Treat returned…" boxes to no avail.

 

Thanks!

Link to comment
Share on other sites

I'm not sure why you don't just apply the OnCopyfit callback function to the entire frame. It sounds like you're trying to copyfit the entire contents of the frame anyway.

 

I created a text box exactly 1 inch wide therefore point size should be 72.

You might want to double-check the Text Frame editor and verify that the width is exactly 1''. Sometimes those numbers jump around by a tiny bit (for me anyway).

I then built the copy fit rule and applied it to the same text box:

return CopyfitLine("", Field("LastName"), "Helvetica", 12, 72, 7, false);

 

However, the long last names absolutely will not reduce/fit into the frame unless I start dropping the point size down. I have to get down to around 55 before the last name will actually reduce. I have no idea why this is.

Dropping what point size down? The size of the text frame? If your frame is 72 points like you say it is, do you have a 8pt text inset applied to the frame? You'd have to account for that as well.

 

I also attempted to try applying GetsettableTextWidth lines to the rule in order to auto find the frame size but this didn't work either.

 

var mywidth = GetSettableTextWidth(FindTextFrame(FusionPro.Composition.CurrentFlow.name))/100;
return CopyfitLine("", Field("LastName"), "Helvetica", 12, mywidth, 7, false);

Again, nothing wrong with that code and that's probably the better way to accomplish this if you dead-set on not using the OnCopyfit callback. Keep in mind, though, that you have to actually give the text frame a unique name before that code will work.

 

All of these suggestions will require "Treat returned strings as tagged text" to be checked and making use of CurrentFlow will require "Re-evaluated this rule for every text flow" to be checked.

 

Unfortunately, I can't really offer any other solutions without seeing your template or data. All of the above worked for me.

Link to comment
Share on other sites

I'm not sure why you don't just apply the OnCopyfit callback function to the entire frame. It sounds like you're trying to copyfit the entire contents of the frame anyway.

Because I don't know anything about the OnCopyfit callback function! :) What does that function do compared to the function I am attempting here? All I want is for the LastName to adjust it's font size so that a long last name fits into the text frame.

 

You might want to double-check the Text Frame editor and verify that the width is exactly 1''. Sometimes those numbers jump around by a tiny bit (for me anyway).

I checked. It's one inch.

 

Dropping what point size down? The size of the text frame? If your frame is 72 points like you say it is, do you have a 8pt text inset applied to the frame? You'd have to account for that as well.

Dropping that 72 down from 72 to 55 within the code made the script "work".

I have no idea what you mean by the 8pt text inset. Can you explain that?

 

I will try to name the text frame box. I know I did not have that named.

Link to comment
Share on other sites

Because I don't know anything about the OnCopyfit callback function! :) What does that function do compared to the function I am attempting here? All I want is for the LastName to adjust it's font size so that a long last name fits into the text frame.

Click the text frame, click the "Overflow" button on the Text Frame property window, select "Adjust text to fit."

 

This will create an "OnCopyfit" callback function in your list of rules. More information can be found on page 152 of the User Guide PDF.

 

I have no idea what you mean by the 8pt text inset. Can you explain that?

On the Text Frame property window, there are text inset amounts that can be set. They located directly above the "Overflow" button. The first sets an x-inset and the second one sets a y-inset. I'm guessing if you had an 8pt x-inset, that would essentially decrease the amount of available space to fit the text by 16pts (8pt on the left and 8pt on the right). 72 - 16 = 56 so that would explain why your code works when you change the width parameter to 55.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...