• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

style.setFont overrides sourceText.split.join

Explorer ,
Apr 26, 2024 Apr 26, 2024

Copy link to clipboard

Copied

Hey all! I have the following expression in a template:

comp("_CHANGE_LANGUAGE_HERE_").layer("Story01_End").text.sourceText.split("§").join("\r");
text.sourceText.style.setFont("Oswald-Bold");

 

The first part grabs a text from a tsv file, selects a language using a dropdown and adds line breaks based on the "§" symbols in that text. That works fine. We've recently added a new language that requres a different font (Omnes vs OmnesGreek, both from Adobe Fonts), because it can't display the greek letters. 

So I'm planning to change the font to the Greek version, if the dropdown "GR" is selected. However, as a basic proof of concept I'm trying it without any of that logic here, just trying to override the font panel font with the new font (in the example Oswald-Bold is selected, that's a copy error but I can't edit the code snippet, ignore that). 

But this doesn't work. With the first bit of code, I can change the language and it supplies the text from the tsv. As soon as I add the setFont line, it changes the font – but reverts the text to the default content of the text box, which is simply empty. 

Am I combining these wrong? This should be possible, right?

(If I place the setFont line first, it just does nothing at all)

M
Thank you!

TOPICS
Error or problem , Experiment , Expressions , Scripting

Views

55

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 26, 2024 Apr 26, 2024

I haven't tested this, but try it this way:

 

txt = comp("_CHANGE_LANGUAGE_HERE_").layer("Story01_End").text.sourceText.split("§").join("\r");
text.sourceText.style.setFont("Oswald-Bold").setText(txt);

 

Votes

Translate

Translate
Community Expert ,
Apr 26, 2024 Apr 26, 2024

Copy link to clipboard

Copied

I haven't tested this, but try it this way:

 

txt = comp("_CHANGE_LANGUAGE_HERE_").layer("Story01_End").text.sourceText.split("§").join("\r");
text.sourceText.style.setFont("Oswald-Bold").setText(txt);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 26, 2024 Apr 26, 2024

Copy link to clipboard

Copied

LATEST

It does! Thanks a bunch and have a happy weekend 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines