/// <summary>
        /// Fill Vertex Buffers for Sprites
        /// </summary>
        /// <param name="i"></param>
        /// <param name="generationSettings"></param>
        /// <param name="textInfo"></param>
        public static void FillSpriteVertexBuffers(int i, TextGenerationSettings generationSettings, TextInfo textInfo)
        {
            int materialIndex = textInfo.textElementInfo[i].materialReferenceIndex;
            int indexX4       = textInfo.meshInfo[materialIndex].vertexCount;

            TextElementInfo[] textElementInfoArray = textInfo.textElementInfo;
            textInfo.textElementInfo[i].vertexIndex = indexX4;

            // Handle potential axis inversion
            if (generationSettings.inverseYAxis)
            {
                Vector3 axisOffset;
                axisOffset.x = 0;
                axisOffset.y = generationSettings.screenRect.y + generationSettings.screenRect.height;
                axisOffset.z = 0;

                Vector3 position = textElementInfoArray[i].vertexBottomLeft.position;
                position.y *= -1;

                textInfo.meshInfo[materialIndex].vertices[0 + indexX4] = position + axisOffset;
                position    = textElementInfoArray[i].vertexTopLeft.position;
                position.y *= -1;
                textInfo.meshInfo[materialIndex].vertices[1 + indexX4] = position + axisOffset;
                position    = textElementInfoArray[i].vertexTopRight.position;
                position.y *= -1;
                textInfo.meshInfo[materialIndex].vertices[2 + indexX4] = position + axisOffset;
                position    = textElementInfoArray[i].vertexBottomRight.position;
                position.y *= -1;
                textInfo.meshInfo[materialIndex].vertices[3 + indexX4] = position + axisOffset;
            }
            else
            {
                textInfo.meshInfo[materialIndex].vertices[0 + indexX4] = textElementInfoArray[i].vertexBottomLeft.position;
                textInfo.meshInfo[materialIndex].vertices[1 + indexX4] = textElementInfoArray[i].vertexTopLeft.position;
                textInfo.meshInfo[materialIndex].vertices[2 + indexX4] = textElementInfoArray[i].vertexTopRight.position;
                textInfo.meshInfo[materialIndex].vertices[3 + indexX4] = textElementInfoArray[i].vertexBottomRight.position;
            }

            // Setup UVS0
            textInfo.meshInfo[materialIndex].uvs0[0 + indexX4] = textElementInfoArray[i].vertexBottomLeft.uv;
            textInfo.meshInfo[materialIndex].uvs0[1 + indexX4] = textElementInfoArray[i].vertexTopLeft.uv;
            textInfo.meshInfo[materialIndex].uvs0[2 + indexX4] = textElementInfoArray[i].vertexTopRight.uv;
            textInfo.meshInfo[materialIndex].uvs0[3 + indexX4] = textElementInfoArray[i].vertexBottomRight.uv;

            // Setup UVS2
            textInfo.meshInfo[materialIndex].uvs2[0 + indexX4] = textElementInfoArray[i].vertexBottomLeft.uv2;
            textInfo.meshInfo[materialIndex].uvs2[1 + indexX4] = textElementInfoArray[i].vertexTopLeft.uv2;
            textInfo.meshInfo[materialIndex].uvs2[2 + indexX4] = textElementInfoArray[i].vertexTopRight.uv2;
            textInfo.meshInfo[materialIndex].uvs2[3 + indexX4] = textElementInfoArray[i].vertexBottomRight.uv2;

            // setup Vertex Colors
            textInfo.meshInfo[materialIndex].colors32[0 + indexX4] = textElementInfoArray[i].vertexBottomLeft.color;
            textInfo.meshInfo[materialIndex].colors32[1 + indexX4] = textElementInfoArray[i].vertexTopLeft.color;
            textInfo.meshInfo[materialIndex].colors32[2 + indexX4] = textElementInfoArray[i].vertexTopRight.color;
            textInfo.meshInfo[materialIndex].colors32[3 + indexX4] = textElementInfoArray[i].vertexBottomRight.color;

            textInfo.meshInfo[materialIndex].vertexCount = indexX4 + 4;
        }
        // Function to offset vertices position to account for line spacing changes.
        public static void AdjustLineOffset(int startIndex, int endIndex, float offset, TextInfo textInfo)
        {
            Vector3 vertexOffset = new Vector3(0, offset, 0);

            for (int i = startIndex; i <= endIndex; i++)
            {
                textInfo.textElementInfo[i].bottomLeft  -= vertexOffset;
                textInfo.textElementInfo[i].topLeft     -= vertexOffset;
                textInfo.textElementInfo[i].topRight    -= vertexOffset;
                textInfo.textElementInfo[i].bottomRight -= vertexOffset;

                textInfo.textElementInfo[i].ascender  -= vertexOffset.y;
                textInfo.textElementInfo[i].baseLine  -= vertexOffset.y;
                textInfo.textElementInfo[i].descender -= vertexOffset.y;

                if (textInfo.textElementInfo[i].isVisible)
                {
                    textInfo.textElementInfo[i].vertexBottomLeft.position  -= vertexOffset;
                    textInfo.textElementInfo[i].vertexTopLeft.position     -= vertexOffset;
                    textInfo.textElementInfo[i].vertexTopRight.position    -= vertexOffset;
                    textInfo.textElementInfo[i].vertexBottomRight.position -= vertexOffset;
                }
            }
        }
        /// <summary>
        /// Store vertex attributes into the appropriate TMP_MeshInfo.
        /// </summary>
        /// <param name="i"></param>
        /// <param name="generationSettings"></param>
        /// <param name="textInfo"></param>
        public static void FillCharacterVertexBuffers(int i, TextGenerationSettings generationSettings, TextInfo textInfo)
        {
            int materialIndex = textInfo.textElementInfo[i].materialReferenceIndex;
            int indexX4       = textInfo.meshInfo[materialIndex].vertexCount;

            // Check to make sure our current mesh buffer allocations can hold these new Quads.
            if (indexX4 >= textInfo.meshInfo[materialIndex].vertices.Length)
            {
                textInfo.meshInfo[materialIndex].ResizeMeshInfo(Mathf.NextPowerOfTwo((indexX4 + 4) / 4));
            }

            TextElementInfo[] textElementInfoArray = textInfo.textElementInfo;
            textInfo.textElementInfo[i].vertexIndex = indexX4;

            // Setup Vertices for Characters
            if (generationSettings.inverseYAxis)
            {
                Vector3 axisOffset;
                axisOffset.x = 0;
                axisOffset.y = generationSettings.screenRect.y + generationSettings.screenRect.height;
                axisOffset.z = 0;

                Vector3 position = textElementInfoArray[i].vertexBottomLeft.position;
                position.y *= -1;

                textInfo.meshInfo[materialIndex].vertices[0 + indexX4] = position + axisOffset;
                position    = textElementInfoArray[i].vertexTopLeft.position;
                position.y *= -1;
                textInfo.meshInfo[materialIndex].vertices[1 + indexX4] = position + axisOffset;
                position    = textElementInfoArray[i].vertexTopRight.position;
                position.y *= -1;
                textInfo.meshInfo[materialIndex].vertices[2 + indexX4] = position + axisOffset;
                position    = textElementInfoArray[i].vertexBottomRight.position;
                position.y *= -1;
                textInfo.meshInfo[materialIndex].vertices[3 + indexX4] = position + axisOffset;
            }
            else
            {
                textInfo.meshInfo[materialIndex].vertices[0 + indexX4] = textElementInfoArray[i].vertexBottomLeft.position;
                textInfo.meshInfo[materialIndex].vertices[1 + indexX4] = textElementInfoArray[i].vertexTopLeft.position;
                textInfo.meshInfo[materialIndex].vertices[2 + indexX4] = textElementInfoArray[i].vertexTopRight.position;
                textInfo.meshInfo[materialIndex].vertices[3 + indexX4] = textElementInfoArray[i].vertexBottomRight.position;
            }

            // Setup UVS0
            textInfo.meshInfo[materialIndex].uvs0[0 + indexX4] = textElementInfoArray[i].vertexBottomLeft.uv;
            textInfo.meshInfo[materialIndex].uvs0[1 + indexX4] = textElementInfoArray[i].vertexTopLeft.uv;
            textInfo.meshInfo[materialIndex].uvs0[2 + indexX4] = textElementInfoArray[i].vertexTopRight.uv;
            textInfo.meshInfo[materialIndex].uvs0[3 + indexX4] = textElementInfoArray[i].vertexBottomRight.uv;

            // Setup UVS2
            textInfo.meshInfo[materialIndex].uvs2[0 + indexX4] = textElementInfoArray[i].vertexBottomLeft.uv2;
            textInfo.meshInfo[materialIndex].uvs2[1 + indexX4] = textElementInfoArray[i].vertexTopLeft.uv2;
            textInfo.meshInfo[materialIndex].uvs2[2 + indexX4] = textElementInfoArray[i].vertexTopRight.uv2;
            textInfo.meshInfo[materialIndex].uvs2[3 + indexX4] = textElementInfoArray[i].vertexBottomRight.uv2;

            // setup Vertex Colors
            textInfo.meshInfo[materialIndex].colors32[0 + indexX4] = textElementInfoArray[i].vertexBottomLeft.color;
            textInfo.meshInfo[materialIndex].colors32[1 + indexX4] = textElementInfoArray[i].vertexTopLeft.color;
            textInfo.meshInfo[materialIndex].colors32[2 + indexX4] = textElementInfoArray[i].vertexTopRight.color;
            textInfo.meshInfo[materialIndex].colors32[3 + indexX4] = textElementInfoArray[i].vertexBottomRight.color;

            textInfo.meshInfo[materialIndex].vertexCount = indexX4 + 4;
        }