Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Quote:Firstly, Is it possible to specify the vertical alignment of text for example in PathText/BoundedText/PathBoundedText. I don't mean for vertical text but normal horizontal text that could be centered or placed at the bottom of the bounded area instead of at the top? It not possible to specify the vertical alignment of PathText as the position of text line is strictly specified by a path. Unfortunately, it is not possible to specify the vertical alignment in BoundedText and PathBoundedText as well, but we plan to add it in the future releases (Aurigma Bug #0022275). Currently, you can implement it in BoundedText using the following code: Code:using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.AdvancedDrawing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
public enum VerticalAlign
{
Top = 0,
Middle = 1,
Bottom = 2
}
static void Main(string[] args)
{
RenderText(VerticalAlign.Top);
RenderText(VerticalAlign.Middle);
RenderText(VerticalAlign.Bottom);
}
static void RenderText(VerticalAlign verticalAlign)
{
using (var bitmap = new Bitmap(400, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
var brush = new SolidBrush(RgbColor.Red);
var dummyText = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras elementum quam ac nisi varius gravida. Mauris ornare, dolor et scelerisque volutpat, enim urna commodo odio, consequat fermentum sem arcu sit amet nisl. Aliquam tincidunt id neque in gravida.";
var boundedTextRect = new System.Drawing.RectangleF(20f, 20f, 360f, 210f);
var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 16f),
brush, boundedTextRect);
//Vertical align
if (verticalAlign != VerticalAlign.Top)
{
var blackBox = boundedText.GetBlackBox();
var r = boundedText.Rectangle;
switch (verticalAlign)
{
case VerticalAlign.Middle:
r.Offset(0, (boundedText.Rectangle.Height - blackBox.Height) / 2);
break;
case VerticalAlign.Bottom:
r.Offset(0, boundedText.Rectangle.Height - blackBox.Height);
break;
}
boundedText.Rectangle = r;
}
graphics.DrawText(boundedText);
graphics.DrawRectangle(new Pen(RgbColor.Black), boundedTextRect);
bitmap.Save(String.Format("../../../VerticlaAlign_{0}.png", verticalAlign));
}
}
}
Quote:Secondly, Is it possible to automatically fit text into an area, so the text size shrinks as the amount of text increases? Do you mean to get a result as on the attached image? Edited by user Wednesday, June 15, 2016 7:31:30 PM(UTC)
| Reason: Not specified Fedor attached the following image(s): |
Best regards, Fedor Skvortsov
|