Ejemplo n.º 1
0
        internal void DrawString(string str, RectangleF rect, Fonte fonte, AlinhamentoHorizontal ah = AlinhamentoHorizontal.Esquerda, AlinhamentoVertical av = AlinhamentoVertical.Topo)
        {
            if (fonte == null)
            {
                throw new ArgumentNullException(nameof(fonte));
            }
            if (fonte.Tamanho <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(fonte));
            }
            CheckRectangle(rect);

            var p = rect.Location;

            if (av == AlinhamentoVertical.Base)
            {
                p.Y = rect.Bottom - fonte.AlturaLinha;
            }
            else if (av == AlinhamentoVertical.Centro)
            {
                p.Y += (rect.Height - fonte.AlturaLinha) / 2F;
            }

            if (ah == AlinhamentoHorizontal.Direita)
            {
                p.X = rect.Right - fonte.MedirLarguraTexto(str);
            }
            if (ah == AlinhamentoHorizontal.Centro)
            {
                p.X += (rect.Width - fonte.MedirLarguraTexto(str)) / 2F;
            }

            SetFont(fonte);
            ShowText(str, p);
        }
Ejemplo n.º 2
0
 public void SetFont(Fonte fonte)
 {
     if (fonte == null)
     {
         throw new ArgumentNullException(nameof(fonte));
     }
     if (fonte.FonteInterna == null)
     {
         throw new ArgumentNullException(nameof(fonte));
     }
     if (fonte.Tamanho <= 0)
     {
         throw new ArgumentNullException(nameof(fonte));
     }
     PrimitiveComposer.SetFont(fonte.FonteInterna, fonte.Tamanho);
 }