• 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

406

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

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
Community Beginner ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

I need to do the same with a % counter where the numbers are rounded to whole numbers. The slider control increases the % number and the line below it using trim paths.

Could you explain in more detail how i can turn that % into a thinner font using the code below? 

Thanks

 

Screenshot 2024-09-25 at 10.29.25.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
Community Beginner ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

 

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
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

The easiest way to make the % a thinner font would be to use a second text layer and tie it to the position of the first layer with sourceRectAtTime(). My first reply gives you the solution to that problem.

 

To make the underline fit the text, it is more efficient to use the Create Nulls From Paths/points follow nulls script from the Window Menu and tie the position of the end of the line null to the width of the combined text layers using sourceRectAtTime(). I don't have time to write that expression for you right now.

 

The problem with using Trim Paths is that you would have to calculate the length of the original line and then come up with a percentage of that length based on the total width of the text. The math and the expression would be a lot more complicated. 

 

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
Community Beginner ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

LATEST

Thanks for your reply Rick. I actually couldnt get the first part to worth either. Doy ou put the code on both layers of text?

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