Graphics

 View Only
  • 1.  Font assignment through Visual Logic?

    Posted 02-08-2019 18:30
    Is it possible to use Visual Logic to assign a font to a text object based on another parameter? Not the face material, I figured that out, but a complete font change? Say Font 1 is 18pt Arial Medium white and Font 2 is 48pt Georgia Bold green (hideous as that sounds). Can I apply Font 1 if, say, text length is greater than 10, Font 2 if less?


  • 2.  RE: Font assignment through Visual Logic?

    Posted 02-08-2019 20:58
    You could try having separate text layers with the font attached to them, that toggle themselves on or off depending on the length of the text in say, field one.

    You could then have the text that is in field one, to equal the text in however many additional field you'd like to make.

    I'd just stack them in the same place on the scene.

    If that is something that could possibly work for you, I could try to make it work in the logic editor. Shouldn't be too hard.
    #XPression


  • 3.  RE: Font assignment through Visual Logic?

    Posted 02-08-2019 21:30

    The logic would look something like this. Though, it could probably be done cleaner and even more simplistic. That's the thing I like about this program.

    Got it to work on my end with those three text layers. All you would need to do is adjust the pivot points!

    All three layers had different fonts and they became visible as needed, with only one text field needed to be published. (small, in this case.)

    *ignore that top right block of logic, I forgot to delete it after I made the "and" clause portion*


    #XPression


  • 4.  RE: Font assignment through Visual Logic?

    Posted 02-10-2019 20:32

    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


  • 5.  RE: Font assignment through Visual Logic?

    Posted 02-11-2019 01:08
    In addition to font tags, if you simply want to change the color of the text, you can use "Material Tags". Create materials in any colors you want and name them.. Then you can use a tag like {M:Red} where "Red" is the name of a material, and this will change the text following the tag to that color. This avoids the need to create a bunch of copies of the same font in different colors.

    #XPression


  • 6.  RE: Font assignment through Visual Logic?

    Posted 02-11-2019 23:11
    Kenneth,

    Thanks for that thorough explanation! I'll give that a spin and let you know how it goes. I look forward to basking in (stolen) glory. "Yeah, I totally figured that out all by myself!"
    #XPression


  • 7.  RE: Font assignment through Visual Logic?

    Posted 02-12-2019 16:42
    After some trial and error, got this to work, although {fntTEXTNAME} did not work. Just using the font ID number in curly brackets {1} did, seemingly even without the textwithtags block. Unless that's a dangerous habit to get into.
    #XPression


  • 8.  RE: Font assignment through Visual Logic?

    Posted 02-12-2019 18:02
    Hey moviesign,
    The {ID} works fine, it'sjust a bit more difficult because you have to lookup the ID all the time.
    However, the {NameOfTheFont} should work fine.

    Just to clarify, the name of the font that I used was fntTest1 and fntTest2. I might have confused you by using a name that starts with fnt, so it's just the curly brackets and inside the name of the font.

    Cheers,
    Kenneth

    #XPression


  • 9.  RE: Font assignment through Visual Logic?

    Posted 02-12-2019 18:20
    @cainnech Ah... that's where I went wrong. I thought the "fnt" was part of the tag code for the font named Test1, especially since the XpressionU tutorial about material tags used {M:MATERIALNAME} to assign materials in the Static tab. Thanks for the clarification!
    #XPression