Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Problem loading fonts via USS resource (2019.3.0a8)

Discussion in 'UI Toolkit' started by taylank, Jul 24, 2019.

  1. taylank

    taylank

    Joined:
    Nov 3, 2012
    Posts:
    182
    EDIT: Problem solved. I wasn't paying attention to the list of applied stylesheets in the debugger. Turns out my path for the stylesheet itself was wrong.

    I'm trying to load fonts via resource ("path") method in uss stylesheets and not having much luck.

    Here's my situation: I have a style class named fa-solid:
    .fa-solid {
    -unity-font: resource("FontAwesome/Solid.ttf");
    }

    This is supposed to find the font file under Resources/FontAwesome/Solid.tff. Except it can't. The path works with a Resources.Load<Font> call on the C# side but not with uss resource. I've tried it with and without file extension; makes no difference. Below is a screenshot of the UI element inspected with UIElements Debugger:

    upload_2019-7-24_8-55-36.png

    The element is assigned the correct class, but the font is still the default one.

    What am I doing wrong here? Am I misunderstanding how style class hierarchies work? Is uss resource busted?
     
    Last edited: Jul 24, 2019
  2. MattM_Unity

    MattM_Unity

    Unity Technologies

    Joined:
    Aug 18, 2017
    Posts:
    45
    Hello taylank!

    Have you try putting the entire path in your string?

    eg. -unity-font: resource("Assets/Editor/Resources/FontAwesome/Solid.ttf"); (or whatever your full path is).