private void DrawTextAlignRight(IList<byte[]> lines, Rectangle r,
            G3Font font, G3Color fontColor, G3Color haloColor)
        {
            int x = r.X + r.Width - 1;
            int y = r.Y + (r.Height / 2);

            y = y - ((font.FontHeight * lines.Count) / 2);
            y = y + (font.FontHeight / 2);

            foreach (var l in lines)
            {
                int w = font.TextWidth(l) / 2;

                if (r.Contains(x, y - (font.FontHeight / 2)) && r.Contains(x, y + (font.FontHeight / 2)))
                    _DrawTextC(l, font, x - w - 1, y, fontColor, haloColor);

                y = y + font.FontHeight;
            }
        }
        public void _DrawTextC(byte[] encodedByteCharArray, G3Font font, int X1, int Y1,
            G3Color fontColor, G3Color haloColor)
        {
            if (encodedByteCharArray == null || font == null)
                return;

            // half width
            float offset = X1 - (font.TextWidth(encodedByteCharArray) / 2f);

            for (int k = 0; k < encodedByteCharArray.Length; k++)
            {
                byte byteChar = encodedByteCharArray[k];

                if (k == 0)
                {
                    offset += (font.Chars[byteChar].width / 2f);
                }
                else
                {
                    offset += (font.Chars[encodedByteCharArray[k - 1]].width / 2f);
                    offset += ((font.Chars[byteChar].width + font.SpaceBetweenChars) / 2f);
                }

                if (byteChar != 32)
                    PutChar0(byteChar, (int)offset, Y1, font, fontColor, haloColor);
            }
        }