Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

55
Vistas
Calculate the font size of a string to make it fit on a box

In After Effects, I have a string, I have a TypeFace, I have the width and height of a composition. How do I get the right font size to fit the string on the comp, without overflowing?

Noobie programmer here.

7 months ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You could calculate the pixel size however (again) Adobe restricts the size to 1296 Px. So you need to go by scale of your text layer.

In scale parameter of the text add following expression:

var myTextSize = sourceRectAtTime();
var ratio = myTextSize.width / myTextSize.height;
var compRatio = thisComp.width/thisComp.height;
if(ratio >= compRatio) {
    var factor = thisComp.width / myTextSize.width;
    [scale[0] * factor, scale[1] * factor]
}
else{
    var factor = thisComp.height / myTextSize.height;
    [scale[0] * factor, scale[1] * factor]
}

This expression scales the text depending on width and height of your comp.

However it is still not centered. If you want that, you need to add another expression. This time on your anchorpoint:

var boundingbox = sourceRectAtTime();
 
[boundingbox.left + boundingbox.width/2, boundingbox.top + boundingbox.height/2 ];

This should do the trick.

7 months ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.