NPN Posted November 29, 2011 Share Posted November 29, 2011 Hi, I have a line break rule that used to work. It was created by the fantastic Dan some time ago. It's a bit of code that basically inserts a   between the last and second last word, if the sentence is to wide for the text field. (I don't actually understand the code properly). So that the last word doesn't stand on it's own. Heres how it should look: Example Company Two AS Here's what happens: Example Company TwoAS So, it removes a regular space where it inserts a hard space as far as I understand. Here's the code: var name = CreateResource("department\\" + Field("department") + ".txt", "tagged text file", true); return name.content.replace(/(.*)(\s)(.+)$/, "$1 $3"); I've recreated the error within the zip file I've attached.example.zip Link to comment Share on other sites More sharing options...
step Posted November 29, 2011 Share Posted November 29, 2011 I'm not sure if I understand the problem you're having. In the example you attached, the nonbreaking space is honored when I preview the file. So the result I see is: Example Company Two As If you return the rule with "Treat returned strings as tagged text" unchecked do you see the in the returned string? Link to comment Share on other sites More sharing options...
NPN Posted November 29, 2011 Author Share Posted November 29, 2011 I'm not sure if I understand the problem you're having. In the example you attached, the nonbreaking space is honored when I preview the file. So the result I see is: Quote: Example Company Two As hmm. That´s weird. I thought maybe it was font related earlier, but I changed back to Arial to check earlier today, and it still did not work for me. If you return the rule with "Treat returned strings as tagged text" unchecked do you see the in the returned string? I am not at work right now, so I cannot check. But when I verified the code I got in return. I tried editing the code and inserting either a normal blank space or a <br>, but that just mucked up the code. This is really frustrating because I have tried so many things, and I do not understand why it suddenly stopped working. Especially since i recreated the problem in a new document using new files. Is there anything I can do to make it work temporarily? Can i force a space in the return code somehow? Link to comment Share on other sites More sharing options...
NPN Posted November 29, 2011 Author Share Posted November 29, 2011 Maybe a different approach would work. I could achieve more or less the same thing if I had a code that would insert a line break after the second word IF the sentence is too long for one line. Could anyone help me with the code for that? The most important thing right now is to get it working, I can always figure out why the code above does not work later. Link to comment Share on other sites More sharing options...
esmith Posted November 29, 2011 Share Posted November 29, 2011 That's a tad more difficult. Try doing a search for "TextMeasure" (one word) for samples of how you would go about doing that. Link to comment Share on other sites More sharing options...
Dan Korn Posted November 29, 2011 Share Posted November 29, 2011 I've recreated the error within the zip file I've attached. Thanks. The problem has something to do with the font "Foundry Form Sans Demi". It seems to work correctly for me with just about any other font. Unfortunately, I don't have the ability to analyze font-specific issues in the context of this forum. I suggest contacting Support. Link to comment Share on other sites More sharing options...
NPN Posted November 30, 2011 Author Share Posted November 30, 2011 You are indeed right. Seems to be a font specific problem. As I said earlier, I did suspect this and tried another font, but that didn't work either. I see now that most fonts work, but there are several that doesn't. Another one that doesn't work for example is Frutiger 45 light. Another bug (if you can call it that) happens if I try the font Consolas, then there are two spaces instead of one where the hardspace is inserted. I don't really understand how different fonts can produce different results in this case. I thought at least a space was the same in all fonts? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.