Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

SharpDX Toolkit SpriteBatch.DrawString issue #236

Closed
xanather opened this issue Dec 13, 2013 · 11 comments
Closed

SharpDX Toolkit SpriteBatch.DrawString issue #236

xanather opened this issue Dec 13, 2013 · 11 comments

Comments

@xanather
Copy link
Contributor

Spritebatch seems to be drawing/measuring letters that are 1 pixel in width incorrectly.

For example (textbox from within my game):

badletters

Compiled font file used (generated by tkfont.exe)
http://www.xanather.com/Main.font.zip

This issue only happens if characters such as "i", "I" (upper case i) and "l" (lower case L) are the first letters in the string. Any of them characters that are not at index zero will be measured correctly.

This is the only actual issue that Ive had with SharpDX toolkit after moving over a large code base from MonoGame. Amazing!

@RecursiveCall
Copy link
Contributor

I can confirm this. Also, the space (" ") returns font.MeasureString().X value of 0. In XNA, it would return the actual width of the space (I'm guessing based on whatever the maximum character block would be).

@ghost
Copy link

ghost commented Dec 18, 2013

This is not related to the actual topic, but:
@xanather may i ask how you are doing this red outline rendering? do you just offset it 4 (or 8) times when before drawing the black font? or do you have some shader in place?

@xanather
Copy link
Contributor Author

I first draw the red outline (4 drawstring calls) at offsets (-1, 0), (1, 0), (0, -1), (0, 1) and then draw the black text over it (no offset).

@xanather
Copy link
Contributor Author

https://github.com/sharpdx/SharpDX/blob/master/Source/Toolkit/SharpDX.Toolkit.Graphics/SpriteFont.cs#L402 Is this the issue? I have a feeling its not the actual imported Glyph measurements since all characters can be drawn/measured fine IF they are not the first character.

@xanather
Copy link
Contributor Author

xanather commented Jan 7, 2014

Any thoughts as to why this might happen? Its the only bug ive found on SharpDX TK and I rather would not code around it.

@xoofx
Copy link
Member

xoofx commented Jan 7, 2014

I had no time to look into this. This code is inherited from SpriteFont from DirectXTk. If you take the time to dig into this issue and fix it that would be helpful

@xanather
Copy link
Contributor Author

xanather commented Jan 7, 2014

Well I do owe this project alot, I will give it a shot. This is also a time for me to solve the requirements on compiling on Windows 7.

@xanather
Copy link
Contributor Author

xanather commented Jan 9, 2014

Edit: I was copying over the Input library instead of the Graphics library, silly me :) Should have fix soon

@xanather
Copy link
Contributor Author

xanather commented Jan 9, 2014

Issue stems from the change at #86 060f9b7

@xoofx
Copy link
Member

xoofx commented Jan 9, 2014

Thanks, I did some tests but the fix was not working well with fixed fonts and spaces at the beginning of the line.
After checking and using the same rule as DirectXTk, It is working well with fixed font like "Courier New" as well as "Arial". Let me know if there is still an issue

@xoofx xoofx closed this as completed Jan 9, 2014
@xanather
Copy link
Contributor Author

xanather commented Feb 3, 2014

Edit: going to make another issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants