Graphics

 View Only
  • 1.  Set Font Material

    Posted 07-31-2019 04:41

    I need to change font materials, and can't seem to figure out how to do it.

    I have two team fonts: Team1Font, Team2Font.

    I get that I can use tags, so when I'm setting something for team 1, I can use:

    textObject.TextWithTags = "{Team1Font}" & my_text_value

    That changes the font; however, every team has a different color; I'm only using two at a time, and the interface I'm building around the current project needs to be very dynamic/generic, so I can't realistically duplicate the same font and edit all the colors by hand, and have Team<N>Font.  The color comes from a spreadsheet - each team has, among other things, a text color given in the data in the spreadsheet.

    So I update materials: Team1Color and Team2Color, and I know that works because I can have that material applied to different things, like quads, and I can see it work, but would like to just apply those materials to Team1Font and Team2Font (respectively), and can't seem to find a way.  The API also doesn't have a way to set a font's material directly, at least not that I can tell.

    I did my searching, and found this post: https://support.rossvideo.com/hc/en-us/community/posts/360043355312-XPression-Font-Materials

    The response from Garner seems to indicate I CAN set the font material from my material library somehow, but I can't figure it out.  If I could, in the editor, just tell Team1Font to use Team1Color, and then script in where that Team1Color (a material) gets updated with the new color, theoretically it should work, but I don't see how to do it.

    Again, this is not how to select different fonts - it's how to update a given font's material through scripting - either directly (by accessing the font's material directly), or indirectly (by setting the font's material to something in my material library, then updating that material).

    Thanks.

    EDIT: Oh, I also know I can apply the material to the text object itself, but that doesn't seem to work - it always seems to use what was there before.  In the editor, you either need to set the material first, or highlight the text to set the material.



  • 2.  RE: Set Font Material

    Posted 07-31-2019 05:16

    I figured it out.... it would be nice to select a material from the library, but this works... you need to get the face attribute (the color is coming in as a comma separated list of RGB values):

    dim values() = split(Text, ",")
    if Engine.GetFontByName("Team" & item & "Font", font) then
    if font.GetLayerAttribByName("Face", font_attr) then
    if font_attr.GetMaterial(mat) then
    mat.ColorAmbient.Update(0, 0, 0, 0)
    mat.ColorDiffuse.Update(0, 0, 0, 0)
    mat.ColorSpecular.Update(0, 0, 0, 0)
    mat.ColorEmissive.Update(Cint(values(0)), Cint(values(1)), Cint(values(2)), 255)
    end if
    end if
    end if



    #XPression


  • 3.  RE: Set Font Material

    Posted 07-31-2019 15:29

    Hello Frederick,

    You can see the material name that is assigned to a font from the "edit material" button in the scene fonts settings.

    You can change the default material name so it will be easier to retrieve.

    Then you can access it directly with Engine.GetMaterialByName(...) function as you would do with a material from the library.

     

    Font materials can be manipulated with Visual Logic too :

    Here "MaterialFaceFont1" is the name of the material that was assigned to the font face

    Hope it helps

     


    #XPression


  • 4.  RE: Set Font Material

    Posted 08-06-2019 17:36

    There is an even easier option with visual logic.  The screen shot below is an excerpt from a logic tree controlling font color change in a highlight state.  CAT in this instance is short form for category.  Depending on your needs, this might be easier, and you can use pretty much anything to drive the input selector,.

     


    #XPression