sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.69k stars 641 forks source link

SharpDX Toolkit SpriteBatch.DrawString issue (x positive offseting) #266

Closed xanather closed 10 years ago

xanather commented 10 years ago

Just got back from a break, the change to fix one letter overlapping itself works now however all the text is offset in the x positive direction alittle. Example is here https://github.com/sharpdx/SharpDX/issues/86

xanather commented 10 years ago

Id rather not have to continuously build my own binaries to make it work properly. Is this issue related to having two different font processors or something? I am using SharpDX's implementation of the DirectX toolkit SpriteFont compiler. According to what has been said before SharpDX now uses the same implementation of DirectX SpriteFont processor so I'm not sure what could cause the issue unless the DirectX Toolkit includes the issue itself. #86 describes this issue.

ArtiomCiumac commented 10 years ago

There is no easy fix, because if we will revert to previous patch - it will cause issues with whitespaces at beginning of the line. The problem lies much deeper, and it may require to rewrite the actual sprite font generation functionality. I will take a look at it once I will find more free time.

xanather commented 10 years ago

Should I submit a temporary fix where SpriteFont has a static propery determining whether to ignore the offset at the beginning or not?

xoofx commented 10 years ago

I would prefer not. I believe DirectXTk has this problem as well and the problem lies into the font generation. I will investigate to switch to DirectWrite rendering for the compiler.

xoofx commented 10 years ago

I have a new working version with DirectWrite that seems to fix this issue, though it seems that supporting underline/strikethrough is a bit problematic. Are you using those? Edit: Seems that BMFont is not supporting underline/strikethrough, so It would be probably fine to drop this feature

ArtiomCiumac commented 10 years ago

@xoofx, I agree to drop this feature. We can investigate it later - probably a call to IDWriteTextLayout::SetUnderline might help - in case if TextLayout is used to render each char.

xoofx commented 10 years ago

I was primarily not using TextLayout (using the lower level part of DirectWrite)... but only TextLayout provide underline/strikethrough. Unfortunately, when using TextLayout, we are loosing the font offsets info, but I have found some possible workaround, testing it right now.

xanather commented 10 years ago

I use SharpDX's version of MakeSpriteFont, no underline/strikethrough, never knew such a feature existed in the first place.

xoofx commented 10 years ago

Can you try latest version (from sourcecode) and let me know if there is anything wrong?

xanather commented 10 years ago

Sorry for late reply, anyway with the latest sources (including the most recent commit) this happened:

untitled

xanather commented 10 years ago

This is the compiled font file that i am using http://www.xanather.com/Main.font

ArtiomCiumac commented 10 years ago

Have you tried to recompile the font? SpriteBatchAndFont Toolkit sample works fine.

xanather commented 10 years ago

Will do

xanather commented 10 years ago

Yep rendering good now! Thanks for the fix.

xanather commented 10 years ago

Well the measurements are fine, however supports for some fonts gone now? I am trying to create a "MS Sans Serif" font but it results in a 0 byte output file. So instead I choose "Microsoft Sans Serif" (they are different), which results in a non 0 byte output file but the difference is that "Microsoft Sans Serif" is anti-aliased/more smooth which I don't want (not solid pixels/has blending). I generated the last font file over 2 months ago and can't remember if I chose "Microsoft Sans Serif" or "MS Sans Serif".

Edit: Just tested out on a old tkfont binary, this seems to be my issue (I think). All I'm trying to do is get a pixelized/not smooth/jagged version out of Microsoft Sans Serif.

Edit2: Silly me, I remember using BMFont to do this. Anyway this issue seems to be fixed so closing...

xanather commented 10 years ago

I was right. I can no longer create Jagged fonts with the new TKFont, is this intentional or is it just how DirectWrite handles it?