Open GoogleCodeExporter opened 8 years ago
The reason the added lines in OpenTK.cs look like they are indented incorrectly
is because I've setup VS to use tabs instead of 4 spaces. Sorry about that.
Original comment by FauxBest...@gmail.com
on 19 Jan 2012 at 6:54
Original comment by der.ag...@gmail.com
on 19 Jan 2012 at 8:41
OK so, I've more-or-less fixed the caret/selection placement. It was due to
the StringFormat not being set to GenericTypographic when measuring or drawing.
Also, OpenTK seems to trim trailing spaces when measuring text, so I simply
add 4 to the width if the string ends with a space character (not the best fix,
but it works, and it looks nice). Here are the edits, and I'll attach the
edited files just in case:
Gwen.Renderer.OpenTK.cs:
In MeasureText(), change
SizeF size = m_Graphics.MeasureString(text, sysFont);
to
SizeF size = m_Graphics.MeasureString(text, sysFont, Point.Empty, StringFormat.GenericTypographic);
and also change
return new Point((int)size.Width, (int)size.Height);
to
return new Point((int)Math.Round(size.Width) + ((text.EndsWith(" ")) ? 4 : 0), (int)Math.Round(size.Height));
Gwen.Renderer.TextRenderer.cs (OpenTK):
In DrawString, change
gfx.DrawString(text, font, brush, point);
to
gfx.DrawString(text, font, brush, point, StringFormat.GenericTypographic);
Original comment by FauxBest...@gmail.com
on 19 Jan 2012 at 9:01
Attachments:
Sorry if it seems like I'm spamming, but there's also an issue with the cursor
not changing when hovering over the sides of resizable windows. It changes
when hovering over the corners, showing that the window can be resized, but not
on the sides. I'm about to look into it (and I think I already know what the
problem is), so I'll let you know when I've resolved it.
Original comment by FauxBest...@gmail.com
on 19 Jan 2012 at 9:09
Fixed the cursor problem.
Gwen.ControlInternal.Resizer.cs:
In ResizeDir set, change
if (0 != (value & Pos.Right) && 0 != (value & Pos.Left))
to
if (0 != (value & Pos.Right) || 0 != (value & Pos.Left))
and change
if (0 != (value & Pos.Top) && 0 != (value & Pos.Bottom))
to
if (0 != (value & Pos.Top) || 0 != (value & Pos.Bottom))
Original comment by FauxBest...@gmail.com
on 19 Jan 2012 at 9:16
So, after testing the caret thing a bit more, it's not fixed -.- The further
from the start of the string the caret is, the more offset it is from where the
caret SHOULD be. I've no idea why this is happening, but I'm going to try some
hacks and see what I can do.
Original comment by FauxBest...@gmail.com
on 19 Jan 2012 at 10:09
It turns out that it all boils down to the fact that we're using hinting when
drawing the string, but when being measured (even with MeasureCharacterRanges
and TextRenderer.MeasureText), it doesn't use any hinting. The space issue
turned out to be quite simple to fix, btw. Just change the StringFormat
FormatFlags to MeasureTrailingSpaces. Until we can find an accurate way of
measuring, even with hinting enabled, the space fix is quite useless...
Original comment by FauxBest...@gmail.com
on 19 Jan 2012 at 11:15
I can get perfect rendering and measurement by using TextRenderer, but the text
comes out fatter, and performance takes a hit, especially when selecting text
by dragging.
Original comment by FauxBest...@gmail.com
on 19 Jan 2012 at 11:48
Generally GDI+'s text measurement is... bad. I'm not sure how to fix that
without using some external library like FreeType.
Original comment by der.ag...@gmail.com
on 20 Jan 2012 at 9:14
Well, I had a look at a few alternatives, including QuickFont, but... it was a
no-go. I ended up just switching from AntiAliasGridFit to AntiAlias for
TextRenderingHint. I really wasn't up for writing my own FreeType wrapper...
Original comment by FauxBest...@gmail.com
on 25 Jan 2012 at 3:20
I suggest you implement texture fonts with proper kerning. I myself did it with
AngelCode BMFonts if at all possible.
They work really well with Gwen. As far as GDI+ goes it seems to be fairly
unrealiable cross-platform.
Original comment by ollipe...@gmail.com
on 3 Feb 2012 at 5:33
Original issue reported on code.google.com by
FauxBest...@gmail.com
on 19 Jan 2012 at 6:51Attachments: