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

Font weight in number slider control

New Here ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

I have created a slider control to count down from "£20,000 remaining" to "0 remaining" however the font is in a bold weight but I would like the word "remaining' to be in a light weight. 

 

Here is my code:
"£" + effect("Slider Control")("Slider").value.toFixed(2)+" "+ "remaining"

 

Any ideas? New at expressions and coding!

Thanks

TOPICS
Expressions , How to

Views

122

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 , Sep 12, 2023 Sep 12, 2023

You can currently get.styleAt(Character Index, Time), but you cannot set.styleAt(Character index. time). It is currently a feature request, but it has not yet been implemented.

 

The best option would be to use two text layers and sourceRectAtTime() to line up the remaining text layer with the text layer containing the number string controlled by the slider. If the top layer is the counter and it is right justified, the bottom layer is the Remaining layer, and the baseline shift for both layers

...

Votes

Translate

Translate
Community Expert ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

You can currently get.styleAt(Character Index, Time), but you cannot set.styleAt(Character index. time). It is currently a feature request, but it has not yet been implemented.

 

The best option would be to use two text layers and sourceRectAtTime() to line up the remaining text layer with the text layer containing the number string controlled by the slider. If the top layer is the counter and it is right justified, the bottom layer is the Remaining layer, and the baseline shift for both layers is the same, something like this expression for Position on the bottom layer will work:

 

ref = thisComp.layer(index - 1);
p = ref.position;
refSize = ref.sourceRectAtTime();
w = refSize.width + refSize.left;
pad = text.sourceText.getStyleAt(1, 0).fontSize * .6;
[p[0] + w + pad, p[1]]

 

You can change the multiplier on the pad variable. Sixty percent (* .6) is a good starting value for most fonts. 

RickGerard_0-1694555006811.png

 

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
New Here ,
Sep 13, 2023 Sep 13, 2023

Copy link to clipboard

Copied

LATEST

Thanks thats done the trick, appreciate the help!

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