Encuesta de investigación: Cuéntanos sobre tu experiencia con Blockly
Comenzar encuesta
blockly > utiles > dom > getFastTextWidth
Función utils.dom.getFastTextWidth()
Obtiene el ancho de un elemento de texto con un método más rápido que getTextWidth
. Este método requiere que conozcamos con anticipación la familia de fuentes y el tamaño del elemento de texto. Al igual que getTextWidth
, almacenamos en caché el ancho que calculamos.
Signature:
export declare function getFastTextWidth(textElement: SVGTextElement, fontSize: number, fontWeight: string, fontFamily: string): number;
Parámetros
Parámetro |
Tipo |
Descripción |
textElement |
SVGTextElement |
Un "texto" SVG . |
fontSize |
número |
Tamaño de fuente que se usará. |
fontWeight |
string |
Es el grosor de la fuente que se usará. |
fontFamily |
string |
La familia de fuentes que se utilizará. |
Muestra:
número
Es el ancho del elemento.
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2024-09-12 (UTC)
[null,null,["Última actualización: 2024-09-12 (UTC)"],[[["`utils.dom.getFastTextWidth` calculates the width of an SVG text element more quickly than `getTextWidth` by pre-requiring font information and caching results."],["The function requires the SVG text element, font size, font weight, and font family as input to calculate and return the element's width."]]],["The `getFastTextWidth` function calculates the width of an SVG text element more quickly than `getTextWidth`. It requires the text element, its font size, weight, and family as inputs. The function takes an SVG `text` element, `fontSize` (number), `fontWeight` (string), and `fontFamily` (string). It returns the element's width as a number, caching computed widths for efficiency.\n"]]