Determine Pixel Length of Text String
Mostrar comentarios más antiguos
Hi Guys,
I was wondering if there was a way to determine the pixel length for a given text? I know there is a way to do this once a text object has been created on a graph etc., but I am particular looking for a way to do this without having to even create an object. That way I would know what the bounding box size would have to be.
Thanks
2 comentarios
Matt Kindig
el 1 de Jul. de 2013
This question doesn't make sense to me. Fonts are usually defined in terms of Bezier curves, which by definition are vectorized and thus can be rendered at any scale. So the pixel representation of the text string isn't defined until it is a rendered, and the number of pixels will of course depend on the font size. I'm not exactly sure what you are asking to do.
Nitin
el 1 de Jul. de 2013
an example of what you are trying to achieve would probably make it easier..
Respuesta aceptada
Más respuestas (1)
Jasper van Casteren
el 10 de Mayo de 2017
3 votos
The answers seem to miss the point. Often, to make a nice app dialog, you want to set the width of text boxes to the largest width. So you would have to find the size of a text in pixels if you cannot design your whole dialog in character units (which is often the case). So, the question is not whether you need to render before you know it, but whether there is a "quite" renderer that does the rendering but only returns the size of the box, without actually displaying something.
Categorías
Más información sobre Labels and Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!