Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
blockly > utils > dom > getFastTextWidth
utils.dom.getFastTextWidth() işlevi
getTextWidth
yönteminden daha hızlı bir yöntem kullanarak metin öğesinin genişliğini alır. Bu yöntem, metin öğesinin yazı tipi ailesini ve boyutunu önceden bilmemizi gerektirir. getTextWidth
işlevine benzer şekilde, hesapladığımız genişliği önbelleğe alırız.
İmza:
export declare function getFastTextWidth(textElement: SVGTextElement, fontSize: number, fontWeight: string, fontFamily: string): number;
Parametreler
Parametre |
Tür |
Açıklama |
textElement |
SVGTextElement |
SVG "metin" öğesine dokunun. |
fontSize |
sayı |
Kullanılacak yazı tipi boyutu. |
fontWeight |
dize |
Kullanılacak yazı tipi ağırlığı. |
fontFamily |
dize |
Kullanılacak yazı tipi ailesi. |
Şunu döndürür:
sayı
Öğenin genişliği.
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-25 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-07-25 UTC."],[],["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"]]