drawString should use the same StringFormat like font metrics

This commit is contained in:
smallsql 2010-12-15 14:33:04 +00:00
Родитель 8dd1fb9229
Коммит 46be1e2aa9
1 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -674,8 +674,27 @@ namespace ikvm.awt
public override void drawString(string text, float x, float y) public override void drawString(string text, float x, float y)
{ {
g.DrawString(text, netfont, brush, x, y - font.getSize(), StringFormat.GenericTypographic); if (text.Length == 0) {
} return;
}
StringFormat format;
switch (g.TextRenderingHint)
{
// Fractional metrics
case TextRenderingHint.AntiAlias:
case TextRenderingHint.SingleBitPerPixel:
// this very mystic, if a StringFormat extends from GenericTypographic then the metric are different but like Java with fractional metrics
format = new StringFormat(StringFormat.GenericTypographic);
break;
default:
// Non Fractional metrics
format = new StringFormat();
break;
}
format.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.NoWrap | StringFormatFlags.FitBlackBox;
format.Trimming = StringTrimming.None;
g.DrawString(text, netfont, brush, x, y - font.getSize(), format);
}
public override void drawString(java.text.AttributedCharacterIterator iterator, int x, int y) public override void drawString(java.text.AttributedCharacterIterator iterator, int x, int y)
{ {