jmerrick0657 Posted November 3, 2016 Share Posted November 3, 2016 I'm having trouble copyfitting a certain font. I'm using this code: var StaticPart = ""; //This text will not copyfit. var DynamicPart = '<tracking newsize="4.5"><b>' + Rule("DetermineFrontEmail") + '</b>'; //This text will copyfit. var TextFont = "Akzidenz-Grotesk BQ Condensed A"; var FontSize = 8; var TextFrameName = "ContactBoxFront"; //For width calculation var MinFontSize = 4; var AdjustWidthOnly = false; if (Field("Email") == "" || Left(Field("Email"), 1) == "@") return ""; else return CopyfitLine(StaticPart,DynamicPart,TextFont,FontSize, FindTextFrame(TextFrameName).GetSettableTextWidth()/100, MinFontSize, AdjustWidthOnly); Which generates a font size smaller than 8, but not small enough to fit on one line: <f name="Akzidenz-Grotesk BQ Condensed A"><z newsize=8><z newsize=7.0000000000000036><tracking newsize="4.5"><b>jmerricklongname@access-genetics.com</b> The funny thing is, if I change the font it works fine; it seems to be just with this one font. The font is a bold font; I tried it without the <b> tags and got an error that normal style was not loaded, using bold style instead. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 3, 2016 Share Posted November 3, 2016 Well, it's hard to say without the job, especially the font, the data, and the other "DetermineFrontEmail" rule that is being called. But I can make a few guesses. It could be that the email address has a "special" character in it. You probably want a call to TaggedTextFromRaw in there, like so: var DynamicPart = '<tracking newsize="4.5"><b>' + TaggedTextFromRaw(Rule("DetermineFrontEmail")) + '</b>'; //This text will copyfit. It could also be that the tracking is confusing the copyfitting somehow. But the most likely issue is that the granularity of the CopyfitLine function is limited, especially at smaller starting point sizes. I think it would be better to use a variation of the CopyfitLineWithMagnifyTag function, which is here: http://forums.pti.com/showthread.php?t=84 Specifically, replace the last line of your rule with this: var line = "<f name=\"" + TextFont + "\"><z newsize=" + FontSize + ">" + DynamicPart; return CopyfitLineWithMagnifyTag(line, FindTextFrame(TextFrameName).GetSettableTextWidth( )/100, false); function CopyfitLineWithMagnifyTag(line, widthInPoints, AllowToExpand) { var tm = new FusionProTextMeasure; tm.CalculateTextExtent(line); if (tm.messages) { if (FusionPro.inValidation) ThrowError("CopyfitMagnifyLine", tm.messages); else Print("CopyfitMagnifyLine: " + tm.messages); } if (tm.textWidth < widthInPoints*100 && !AllowToExpand) return line; var factor = Round(widthInPoints / tm.textWidth * 10000, 0) - 1; return "<magnify type=pointsize factor=" + factor + ">" + line + "</magnify>"; } Quote Link to comment Share on other sites More sharing options...
jmerrick0657 Posted November 4, 2016 Author Share Posted November 4, 2016 Dan, Thanks for the response. I got it to work, but I'm not really sure why. I took my original rule and duplicated it to try your suggestions. Before I actually changed it I put the rule in a text box along with the original, and one of them worked while the other one didn't (even though they were exactly the same rule, producing exactly the same output). I then deleted the rule that wasn't working, and that caused the other rule to stop working as well. I then duplicated the rule that wasn't working, which caused one of them to start working. I'm not sure what is going on. So I checked the box "Re-evaluate this rule for every text flow" and that fixed it. I'm not sure why that would have fixed it, but it did. Thanks, Jake Merrick Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.