spritefont

How do I implement word wrap?

不羁的心 提交于 2019-12-19 09:08:36
问题 XNA has Spritefont class, which has a MeasureString method, which can return the Width and Height of a string . I'm trying to understand how to create a method that will efficiently return a string with Environment.Newline inserted in the right places, so that if fits a certain Width and Height (Rectangle is used as a parameter for that). 回答1: I found following code: XNA - Basic Word Wrapping public string WrapText(SpriteFont spriteFont, string text, float maxLineWidth) { string[] words =

How do I create a bitmap image as spritefont with multiple character regions?

对着背影说爱祢 提交于 2019-12-11 03:48:55
问题 How do I create a bitmap font image that contains characters from multiple regions and is correctly interpreted by XNA content pipeline? I want to add some special characters to my bitmap font image, but I don't know how to do it correctly. UPD: I think I'm getting closer to my answer. Sprite font texture content processor looks for non-magenta squares in the image and probably uses an xml settings file like with normal spritefonts to map each square to a corresponding symbol. I should

DirectX::SpriteFont/SpriteBatch prevents 3D scene from drawing

这一生的挚爱 提交于 2019-12-04 05:27:02
问题 I have a problem using DirectX::SpriteFont / DirectX::SpriteBatch (from DirectXTK; exactly the same problem as discussed here: Problems when drawing text using the SpriteFont class). void DrawScene(void) { HRESULT hr; float bgColor_a[4] = { 0.0f, 0.4f, 0.8f, 0.0f }; g_pDeviceContext->ClearRenderTargetView(g_pRenderTargetView, bgColor_a); g_pDeviceContext->ClearDepthStencilView(g_pDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); XMMATRIX cameraProj = XMLoadFloat4x4(&g

How do I implement word wrap?

人走茶凉 提交于 2019-12-01 08:20:59
XNA has Spritefont class, which has a MeasureString method, which can return the Width and Height of a string . I'm trying to understand how to create a method that will efficiently return a string with Environment.Newline inserted in the right places, so that if fits a certain Width and Height (Rectangle is used as a parameter for that). I found following code: XNA - Basic Word Wrapping public string WrapText(SpriteFont spriteFont, string text, float maxLineWidth) { string[] words = text.Split(' '); StringBuilder sb = new StringBuilder(); float lineWidth = 0f; float spaceWidth = spriteFont