Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const letter = letters[i];
const charCode = parseInt(letter.getAttribute('id'), 10);
const page = letter.getAttribute('page') || 0;
const textureRect = new Rectangle(
(parseInt(letter.getAttribute('x'), 10) / res) + (pagesTextures[page].frame.x / res),
(parseInt(letter.getAttribute('y'), 10) / res) + (pagesTextures[page].frame.y / res),
parseInt(letter.getAttribute('width'), 10) / res,
parseInt(letter.getAttribute('height'), 10) / res
);
data.chars[charCode] = {
xOffset: parseInt(letter.getAttribute('xoffset'), 10) / res,
yOffset: parseInt(letter.getAttribute('yoffset'), 10) / res,
xAdvance: parseInt(letter.getAttribute('xadvance'), 10) / res,
kerning: {},
texture: new Texture(pagesTextures[page].baseTexture, textureRect),
page,
};
}
// parse kernings
const kernings = xml.getElementsByTagName('kerning');
for (let i = 0; i < kernings.length; i++)
{
const kerning = kernings[i];
const first = parseInt(kerning.getAttribute('first'), 10) / res;
const second = parseInt(kerning.getAttribute('second'), 10) / res;
const amount = parseInt(kerning.getAttribute('amount'), 10) / res;
if (data.chars[second])
{
Math.floor(rect.h) / this.resolution
);
}
// Check to see if the sprite is trimmed
if (data.trimmed !== false && data.spriteSourceSize)
{
trim = new Rectangle(
Math.floor(data.spriteSourceSize.x) / this.resolution,
Math.floor(data.spriteSourceSize.y) / this.resolution,
Math.floor(rect.w) / this.resolution,
Math.floor(rect.h) / this.resolution
);
}
this.textures[i] = new Texture(
this.baseTexture,
frame,
orig,
trim,
data.rotated ? 2 : 0,
data.anchor
);
// lets also add the frame to pixi's global cache for 'from' and 'fromLoader' functions
Texture.addToCache(this.textures[i], i);
}
frameIndex++;
}
}
const letter = letters[i];
const charCode = parseInt(letter.getAttribute('id'), 10);
const page = letter.getAttribute('page') || 0;
const textureRect = new Rectangle(
(parseInt(letter.getAttribute('x'), 10) / res) + (pagesTextures[page].frame.x / res),
(parseInt(letter.getAttribute('y'), 10) / res) + (pagesTextures[page].frame.y / res),
parseInt(letter.getAttribute('width'), 10) / res,
parseInt(letter.getAttribute('height'), 10) / res
);
data.chars[charCode] = {
xOffset: parseInt(letter.getAttribute('xoffset'), 10) / res,
yOffset: parseInt(letter.getAttribute('yoffset'), 10) / res,
xAdvance: parseInt(letter.getAttribute('xadvance'), 10) / res,
kerning: {},
texture: new Texture(pagesTextures[page].baseTexture, textureRect),
page,
};
}
// parse kernings
const kernings = xml.getElementsByTagName('kerning');
for (let i = 0; i < kernings.length; i++)
{
const kerning = kernings[i];
const first = parseInt(kerning.getAttribute('first'), 10) / res;
const second = parseInt(kerning.getAttribute('second'), 10) / res;
const amount = parseInt(kerning.getAttribute('amount'), 10) / res;
if (data.chars[second])
{