私はそれが簡単で
http://csharphelper.com/blog/2014/10/fully-justify-a-line-of-text-in-c/
:)をFOUND - あなたは段落全体の所定の幅を知っているとき、あなたはそれぞれ別の行のテキストを正当化することができます。
float extra_space = rect.Width - total_width; // where total_width is the sum of all measured width for each word
int num_spaces = words.Length - 1; // where words is the array of all words in a line
if (words.Length > 1) extra_space /= num_spaces; // now extra_space has width (in px) for each space between words
残りがありますかなり直感的です:
float x = rect.Left;
float y = rect.Top;
for (int i = 0; i < words.Length; i++)
{
gr.DrawString(words[i], font, brush, x, y);
x += word_width[i] + extra_space; // move right to draw the next word.
}
出典
2016-01-21 09:26:22
ymz