Jump to content

Two Fonts and Custom Copy


Recommended Posts

Hi,

 

New here and to Marcom/Javascript/Fusion Pro so figured to reach out for some help.

Working on a postcard and the field EventHeader has 2 fonts and a variable spot to enter [Community Name] (I attached the image).

 

So, on Marcom side it would be pre filled field and user can change the Community Name. Not sure what the code looks like to return 2 fonts and for it to be a custom field. Any help is appreciated.

 

Thanks, :confused:

Untitled-2.png.6bc835f1b195bef61a8564a98dc83f71.png

Link to comment
Share on other sites

Thanks Dan,

 

I will try that. Maybe I'm overthinking this :).

 

I will say, a majority of the solutions you will find are a lot easier than you think. I would say 75%, I, myself, overthink the problems, and then find a very simple solution to the problem. Just letting you know, you are not alone.

Link to comment
Share on other sites

I will say, a majority of the solutions you will find are a lot easier than you think. I would say 75%, I, myself, overthink the problems, and then find a very simple solution to the problem. Just letting you know, you are not alone.

 

Thanks Scotts! It's good to know I'm not alone in this and to have a great support as this forum along the way :):)

Link to comment
Share on other sites

I don't think you need any JavaScript code to accomplish this. Just set the text with the data field name in the Text Editor, and set the fonts to whatever you want.

 

http://forums.pti.com/attachment.php?attachmentid=1810&stc=1&d=1522083702

 

Hey Dan,

 

So, when I set the fonts and change the data field to <header> it changes the font to the first font (top line)- see attached. This is all one field (header). This should also work as a custom field where user can change the copy if they would like. Is there a way to make it work like this without making it two separate data fields?

 

Thank you, :confused:

Untitled-2.png.69b28cf7eb0fc76a8e3e485b8f568057.png

Untitled-3.png.36234a310bcd56200cd783993d00a3f2.png

Link to comment
Share on other sites

So, when I set the fonts and change the data field to <header> it changes the font to the first font (top line)- see attached. This is all one field (header). This should also work as a custom field where user can change the copy if they would like. Is there a way to make it work like this without making it two separate data fields?

Sorry, I don't understand. If you posted the collected template, or at least the data file, and a mockup of what you want the output to look like, that might be clearer.

Link to comment
Share on other sites

Thanks for posting the template.

 

Are you trying to figure out how to replace the "[COMMUNITY NAME]" text in the data with something else? And what do you want to replace it with? Because the value of the "CommunityName" field in your data is just "[Community Name]". Or is the actual community name defined somewhere else?

 

Anyway, there may be a new feature in an upcoming version of FusionPro that makes this kind of text replacement much easier, but for now, you need to write a rule that takes the original field value and replaces the denoted text with something else. So you could make a rule named "Copy" that does this:

return ReplaceSubstring(Field("Copy"), "[COMMUNITY NAME]", "Your community name here");

Or, you could add this line to OnRecordStart:

FusionPro.Composition.AddVariable("Copy", ReplaceSubstring(Field("Copy"), "[COMMUNITY NAME]", "Your community name here"));

Or, if you want to replace that text with another field value:

FusionPro.Composition.AddVariable("Copy", ReplaceSubstring(Field("Copy"), "[COMMUNITY NAME]", Field("CommunityName")));

Though, as I said, with the data you posted, that's still going to put just "[Community Name]" in the output, since that's the value in that field.

 

Anyway, I'm still not sure what this has to do with your original question about "two fonts." Where do you want two different fonts applied as part of this?

Link to comment
Share on other sites

Thanks for posting the template.

 

 

Anyway, I'm still not sure what this has to do with your original question about "two fonts." Where do you want two different fonts applied as part of this?

 

Hey Dan,

 

Thanks for that [Community Name] explanation...very helpful! Reason we add value this way is so the user can put the name of their Community Name inside our provided copy. This is a variable template not specific to any community. Hope i'm explaining it right.

 

Now, the font in the header 'Join us for' (first line) and second line 'CINCO DE MAYO' are two different fonts. When I add text to the text editor and select those two lines and insert <header> it changes both of those lines of text to the first font :/.

 

Thanks,

Link to comment
Share on other sites

Thanks for that [Community Name] explanation...very helpful! Reason we add value this way is so the user can put the name of their Community Name inside our provided copy. This is a variable template not specific to any community. Hope i'm explaining it right.

Yes, every FusionPro template is a variable template.

Now, the font in the header 'Join us for' (first line) and second line 'CINCO DE MAYO' are two different fonts. When I add text to the text editor and select those two lines and insert <header> it changes both of those lines of text to the first font :/.

I see. It's not that the text 'CINCO DE MAYO' is in a data field, and the rest is static. It's that the entire string "Join us for CINCO DE MAYO!" is in a variable data field, and you're trying to typeset parts of that data field into different fonts.

 

Although:

  • I'm not sure how anyone would have known that from the original screenshots you posted.
  • What you're asking about now with the data field whose contents are "Join us for CINCO DE MAYO!" doesn't seem to have much to do with the question in your original post, where you said you were "Working on a postcard and the field EventHeader has 2 fonts and a variable spot to enter [Community Name]"
  • It's not at all obvious from the template you posted either, because you have one record where that text is all in white against a white background because there's no graphic behind it, and another record where that data field value is the text "Image".

 

Anyway, the short answer is that you can use <f name="***"> tags (with font names the same as shown in the Text Editor) to change fonts, as detailed in the Tags Reference Guide.

 

For example:

return '<f name="Avenir Light">Join us for <f name="Garamond BE Bold">CINCO DE MAYO!';

Or, you can use the ending </f> tag to put only a selected portion of the text in a particular font, and let the rest be defined by the font selected for the variable in the Text Editor:

return '<f name="Avenir Light">Join us for </f>CINCO DE MAYO!';

Or just apply a font to the other part of the text:

return 'Join us for <f name="Garamond BE Bold">CINCO DE MAYO!';

But I think now you see the problem. How do you program the rule to know exactly which substring of that entire text to apply a particular font to? You can write a rule to divide it up however you want. For instance, you could tell it to put just the first three words in a different font:

var words = Field("Header").split(/\s/);
return words.slice(0,3).join(' ') + '<f name="Garamond BE Bold">' + words.slice(3).join(' ');

But since this is a variable data field, you can't rely on it always following that pattern. Other algorithms are possible, but they have the same problem: A computer can't figure everything out, especially something like where to break up the text into ranges with different fonts, which is ultimately an artistic design decision that a human has to make on a case-by-case basis. This is the challenge of variable data typesetting (and not just in FusionPro): A graphic designer may have an idea of how to set everything down just so for particular cases, but that design intent is not always perfectly applicable to other variations.

 

So the real answer to your question is: You should have the parts of the text that need to be in different fonts in separate data fields. Then you don't need to try to write JavaScript code to have the computer try to make what should be an artistic design decision.

 

The thing is, you really need a data field (presumably named "Event Name") that just has the event name by itself, i.e. "CINCO DE MAYO" or whatever. Then you can just select insert that variable into the Text Editor, separately from the other "Join us for" text (which can itself either be hard-coded in the Text Editor or called out from another variable), and set each part in its own font, without writing any code at all.

 

Or, you could follow your pattern of using other variables inside your data fields. For instance, your "Header" data field can be something like "Join us for [Event Name]!", and your "Header" rule can do something like this:

return ReplaceSubstring(TaggedDataField("Header"), "[Event Name]",
    '<f name="Garamond BE Bold">' + TaggedDataField("Event Name"));

Edited by Dan Korn
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...