MCPcopy Index your code
hub / github.com/plotly/plotly.js / getGlyph

Function getGlyph

stackgl_modules/index.js:19337–19406  ·  view source on GitHub ↗
(symbol, font, pixelRatio)

Source from the content-addressed store, hash-verified

19335var GLYPH_CACHE = {}
19336
19337function getGlyph(symbol, font, pixelRatio) {
19338 var fontKey = [
19339 font.style,
19340 font.weight,
19341 font.variant,
19342 font.family
19343 ].join('_')
19344
19345 var fontCache = GLYPH_CACHE[fontKey]
19346 if(!fontCache) {
19347 fontCache = GLYPH_CACHE[fontKey] = {}
19348 }
19349 if(symbol in fontCache) {
19350 return fontCache[symbol]
19351 }
19352
19353 var config = {
19354 textAlign: "center",
19355 textBaseline: "middle",
19356 lineHeight: 1.0,
19357 font: font.family,
19358 fontStyle: font.style,
19359 fontWeight: font.weight,
19360 fontVariant: font.variant,
19361 lineSpacing: 1.25,
19362 styletags: {
19363 breaklines:true,
19364 bolds: true,
19365 italics: true,
19366 subscripts:true,
19367 superscripts:true
19368 }
19369 }
19370
19371 //Get line and triangle meshes for glyph
19372 config.triangles = true
19373 var triSymbol = vectorizeText(symbol, config)
19374 config.triangles = false
19375 var lineSymbol = vectorizeText(symbol, config)
19376
19377 var i, j
19378
19379 if(pixelRatio && pixelRatio !== 1) {
19380 for(i = 0; i < triSymbol.positions.length; ++i){
19381 for(j = 0; j < triSymbol.positions[i].length; ++j){
19382 triSymbol.positions[i][j] /= pixelRatio;
19383 }
19384 }
19385
19386 for(i = 0; i < lineSymbol.positions.length; ++i){
19387 for(j = 0; j < lineSymbol.positions[i].length; ++j){
19388 lineSymbol.positions[i][j] /= pixelRatio;
19389 }
19390 }
19391 }
19392
19393 //Calculate bounding box
19394 var bounds = [[Infinity,Infinity], [-Infinity,-Infinity]]

Callers 1

get_glyphDataFunction · 0.85

Calls 1

vectorizeTextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…