Hi,
"‹While the solution of @icingo44 is definitely a possibility, it might not always be practical to have to create two different textfields for every possible text that you might want to change the font for.
Let me give an example to clarify.
Imagine that you have to create a list of names (such as a starting list or a standingslist) that involves 10 players where you have to use a different font for the first and the last name.
Using the above suggestion could be a possibility but it would involve having to create 20 different textobjects. (10 for the first name and 10 for the last name)
On top of that, the length of the names are different so you would have to create additional Visual Logic to adjust the position of the textbox which holds the last name to make sure it follows the first name. All of this is doable but it's also a lot of work.
It would be easier to use just 10 textboxes and use multiple fonts inside this one textfield.
Luckily the guys at Ross have come up with a solution for this by using Font Tags.
Font tags are essentially a piece of text that tells XPression which font to use for a textfield. Font tags can be used in the Template Data-tab of the Sequencer but also in Visual Logic. However if you type them in your textfield in the Editor, they will not work.
If you have a font which is called Normal font and you have a font called Big font, you can assign the fonttags as such: {Normal font} and {Big font}.
So imagine that you put in your template data in the Sequencer the following text: {Normal font} This is normal text, but {Big font} this is big text
On the output you will see the text This is normal text, but this is big text but the "This is normal text, but " would be in the normal font and the "this is big text" would be in the big font. So XPression sees the font tags and interprets them and changes the font. This way, it becomes very easy to put a first name and a last name in the same textfield in two different fonts.
Now to go back to your question.
Below you will see a screenshot with visual logic which will do just what you asked.
Just a description of what block does what:
- the Length-block counts the number of characters in the text in Text1
"‹
- the Value on top of it is just used to determine after how many characters the text should change to the new font. I could also enter this value directly in the Greater Than-block but it's more clear when you put it in a separate Value-block.
- the Greater Than-block is used to compare the values against each other. So if the textlength is 10 or less characters, the output of the Greater Than-block will be 0. If the textlength is 11 or more characters long, the output of the Greater Than-block will be 1. This value will be used to determine which fonttag will be used in the text.
- the two String Value-blocks are used to specify which fonttags should be used. So for this example the value of the first block is {fntTest1} (which is the name of the Arial 18pt Medium White-font) and the value of the second block is {fntTest2} which is the name of the Georgia 48pt Bold Green-font. In the description of the String Value-block I also put the names of the font in so I could easily recognize them in the Visual Logic window.
- the Input Selector-block takes the output of the Greater Than-block (which is 0 or 1) and uses that value to determine which value to send to it's own output. So if the outcome of the Greater Than block is 0, the Input Selector will take whatever is in option [0] (which is the first String Value with the fonttag) and send it to the output. When the result of the Greater Than is 1, it will get the value of the String Value which is in option [1] and send that to the output of the Input Selector. So in this case the output of the Input Selector would be either {fntTest1} or {fntTest2}.
- the Concatenate-block is used to merge two (or more) textvalues together as one. So in this case I will get the output of the Input Selector (which is [LEFT]{fntTest1} or {fntTest2}[/LEFT]) and I will stitch the actual text of the textfield called Text1 after it. So the output of the Concatenate-block will be {fntTest1}This is the text of Text1 OR [LEFT][COLOR=#555555][FONT=Helvetica Neue][SIZE=13px]{fntTest2}This is the text of Text1.
- the TextWithTags-block is used to tell XPression that there could be fonttags in this text so he should interpret them. If you would use just the Text-block of Text1, then the text would actually say {fntTest1}This is the text of Text1 on screen. Using the TextWithTags you will only see This is the text of Text1 on the screen in the font determined by the Visual Logic.
So using FontTags, you can very easily use multiple fonts inside the same textobject or change the color of text depending on it's value (Think of stock exchange where loss could be shown in red, gain could be shown in green and equal could be shown in white) which makes this a very powerful tool.
I hope this was helpful.
Cheers,
Kenneth

#XPression