Hot answers tagged

18

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, ...


17

It's easy: Fonts do not need to match resolution, they need to match pixel density. Pixel density is measured as pixels per inch(PPI), or pixels per centimeter. There's also a measure unit called density independent pixels(DP). It is defined that 1dp is the size one pixel has on a 160 PPI screen. Now coming back to fonts, try to make this test: put your ...


15

You seem to want to keep the same textsize/screensize ratio. Basically what you do is develop at one resolution and let that be scale 1.0. Then you divide the new screen width by the old width and that is your scale factor. For example. Developing on 2560x1440 with font size 16 and running on 1920x1080. Font size will be: 1920 * 16 / 2560 = 12 I do the ...


13

If you use a font rendering engine like FreeType, then the most common mistake is to re-render strings every frame. This is pointless, because when you render a string, it will usually be on the screen unchanged for at least a few seconds. When you want to display a text, render that text to a texture once and then draw that texture instead of re-rendering ...


7

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 ...


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

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 */ font->Render("...


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 ...


5

So what I had been thinking has been confirmed: The dialog is built with a single NinePatch so you need to adjust the size of the title bar manually within the .atlas file and .png file. EDIT This will basically be a little How to use a JSON file with LibGdx tutorial. LibGdx has a very useful Class called Skin. It allows you to have a .json file along with ...


5

From this topic: http://badlogicgames.com/forum/viewtopic.php?t=8573&p=38930 You should try not to do the following: (Quote from one of the GDX creators) batch.begin(); shapes.begin(); .. draw stuff from both ... shapes.end(); batch.end(); And from me - Don't use ShapeRenderer for drawing - it's for debugging purposes. Instead of this create a ...


5

Truetype fonts are vector based. So you would have to trace the glyphs with a vector editor and then use a program like FontForge (which also is a vector editor) to build a font from that. That said, You do not need to use TTF fonts in MonoGame since it just renders the font to a texture at compile time. There are many bitmap font programs/examples ...


4

If you want to use SDL_ttf, then you have no choice but using TTF fonts, see the doc: SDL_ttf supports loading fonts from TrueType font files, normally ending in .ttf, though some .fon files are also valid for use. Now if OTF is still an option you would consider (even if there's no SDL_otf, which means you'll have to implement it), it's potentially a ...


4

The solution is quite simple and is used by a great number of games. All you have to do is treat your fonts as if they were sprites. Have your designer draw out the entire range of numbers and letters that you want to use in your game. Then render them to varying sized static images (.png, .bmp, whatever format you use). You'll have something like this: ...


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 splines. ...


4

The reason you are getting this behaviour is because of coordinate system. The base coordinate for your sprites is "left,bottom" (classic Cartesian) however all offsets in fnt files are assuming inverted Y axis (drawing from "left,top" of the sprite). So instead of (you may notice this gives correct align, but on the top, i.e. g goes up instead of down): ...


4

The fileformat.info page you linked to contains a link “Fonts that support this block”. The ones listed there with 100% support are— Everson Mono (cost: €25; license: Everson Mono Shareware License), and GNU Unifont (cost: free; license: GNU GPL, with virality-exemption for embedding)


4

My approach is to do the following: Convert your font file to an image Store each character as a VAO (use a loop to store them all - array index = unicode number) Use a sprite batch to draw the text whenever its needed Below is a snippet of my Java sprite batching code, used to draw the text. public void draw(final String text, final float sx, final float ...


4

If you cannot find a single font containing all glyphs you want, you will have to have multiple fonts. Some text rasterisation APIs have "font linking" or "font substitution" in which they use more than one font as fallback for missing glyphs. This tends to result in a sub-optimal result in terms of character advances, relative glyph size, and kerning - but ...


4

Yes, Freetype is reasonable. If you use .png files, you have to make one for EVERY size and EVERY color, and that may occupy 10 times the space a .ttf file takes up. Goodbye, free space on android and iOS devices. Moreover, you just have to get 1 .ttf file, and that's it. Hope I helped you!


4

I believe this could be an issue with the AssetManager as it uses an objectMap which maps loaded objects to the string used to load them. In this case you're loading the font and the assetManager is storing it in it's objectMap under the key "fonts/Roboto-Regular.ttf", then when you load your font again with second set of parameters the previous font is ...


4

The intent of Condition #5 of the Open Font License seems to simply be to clarify the following: You do need to provide this license alongside your usage of the font, but This license applies just to the font, and doesn't affect whatever you're using the font to produce. In other words, the license is clarifying that it is not a viral license such as the ...


3

Basically this is just a programming question if you abstract this out. If you really want to do this with sprite sheets, here's how I might do it in some quick JavaScript-style pseudocode... // ------------------------------------------------------------------------- // --- Array of sprite sheet offset for letter variants, indexed by letter // --- Note ...


3

If you are referring to your in-game fonts, you do not need to install the custom fonts in order to use them with your compiled game. When compiled, your fonts get converted to .XNB files, which are packaged in in your /bin directory and are used to draw in game.


3

Perhaps you could try scissor testing the window when drawing text? glEnable(GL_SCISSOR_TEST); glScissor(windowX, windowY, windowSizeX, windowSizeY); CFontManager::Instance().renderWrappedText(font, lineLength, position, text); glDisable(GL_SCISSOR_TEST); You can also apply this to everything within the window as a single, unified solution.


3

I don't know about the platform you're using, but there are mostly three ways to center text. Not all of them are available on all platforms, so you should check your platform documents and see which one of these is available. The font rendering system has a flag or option to draw centered text. Look for something like font.textAlignment. The font rendering ...


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 Magnification for Vector Textures and Special Effects. This involves ...


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. http://www.71squared.com/en/article/1979/introducing-glyph-designer-command-...


3

Do you know how to implement sprites? If yes, then drawing text from a character sheet is easy: just treat each character as a sprite and draw them one after the other. The details depend on the font you have and on how fancy you want your typography to be. Obviously, the simplest case would be a monospace font, where each character is a constant-size ...


3

It looks like you are using a scale camera for your game objects (the grid). That's fine. However fonts in libgdx are scaled in pixel dimensions and not your game world units. The best course of action here is to maintain two sperate cameras to render your game: world, and ui. The world camera will be in your world units as you have it now. The ui camera ...


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