Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Fr Jul 18, 2025 12:31

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: RTCW Font Format
BeitragVerfasst: Do Nov 04, 2004 04:40 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
RTCW fonts have a .dat file and a TGA of the font(with the font in the alpha channel).

My problem is that i don't know why there is so much data for each letter (and why they seem to all be the same for most letters). For the name of the image there is 32Bytes, for the "header" there is 48.(see below for the Hex of a .dat)


Attached is a unit with the font files and below is some images.


Dateianhänge:
Dateikommentar: Delphi's values of the loaded file
delphivalues.jpg [217.9 KiB]
56-mal heruntergeladen
Dateikommentar: Hex of the fonts .dat
fonthex.jpg [204.03 KiB]
56-mal heruntergeladen
Dateikommentar: Includes: Helios_Font.pas(Incompleate), and a tga font and its dat file.
fonts.zip [14.39 KiB]
319-mal heruntergeladen

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Nov 06, 2004 08:12 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
Below is an image of each 48 bytes of the first 2 glyphs(which are the same looks wise on the tga) and a jpg of font 17.

The first 2 glyphs are 9x14, there is a gap of 3 horazontaly. between the two. I still don't see the need for 48 bytes when you just need 4 bytes(since its dimentions are 255x255 you don't need larger numbers). The numbers still seem pritty random to me.

EDIT:

Found the following in the q3 source. Time to try n use it...

Code:
  1.  
  2. // font support
  3.  
  4. #define GLYPH_START 0
  5. #define GLYPH_END 255
  6. #define GLYPH_CHARSTART 32
  7. #define GLYPH_CHAREND 127
  8. #define GLYPHS_PER_FONT GLYPH_END - GLYPH_START + 1
  9. typedef struct {
  10.   int height;       // number of scan lines
  11.   int top;          // top of glyph in buffer
  12.   int bottom;       // bottom of glyph in buffer
  13.   int pitch;        // width for copying
  14.   int xSkip;        // x adjustment
  15.   int imageWidth;   // width of actual image
  16.   int imageHeight;  // height of actual image
  17.   float s;          // x offset in image where glyph starts
  18.   float t;          // y offset in image where glyph starts
  19.   float s2;
  20.   float t2;
  21.   qhandle_t glyph;  // handle to the shader with the glyph
  22.     char shaderName[32];
  23. } glyphInfo_t;
  24.  
  25. typedef struct {
  26.   glyphInfo_t glyphs [GLYPHS_PER_FONT];
  27.     float glyphScale;
  28.     char name[MAX_QPATH];
  29. } fontInfo_t;
  30.  


Dateianhänge:
unknownbytes.jpg [27.3 KiB]
38-mal heruntergeladen
rtcwfont17.jpg
rtcwfont17.jpg [ 49.1 KiB | 4006-mal betrachtet ]

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Nov 06, 2004 10:08 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
Now i seem to b able to load it, problem is that when the glyphs are drawn there plain white. Dispite the fact iv used the blendfunc.

Code:
  1.  
  2. unit Helios_Font;
  3.  
  4. {$I Global_Conditionals.INC}
  5.  
  6. interface
  7.  
  8. // font support
  9. Const
  10. GLYPH_START     =  0;
  11. GLYPH_END       = 255;
  12. GLYPH_CHARSTART = 32;
  13. GLYPH_CHAREND   = 127;
  14. GLYPHS_PER_FONT = GLYPH_END - GLYPH_START;
  15.  
  16. Type
  17. TGlyphInfo = Packed Record
  18.   height,       // number of scan lines
  19.   top,          // top of glyph in buffer
  20.   bottom,       // bottom of glyph in buffer
  21.   pitch,        // width for copying
  22.   xSkip,        // x adjustment
  23.   imageWidth,   // width of actual image
  24.   imageHeight : integer;  // height of actual image
  25.   s,          // x offset in image where glyph starts
  26.   t,          // y offset in image where glyph starts
  27.   s2,
  28.   t2 : single;
  29.   glyph : integer; // handle to the shader with the glyph
  30.   ShaderName : Array [1..32] of Char;
  31. end;
  32.  
  33. THelios_Font = record
  34. Size : Integer;
  35. Glyphs : array [0..255] of TGlyphInfo;
  36. DisplayList : Integer;
  37. end;
  38.  
  39. THelios_Fonts = record
  40. Font : array of THelios_Font;
  41. Font_No : Integer;
  42. end;
  43.  
  44. Var
  45. Fonts : THelios_Fonts;
  46.  
  47. //Function LoadAFont(Filename : String; Size : Integer) : Boolean;
  48. //Procedure BuildFont(Var Font : THelios_Font);
  49. Procedure BuildFonts;
  50. Procedure LoadFonts;
  51. Procedure WriteTextHN(X,Y : Single; S : Pchar; Font : THelios_Font);
  52.  
  53. implementation
  54.  
  55. Uses SysUtils,Dialogs,Helios_Filesystem, OpenGL15, Textures;
  56.  
  57. Function LoadFont(Filename : String; Size : Integer; Var Font : THelios_Font) : Boolean;
  58. var
  59. F : file;
  60. X : Integer;
  61. begin
  62. Result := False;
  63.  
  64. If not Fileexists(Filename) then exit;
  65.  
  66. AssignFile(f, filename);
  67. Reset(f,1);
  68.  
  69. Font.Size := Size;
  70. Font.DisplayList := -1;
  71.  
  72. For x := 0 to 255 do
  73. BlockRead(F,Font.Glyphs[x],SizeOf(TGlyphInfo));
  74.  
  75. CloseFile(f);
  76.  
  77. Result := True;
  78. end;
  79.  
  80. Function LoadAFont(Filename : String; Size : Integer) : Boolean;
  81. var
  82. X : integer;
  83. begin
  84.  
  85. Result := False;
  86.  
  87. For x := 0 to Fonts.Font_No-1 do
  88. if Fonts.Font[x].Size = Size then
  89. begin
  90. Result := True;
  91. exit;
  92. end;
  93.  
  94. Inc(Fonts.Font_No);
  95. SetLength(Fonts.Font,Fonts.Font_No);
  96.  
  97. Result := LoadFont(Filename,Size,Fonts.Font[Fonts.Font_No-1]);
  98. If Not Result then
  99. begin
  100. Dec(Fonts.Font_No);
  101. SetLength(Fonts.Font,Fonts.Font_No);
  102. end;
  103.  
  104. end;
  105.  
  106. Procedure LoadFonts;
  107. begin
  108.  
  109. Fonts.Font_No := 0;
  110. SetLength(Fonts.Font,Fonts.Font_No);
  111.  
  112. LoadAFont(DoesFileExist('fonts\fontimage_12.dat'),12);
  113. LoadAFont(DoesFileExist('fonts\fontimage_16.dat'),16);
  114. LoadAFont(DoesFileExist('fonts\fontimage_17.dat'),17);
  115. LoadAFont(DoesFileExist('fonts\fontimage_24.dat'),24);
  116.  
  117. BuildFonts;
  118.  
  119. end;
  120.  
  121. Function CharArrayToStr(Chars : Array of Char; Ammount : Integer) : String;
  122. var
  123. x : integer;
  124. begin
  125.  
  126. Result := '';
  127.  
  128. For x := 0 to Ammount-1 do
  129. If Chars[x] <> #0 then
  130. Result := Result + Chars[x]
  131. else
  132. Exit;
  133.  
  134. end;
  135.  
  136. Procedure BuildFont(Var Font : THelios_Font);
  137. Var
  138. I : Integer;
  139. S : Cardinal;
  140. CurTex,CurTex2 : String;
  141. begin
  142.   glLoadIdentity;
  143.   CurTex := '';
  144.   CurTex2 := '';
  145.  
  146.   Font.DisplayList := glGenLists(256);
  147.   for I := 0 to 255 do
  148.   begin
  149.     glNewList(Font.DisplayList+I, GL_COMPILE);       // Start Building A List
  150.     glBegin(GL_QUADS);
  151.     If String(Font.Glyphs[I].ShaderName) <> CurTex2 then
  152.     begin
  153.     CurTex2 := String(Font.Glyphs[I].ShaderName);
  154.     CurTex := CharArrayToStr(Font.Glyphs[I].ShaderName,32);
  155.     LoadTexture(DoesFileExist(CurTex),S,False,False,False);
  156.     end;
  157.  
  158.      glEnable(GL_BLEND);
  159.      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  160.      glEnable(GL_ALPHA_TEST);
  161.  
  162.      glBindTexture(GL_TEXTURE_2D, S);
  163.  
  164.        glTexCoord2f(Font.Glyphs[I].s,Font.Glyphs[I].t);
  165.       glVertex2i(0, 0);
  166.       glTexCoord2f(Font.Glyphs[I].s2, Font.Glyphs[I].t);
  167.       glVertex2i( Font.Glyphs[I].imageWidth, 0);
  168.       glTexCoord2f(Font.Glyphs[I].s2, Font.Glyphs[I].t2);
  169.       glVertex2i( Font.Glyphs[I].imageWidth, Font.Glyphs[I].imageHeight);
  170.       glTexCoord2f(Font.Glyphs[I].s,Font.Glyphs[I].t2);
  171.       glVertex2i(0, Font.Glyphs[I].imageHeight);
  172.     glEnd();
  173.     glTranslatef(Font.Glyphs[I].imageWidth+1, 0, 0);
  174.     glEndList();
  175.   end;
  176.  
  177.   glDisable(GL_BLEND);
  178. end;
  179.  
  180. Procedure BuildFonts;
  181. var
  182. x : Integer;
  183. begin
  184.  
  185. if Fonts.Font_No > 0 then
  186. for x := 0 to Fonts.Font_No-1 do
  187. BuildFont(Fonts.Font[x]);
  188.  
  189. end;
  190.  
  191. Procedure WriteTextHN(X,Y : Single; S : Pchar; Font : THelios_Font);
  192. begin
  193. glPushMatrix();
  194.     glTranslatef(x, y, 0.005);
  195.  
  196.     glPushAttrib(GL_LIST_BIT);
  197.       glListBase(Font.DisplayList);
  198.       glCallLists(length(S),GL_UNSIGNED_BYTE,S); // Write The Text To The Screen
  199.     glpopattrib();
  200.   glPopMatrix();
  201. end;
  202.  
  203. end.
  204.  

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Nov 06, 2004 17:17 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
Working Unit:

Code:
  1.  
  2. unit Helios_Font;
  3.  
  4. {$I Global_Conditionals.INC}
  5.  
  6. interface
  7.  
  8. // font support
  9. Const
  10. GLYPH_START     =  0;
  11. GLYPH_END       = 255;
  12. GLYPH_CHARSTART = 32;
  13. GLYPH_CHAREND   = 127;
  14. GLYPHS_PER_FONT = GLYPH_END - GLYPH_START;
  15.  
  16. Type
  17. TGlyphInfo = Packed Record
  18.   height,       // number of scan lines
  19.   top,          // top of glyph in buffer
  20.   bottom,       // bottom of glyph in buffer
  21.   pitch,        // width for copying
  22.   xSkip,        // x adjustment
  23.   imageWidth,   // width of actual image
  24.   imageHeight : integer;  // height of actual image
  25.   s,          // x offset in image where glyph starts
  26.   t,          // y offset in image where glyph starts
  27.   s2,
  28.   t2 : single;
  29.   glyph : integer; // handle to the shader with the glyph
  30.   ShaderName : Array [1..32] of Char;
  31. end;
  32.  
  33. THelios_Font = record
  34. Size : Integer;
  35. Glyphs : array [0..255] of TGlyphInfo;
  36. DisplayList : Integer;
  37. Height : Integer;
  38. end;
  39.  
  40. THelios_Fonts = record
  41. Font : array of THelios_Font;
  42. Font_No : Integer;
  43. end;
  44.  
  45. Var
  46. Fonts : THelios_Fonts;
  47.  
  48. //Function LoadAFont(Filename : String; Size : Integer) : Boolean;
  49. //Procedure BuildFont(Var Font : THelios_Font);
  50. Procedure BuildFonts;
  51. Procedure LoadFonts;
  52. Procedure WriteTextHN(X,Y : Single; S : Pchar; Font : THelios_Font);
  53.  
  54. implementation
  55.  
  56. Uses SysUtils,Helios_Filesystem, OpenGL15, Textures;
  57.  
  58. Function LoadFont(Filename : String; Size : Integer; Var Font : THelios_Font) : Boolean;
  59. var
  60. F : file;
  61. X : Integer;
  62. begin
  63. Result := False;
  64.  
  65. If not Fileexists(Filename) then exit;
  66.  
  67. AssignFile(f, filename);
  68. Reset(f,1);
  69.  
  70. Font.Size := Size;
  71. Font.DisplayList := -1;
  72.  
  73. Font.Height := -1;
  74.  
  75. For x := 0 to 255 do
  76. begin
  77. BlockRead(F,Font.Glyphs[x],SizeOf(TGlyphInfo));
  78. If Font.Glyphs[x].imageHeight > Font.Height then
  79. Font.Height := Font.Glyphs[x].imageHeight;
  80. end;
  81.  
  82. CloseFile(f);
  83.  
  84. Result := True;
  85. end;
  86.  
  87. Function LoadAFont(Filename : String; Size : Integer) : Boolean;
  88. var
  89. X : integer;
  90. begin
  91.  
  92. Result := False;
  93.  
  94. For x := 0 to Fonts.Font_No-1 do
  95. if Fonts.Font[x].Size = Size then
  96. begin
  97. Result := True;
  98. exit;
  99. end;
  100.  
  101. Inc(Fonts.Font_No);
  102. SetLength(Fonts.Font,Fonts.Font_No);
  103.  
  104. Result := LoadFont(Filename,Size,Fonts.Font[Fonts.Font_No-1]);
  105. If Not Result then
  106. begin
  107. Dec(Fonts.Font_No);
  108. SetLength(Fonts.Font,Fonts.Font_No);
  109. end;
  110.  
  111. end;
  112.  
  113. Procedure LoadFonts;
  114. begin
  115.  
  116. Fonts.Font_No := 0;
  117. SetLength(Fonts.Font,Fonts.Font_No);
  118.  
  119. LoadAFont(DoesFileExist('fonts\fontimage_12.dat'),12);
  120. LoadAFont(DoesFileExist('fonts\fontimage_16.dat'),16);
  121. LoadAFont(DoesFileExist('fonts\fontimage_17.dat'),17);
  122. LoadAFont(DoesFileExist('fonts\fontimage_24.dat'),24);  
  123.  
  124. BuildFonts;
  125.  
  126. end;
  127.  
  128. Function CharArrayToStr(Chars : Array of Char; Ammount : Integer) : String;
  129. var
  130. x : integer;
  131. begin
  132.  
  133. Result := '';
  134.  
  135. For x := 0 to Ammount-1 do
  136. If Chars[x] <> #0 then
  137. Result := Result + Chars[x]
  138. else
  139. Exit;
  140.  
  141. end;
  142.  
  143. Procedure BuildFont(Var Font : THelios_Font);
  144. Var
  145. I : Integer;
  146. S : Cardinal;
  147. CurTex,CurTex2 : String;
  148. begin
  149.   glLoadIdentity;
  150.   CurTex := '';
  151.   CurTex2 := '';
  152.  
  153.   s := 0;
  154.  
  155.   Font.DisplayList := glGenLists(256);
  156.   for I := 0 to 255 do
  157.   begin
  158.  
  159.     If (String(Font.Glyphs[I].ShaderName) <> CurTex2) then
  160.     begin
  161.     CurTex2 := String(Font.Glyphs[I].ShaderName);
  162.     CurTex := DoesFileExist(StringReplace(CharArrayToStr(Font.Glyphs[I].ShaderName,32), '/', '', [rfReplaceAll]));
  163.     If CurTex <> '' then
  164.     LoadTexture(CurTex,S,False,False,False);
  165.  
  166.     end;
  167.  
  168.     glNewList(Font.DisplayList+I, GL_COMPILE);       // Start Building A List
  169.     glBegin(GL_QUADS);
  170.  
  171.      glEnable(GL_TEXTURE_2D);
  172.      glEnable(GL_BLEND);
  173.      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  174.  
  175.       glBindTexture(GL_TEXTURE_2D, S);
  176.  
  177.       glTexCoord2f(Font.Glyphs[i].s,1-Font.Glyphs[i].t2);
  178.       glVertex2i(0, Font.Glyphs[i].top - Font.Glyphs[i].height);
  179.       glTexCoord2f(Font.Glyphs[i].s2, 1-Font.Glyphs[i].t2);
  180.       glVertex2i( Font.Glyphs[i].imageWidth, Font.Glyphs[i].top - Font.Glyphs[i].height);
  181.       glTexCoord2f(Font.Glyphs[i].s2, 1-Font.Glyphs[i].t);
  182.       glVertex2i( Font.Glyphs[i].imageWidth, Font.Glyphs[i].top - Font.Glyphs[i].height + Font.Glyphs[i].imageHeight);
  183.       glTexCoord2f(Font.Glyphs[i].s,1-Font.Glyphs[i].t);
  184.       glVertex2i(0, Font.Glyphs[i].top - Font.Glyphs[i].height + Font.Glyphs[i].imageHeight);
  185.     glEnd();
  186.    
  187.     If i = 32 then
  188.     glTranslatef(6, 0, 0)
  189.     else
  190.     glTranslatef(Font.Glyphs[I].imageWidth, 0, 0);
  191.     glEndList();
  192.   end;
  193.  
  194.   glDisable(GL_BLEND);
  195. end;
  196.  
  197. Procedure BuildFonts;
  198. var
  199. x : Integer;
  200. begin
  201.  
  202. if Fonts.Font_No > 0 then
  203. for x := 0 to Fonts.Font_No-1 do
  204. BuildFont(Fonts.Font[x]);
  205.  
  206. end;
  207.  
  208. Procedure WriteTextHN(X,Y : Single; S : Pchar; Font : THelios_Font);
  209. begin
  210.  
  211.   glLoadIdentity;
  212.   glTranslatef(x,y,0);
  213.  
  214. {  glEnable(GL_BLEND);
  215.   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); }
  216.  
  217.   glColor4f(1,1,1,1);//Colour.X,Colour.Y,Colour.Z,Alpha);
  218. //  glRasterPos2f(X, SCREEN_HEIGHT-Y);                        // Set the position for the text to be rendered
  219.   glPushAttrib (GL_LIST_BIT);
  220.     glListBase(Font.DisplayList);
  221.       glCallLists(length(S),GL_UNSIGNED_BYTE,S); // Write The Text To The Screen
  222.   glPopAttrib();
  223.   glDisable(GL_BLEND);
  224. end;
  225.  
  226. end.
  227.  

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 3 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.013s | 17 Queries | GZIP : On ]