Tag Info

Hot answers tagged

17

Okay, you're going to have to forgive me for not giving you specific XNA code, because I'm not knowledgeable in that platform, but what I'm going to tell you should work on any game engine that lets you draw sprites. Fonts is not your only problem, so I'm going to give you a piece of advice, and then I'm going to answer your question. With these two things, ...


16

Fonts, like all forms of creative expression, are covered by copyright unless their copyright owner explicitly releases them into the public domain. Distributing a font, or derivative works of the font (bitmap images of text rendered using the font, for example) would be a violation of copyright, unless you have a license to do so. The particular font you ...


13

Modify the sprite font file. It's XML. Double click it in Visual Studio. Towards the bottom of the default file is a the following: <CharacterRegions> <CharacterRegion> <Start>&#32;</Start> <End>&#126;</End> </CharacterRegion> </CharacterRegions> Your character is unicode code point ...


11

The XNA sprite font processor uses DXT3 compression that does not work well with the new premultiplied alpha in XNA 4.0. Hence the blocky look of the text. The Nuclex sprite font processor outputs exactly the same data, except that the internal Texture2D that holds the font bitmap data is not compressed - so it has no quality issues. Because the data from ...


11

I'm speaking on behalf of CheapProFonts. ;) Obtaining a license for one of our fonts for inclusion in a software is easy and inexpensive: Just let us know that the font you purchase IS for that purpose, and then purchase two licenses for the font. So for $20 you will be allowed to include the font in your game and distribute as many copies of that game as ...


11

(Disclaimer: I am not a lawyer) In the United States a font face is not copyrightable (Eltra Corp. v. Ringer, 579 F.2d 294 (4th Cir. 1978)). But font software is copyrightable. A TrueType font (such as one you might download from cheapprofonts.com) contains instructions for how to render that font and is therefore a copyright piece of software. A bitmap ...


11

MeasureString() returns to you a Vector2 where the X is the width and Y is the height of the text. Also the SpriteFont class has a LineSpacing member that gives you the height of a line, including text and blank space. http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritefont_members.aspx


9

For a flexible system, you'll want to make new classes to represent a line of text that can contain multiple sections of text with a given colour. public class TextSection { String text; Color color; Font font; public void Draw(SpriteBatch spriteBatch, Vector2 location) { spriteBatch.DrawString(font, text, location, color); } ...


8

It's my understanding that in the most recent versions of the spec (3.3 and 4.x) the matrix stacks are gone and you need to keep track of your transformation matrices by hand. I believe this might be true for the mobile (ES) spec as well. If you're looking for a consistent way to handle your matrices by hand, you might be interested in GLM. It's a pretty ...


8

XNA lets you import a texture as a spritefont. You can probably get better hinting and anti-aliasing in your font if you lay each character out manually in a good image editing program, rather than relying on the sprite sheet that XNA generates.


7

You could use pixel fonts: When you use a pixel font at the font size it was designed for (or a whole multiple of it, e.g. 2x, 3x, 4x) you are guaranteed pixel-perfect text that requires no anti-aliasing. This means you never have to deal with the terrible anti-aliasing which makes XNA's sprite fonts so bad and Nuclex so much better. (This article ...


7

There are a lot of ways - depending on what you want... Like everywhere else, there isn't something like "the best solution". Which plattform is your target? Which language are you using? What is about text resizing/rotation - is it necessary? Do you need to be able to render TrueTypeFonts? Whats about Multilanguage/Unicode? How do you want to store your ...


7

Flexible & Accurate: Filters Use a texel filter either on the texture on the CPU side, or if you are using programmable pipeline OpenGL, directly in the fragment shader. The idea of a filter is simply that you run through a 2D loop to process every texel. If it is white, then you run through an inner 2D loop for each of its surrounding pixels in some ...


6

If the output bitmap matches the look of the font (the typeface) then it essentially IS the font, and yes you would be violating the license. You may embed the font in electronic documents, but you may NOT include the font in a software product - this requires a special license. Even though it's just an image it would still be the exact font, which is ...


6

Bitmap fonts Advantages: Can be integrated into any existing codebase, whether it's OpenGL, DirectX, DirectDraw or even GDI+. Fast. Using a texture atlas, you can render all your text in a single pass. Artist-controlled. Texture atlases can be procedurally generated (rendering a font style to a texture) or they can be loaded from a file. Artists can then ...


