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
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
...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.
Copy link to clipboard
Copied
Thanks thats done the trick, appreciate the help!
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?