Exemple #1
0
        private void drawText(SSText text, SKCanvas canvas)
        {
            var        lineNum    = 0;
            float      textheight = getTextHeight(text);
            SSPosition startPoint = PositionHelper.getPosition(text.alignX, text.alignY, 0, textheight, canvasSize);
            SSPosition position   = startPoint;

            foreach (SSLine line in text.lines)
            {
                LineProps lineProps = calculateLineProps(line);
                if (text.alignX.style == AlignKeys.Center)
                {
                    position.x -= (lineProps.width / 2);
                }
                else if (text.alignX.style == AlignKeys.Right)
                {
                    position.x -= lineProps.width;
                }
                position.y += lineProps.maxHeight;
                if (lineNum > 0)
                {
                    position.y += text.extraLineSpacing;
                }
                drawLine(line, position, canvas);
                lineNum++;
                position.x = startPoint.x;
            }
        }
Exemple #2
0
        private float getTextHeight(SSText text)
        {
            float height = 0;

            foreach (SSLine line in text.lines)
            {
                height += calculateLineProps(line).maxHeight;
            }
            return(height);
        }