6

Well, like someone else said, in XNA, spritefont does the heavy lifting for you. on the creators club website there is a bitmap font exporter that exports in XNA style font images. (http://xbox.create.msdn.com/en-US/education/catalog/utility/bitmap_font_maker) Then, you can open it in photoshop or whatever and make it look pretty. From there, you add the ...


6

This feature is implemented directly in FTGL but it is only available in the ExtrudeFont class. You simply define an outset for the font: font = new FTExtrudeFont(...); font->FaceSize(80); font->Depth(0); font->Outset(0, 5); Then you can use a different colour for the two render modes: glColor3f(1.0, 1.0, 1.0); /* White inside */ ...


5

This is what you're looking for: http://www.angelcode.com/products/bmfont/ Used by numerous games, from indies to AAA titles, to create bitmap fonts from TTFs Using this tool or something similar is probably the most common way to implement font rendering in a game. Other options do exist (e.g. rendering vector fonts directly with something like ...


5

The nuclex library has more than one font renderer. Developer's blog, article discussing why XNA 4 fonts don't render as well as they could with spritebatch, with before and after comparisons of Nuclex font rendering vs Spritebatch in XNA4. Nuclex Fonts wiki. Nuclex Vector fonts (very useful for large fonts or fonts that need to be drawn well in 3D). XNA ...


5

If you want to use bitmap fonts, you can't go far wrong with the Angelcode Bitmap Font Generator: http://www.angelcode.com/products/bmfont/ It converts a truetype font to one or more textures (with nicely packed glyphs), and outputs a little file containing the UVs and spacings (I find that the XML output is particularly easy to work with, and the quality ...


4

I think your problem is that GetTextExtentPoint retrieves the "advance width", or how far the cursor would be advanced horizontally by inserting a particular bit of text. But some fonts (especially italics) contain overhangs - where the character extends a little bit further than the advance width. You can get more detailed information by using ...


4

The problem with resizing spritefonts is that when you make the spritefont, a file is made with an image of the font at the size you specify in the xml file. Because of this, you are not going to get the scalability of vector fonts, meaning that when you make your fonts bigger they will be blurry. The only way around this is to create several sprite fonts of ...


4

I haven't tried this out, so some experimentation would be needed to see if it actually works. What I would do: Start from a vectorized format that follows the drawing direction. As an example, the hershey fonts - the "scripts" and "scriptc" fonts might be a good starting point: Next, instead of drawing the fonts as line segments, render them as ...


3

I don't really think they could say, in very large print on the home screen: Only the best commercial- use free fonts Free fonts have met their match. We know how hard it is to find quality freeware that is licensed for commercial work. If they weren't.


3

You can use GetGlyphOutLine() with a format of GGO_GRAY8_BITMAP to extract individual character images, along with the metrics that tell you about placement and spacing. Without using those metrics, rendering the bitmaps in the correct position is much more difficult. Ideally you'd also use data from GetKerningPairs() to improve spacing between characters ...


3

As others have noted, the matrix stack is on its way out, which is a good reason to investigate alternatives. On one of my projects, I used the OpenGL's matrix ops to calculate my matrices, but ended up having to use glGet functions to fetch the matrix back so I could do some operations on the matrix that OpenGL's own functions didn't support. The ...


3

Using it that way would not be allowed. You're not allowed to use or copy fonts in any way, up to and including in printed material, without a license to do so. Luckily, there are many sources of free and free-to-license fonts out there. Chances are very good you can find an acceptable alternative.


3

It's late in the day, but 71Squared has now released a command line app for Glyph Designer that allows you generate your font assets as part of your build process and also specify the size you would like, so you can automatically generate SD/HD output as required by your project. ...


3

This is not an easy problem to solve. If the "multiple sprite fonts" technique doesn't work for you, there's no other built-in way in XNA to get what you want. So you have to do some custom development. One method is to use Valve's technique, as described in the paper: Improved Alpha-Tested Magni´Čücation for Vector Textures and Special Effects. This involves ...



Only top voted, non community-wiki answers of a minimum length are eligible