本文整理汇总了C#中Font.GetWidthUtf8方法的典型用法代码示例。如果您正苦于以下问题:C# Font.GetWidthUtf8方法的具体用法?C# Font.GetWidthUtf8怎么用?C# Font.GetWidthUtf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Font
的用法示例。
在下文中一共展示了Font.GetWidthUtf8方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintWord
private void PrintWord(string word, Font font,
bool ignore_split)
{
double width_required =
font.GetWidthUtf8 (word);
Tag tag;
// word fits in the line
if ((curx + width_required) <
(marginx + width))
{
tag.word = word;
tag.font = font;
tag.width = width_required;
tags.Add (tag);
curx += width_required;
return;
}
// this is a loooong word.
if (width_required > width)
{
if (ignore_split)
{ // for tabs we dont need to split
FlushLine ();
}
else
{
string part, extra;
SplitWord (word, font,
marginx +
width - curx,
out part,
out extra);
tag.word = part;
tag.font = font;
tag.width =
font.
GetWidthUtf8
(part);
tags.Add (tag);
FlushLine ();
PrintWord (extra, font, ignore_split); // recursive!
}
return;
}
// the 'word' has to go to the next line
FlushLine ();
tag.word = word;
tag.font = font;
tag.width = width_required;
curx += width_required;
tags.Add (tag);
}
示例2: SplitWord
private void SplitWord(string word, Font font,
double available_width,
out string left,
out string right)
{
double total_width = 0;
for (int i = 0; i < word.Length; i++)
{
char ch = word[i];
double char_width =
font.GetWidthUtf8 ("" + ch);
total_width += char_width;
if (total_width > available_width)
{
left = word.Substring (0,
i);
right = word.
Substring (i);
return;
}
}
left = null;
right = null;
}