Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
How to output the fontsize in .jsx

I have a .jsx file. The code is below.

What I want: I want to display a multiline text in the group : #someGroup.

My approach: I have inserted an empty <rect> as orientation where the text should be. So I know where to place the text in my svg.

<tspan> only starts at a defined coordinate. As far as I know there is no function that breaks the text after a certain number of characters.

My problem: Now I want to write a function myself which breaks the text after a certain length and inserts a new line in the form of <tspan> (as far as I know it only works with this), only a little further down.

I just can't figure out how to access the size of the respective font size.

With this, I would see how much % of the respective text fit into the first lines and then, if necessary, start a new line at a space.

With friendly greetings

How I return it:

<svg>
    ...
    <g id="someGroup">
    <rect id="someRect" x="296" y="51.3676"
    width="184" height="135.265" fill={"none"}/>
    <text id="testText" className={styles.testText}>
    {renderText}
    </text>
    </g>
    ... 
</svg>

/* The CSS: */

.testText{
    font-family: "Times New Roman", Times, serif;
    font-size: 17px;
    fill: black;
    letter-spacing: 0em;
}

My function (WIP)

function renderText(x,y fontsize ) {
    let message = `Please try another search term.`;
    return (
            <tspan x={"296"} y={"60"}>{message}</tspan>
    );
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda