   [D3DX]Bitmap font
  Hello,I'm working on a project where i want to use bitmap font.Preferably i'd like to use  this file.  When use this file i get a border around a char, and i'm not sure why.Here is how file looks :  it has 10 chars/ row, 23 rows, every char is 35x35 px size and has 1px border around it.I use this code(found in this article. ) to get char i want to print:Xpos, Ypos // vertex positionBORDER = 1;  //Border widthCORR = 0.5;  //Quad vertex correction for correct texel to pixel mappingWIDTH = 360;//Texture widthHEIGHT = 828;  //Texture heightFONT_SIZE = 36; //Char size including borderNUM_CHARS_PER_LINE = 10; //char position calculationtu := ((((char_code - 32) * FONT_SIZE) mod WIDTH) + BORDER) / WIDTH;tv := ((((char_code - 32) div NUM_CHARS_PER_LINE) * FONT_SIZE)+BORDER)/HEIGHT;quad[0].x := Xpos - CORR;quad[0].y := Ypos - CORR;quad[0].z := 0;quad[0].rhw := 1;quad[0].color := color;quad[0].tu := tu;quad[0].tv := tv;quad[1].x := Xpos + Size - CORR;quad[1].y := Ypos - CORR;quad[1].z := 0;quad[1].rhw := 1;quad[1].color := color;quad[1].tu := tu + ((FONT_SIZE-BORDER)/WIDTH);quad[1].tv := tv;quad[2].x := Xpos - CORR;quad[2].y := Ypos + Size - CORR;quad[2].z := 0;quad[2].rhw := 1;quad[2].color := color;quad[2].tu := tu;quad[2].tv := tv + ((FONT_SIZE-BORDER)/HEIGHT);quad[3].x := Xpos + Size - CORR;quad[3].y := Ypos + Size - CORR;quad[3].z := 0;quad[3].rhw := 1;quad[3].color := color;quad[3].tu := tu + ((FONT_SIZE-BORDER)/WIDTH);quad[3].tv := tv + ((FONT_SIZE-BORDER)/HEIGHT);The other problem is how to get char's width. If you did't noticed theres is a pixel marking char's width, but i don't have any ideas how to use that info to get proper char width.   
  Hello Spak!The dirty answer is that if you can render the correct characters with a border, you just need to clamp your UV coordinates more tightly. Reanalyze the formulas that use BORDER.I wouldn't rely on the ASCII table directly. Your approach looks well thought out, but you may want to research typography a little more, specifically in metrics. Take a look at BMFont and observe it's output.I hope this helps.Cheers!-Zyro   ;  Thanks, for reply Zyro!The problem is not in the formulas.Let's take letter 'A' for example.In a file it is  located 108 px from the top and 108 px from the left and that's incuding border.To omit the top and left border i add 1px to these numbers, now i have top-left corner for letter 'A'. To calculate bottom-right corner i need to add char width without border that is char width - 1 px.After these calculation i would expect to get clean char, but after rendering char to screen it apears with border.Quote:...you just need to clamp your UV coordinates more tightlywhat do you mean by this? texture-addressing mode?if yes i allready tried D3DTADDRESS_CLAMP addressing mode for both U and V coordinates and did't notice any effect.Other thing i noticed, if i disable texture filtering or set it to D3DTEXF_POINT top and left borders disapear.   ;Quote:Original post by _spakOther thing i noticed, if i disable texture filtering or set it to D3DTEXF_POINT top and left borders disapear.Yep, and there's the problem.Bilinear filtering samples around the current texel to make a blended final texel. This is great for 3D graphics but causes all sorts of problems in 2D.You've come across the issue that happens with sprite sheets of any kind - filtering pulls in pixels from around the edge of the sprite which are causing the border you noticed.The best solution that I've found is to generate sprite sheets procedurally and create a 1 pixel border around each sprite that replicates the colours of the sprite's actual border (this is sometimes called a gutter). You then disregard this border when computing your texture co-ordinates and the filtering will then produce the correct results at the edges. A downside is that you can no longer tile textures (u or v > 1) correctly.This was pretty easy for me since I was already procedurally generating my sprite sheets from single frames but to apply this here, you will need to either modify the original image or split it up procedurally and regenerate a new sprite sheet.Using 3D hardware for 2D stuff can be a real pain sometimes, regardless of what anyone says. [smile]   