public override WordRectangle PutNextWord(string word, Size rectangleSize) { while (true) { var currentPoint = curve.CurrentPoint; var possibleRectangle = new Rectangle(currentPoint, rectangleSize); curve.Next(); if (!CanFit(possibleRectangle)) { continue; } var wordRectangle = new WordRectangle(possibleRectangle, word); WordRectangles.Add(wordRectangle); return(wordRectangle); } }
public override WordRectangle PutNextWord(string word, Size rectangleSize) { while (true) { var currentPoint = curve.CurrentPoint; var possibleRectangle = new Rectangle(currentPoint, rectangleSize); var canFit = WordRectangles.All(rect => !rect.Rectangle.IntersectsWith(possibleRectangle)); curve.Next(); if (!canFit) { continue; } var wordRectangle = new WordRectangle(possibleRectangle, word); WordRectangles.Add(wordRectangle); return(wordRectangle); } }
private Font GetBiggestFont(WordRectangle token, string fontFamilyName, Graphics graphics) { var word = token.Word; var rectangle = token.Rectangle; var fontSize = 10; for (; fontSize < 100; fontSize++) { var font = new Font(fontFamilyName, fontSize); var size = graphics.MeasureString(word, font); if (size.Height > rectangle.Height || size.Width > rectangle.Width) { break; } } return(new Font(fontFamilyName, fontSize - 1)); }