-- functions for calculating data for text from spritesheets


local function getStringWidth(text, sizeSet)
	local length, ntext = 0, #text;
	for i = 1, ntext do
		local i2 = i + 1 <= #text and i + 1;
		local b = byte(sub(text, i, i));
		local b2 = i2 and byte(sub(text, i2, i2));
		local character = sizeSet.characters[b];
		local kernx = 0
		if (b2 and sizeSet.kerning[b] and sizeSet.kerning[b][b2]) then
			kernx = sizeSet.kerning[b][b2].x;
		end;
		length = length + sizeSet.characters[b].xadvance + kernx;
	end;
	return length;
end;

local function getMaxHeight(text, sizeSet)
	local mheight, ntext = 0, #text;
	for i = 1, ntext do
		local b = byte(sub(text, i, i));
		local character = sizeSet.characters[b];
		local height = sizeSet.characters[b].height + sizeSet.characters[b].yoffset;
		if (height > mheight) then
			mheight = height;
		end;
	end;
	return mheight;
end;
