|
From: <cn...@us...> - 2009-06-20 23:08:44
|
Revision: 346
http://hgengine.svn.sourceforge.net/hgengine/?rev=346&view=rev
Author: cnlohr
Date: 2009-06-20 23:08:43 +0000 (Sat, 20 Jun 2009)
Log Message:
-----------
update
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-06-19 04:21:37 UTC (rev 345)
+++ Mercury2/tools/fonter/main.cpp 2009-06-20 23:08:43 UTC (rev 346)
@@ -35,7 +35,7 @@
// imagedata[(x+y*1024)*4+3] = 255; //alpha
}
- my_read_font( argv[1], imagedata, 64, 64, 16, 16 );
+ my_read_font( argv[1], imagedata, 64, 64, 16, 8 );
my_write_png( argv[2], imagedata, 1024, 1024 );
}
@@ -68,41 +68,65 @@
exit( -1 );
}
- error = FT_Set_Pixel_Sizes( face, 0, 64 );
+ error = FT_Set_Pixel_Sizes( face, 0, 54 );
if( error )
{
fprintf( stderr, "Error with FT_Set_Pixel_Sizes\n" );
exit( -3 );
}
- glyph_index = FT_Get_Char_Index( face, 65 );
+ for( int ch = 0; ch < xq * yq; ch++ )
+ {
+ glyph_index = FT_Get_Char_Index( face, ch );
+
+ error = FT_Load_Glyph( face, glyph_index, 0 ); //FT_LOAD_NO_BITMAP (try as last parameter)
+
+ if( error )
+ {
+ fprintf( stderr, "FT_Load_Glyph had a problem.\n" );
+ exit( -4 );
+ }
+
+ error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL ); //try FT_LOAD_NO_HINTING
+ if( error )
+ {
+ fprintf( stderr, "FT_Render_Glyph had a problem.\n" );
+ exit( -4 );
+ }
- error = FT_Load_Glyph( face,
- glyph_index, 0 ); //FT_LOAD_NO_BITMAP (try as last thing)
+ FT_Bitmap l_bitmap = face->glyph->bitmap;
- if( error )
- {
- fprintf( stderr, "FT_Load_Glyph had a problem.\n" );
- exit( -4 );
+ printf( "%d (%c) %d %d\n", ch, ch, face->glyph->bitmap_left, face->glyph->bitmap_top );
+
+ for( int x = 0; x < xpp; x++ )
+ for( int y = 0; y < ypp; y++ )
+ {
+ int offx = x+(xpp*(ch%xq)) + face->glyph->bitmap_left+0;
+ int offy = y+(ypp*(ch/xq)) - face->glyph->bitmap_top+64;
+
+ if( x >= l_bitmap.width ) continue;
+ if( y >= l_bitmap.rows ) continue;
+
+ if( offx < 0 || offx >= xq*xpp ) continue;
+ if( offy < 0 || offy >= yq*ypp ) continue;
+
+ imagedata[(offx + offy*(xq*xpp))*2+1] = l_bitmap.buffer[x+y*l_bitmap.pitch ];
+ imagedata[(offx + offy*(xq*xpp))*2+0] = 0;
+ }
}
- error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL );
- if( error )
+ for( int x = 0; x < 1024; x+=64 )
+ for( int y = 0; y < 1024; y++ )
{
- fprintf( stderr, "FT_Render_Glyph had a problem.\n" );
- exit( -4 );
+ imagedata[(x+y*(xq*xpp))*2+0] = 0;
+ imagedata[(x+y*(xq*xpp))*2+1] = 255;
}
-
- FT_Bitmap l_bitmap = face->glyph->bitmap;
-
for( int x = 0; x < 1024; x++ )
- for( int y = 0; y < 1024; y++ )
- {
- if( x > l_bitmap.width ) continue;
- if( y > l_bitmap.rows ) continue;
- imagedata[(x+y*1024)*2+1] = face->glyph->bitmap.buffer[x+y*l_bitmap.width ];
- }
-
+ for( int y = 0; y < 1024; y+=64 )
+ {
+ imagedata[(x+y*(xq*xpp))*2+0] = 0;
+ imagedata[(x+y*(xq*xpp))*2+1] = 255;
+ }
}
int my_write_png( const char * fname, unsigned char * imagedata, int width, int height )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-21 00:10:50
|
Revision: 347
http://hgengine.svn.sourceforge.net/hgengine/?rev=347&view=rev
Author: cnlohr
Date: 2009-06-21 00:10:49 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
better font tool
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-06-20 23:08:43 UTC (rev 346)
+++ Mercury2/tools/fonter/main.cpp 2009-06-21 00:10:49 UTC (rev 347)
@@ -8,9 +8,8 @@
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#endif
+FILE * fontfile;
-FILE * fout;
-
int my_write_png( const char * fname, unsigned char * imagedata, int x, int y );
int my_read_font( const char * fname, unsigned char * imagedata, int xpp, int ypp, int xq, int yq );
@@ -22,7 +21,7 @@
if( argc != 3 )
{
fprintf( stderr, "Mercury Fonter\n" );
- fprintf( stderr, "Usage: %s [font file] [output png]\n", argv[0] );
+ fprintf( stderr, "Usage: %s [font file] [font name]\n", argv[0] );
exit( -1 );
}
@@ -35,8 +34,22 @@
// imagedata[(x+y*1024)*4+3] = 255; //alpha
}
- my_read_font( argv[1], imagedata, 64, 64, 16, 8 );
- my_write_png( argv[2], imagedata, 1024, 1024 );
+ char fname[1024];
+ char pngname[1024];
+
+ sprintf( fname, "%s.%s", argv[2], "hgfont" );
+ sprintf( pngname, "%s.%s", argv[2], "png" );
+
+ fontfile = fopen( fname, "w" );
+ if( !fontfile )
+ {
+ fprintf( stderr, "Could not open font output file: %s\n", fname );
+ exit( -1 );
+ }
+ fprintf( fontfile, "%s\n", pngname );
+
+ my_read_font( argv[1], imagedata, 64, 64, 16, 16 );
+ my_write_png( pngname, imagedata, 1024, 1024 );
}
int my_read_font( const char * fname, unsigned char * imagedata, int xpp, int ypp, int xq, int yq )
@@ -68,16 +81,17 @@
exit( -1 );
}
- error = FT_Set_Pixel_Sizes( face, 0, 54 );
+ error = FT_Set_Pixel_Sizes( face, 0, 64 );
if( error )
{
fprintf( stderr, "Error with FT_Set_Pixel_Sizes\n" );
exit( -3 );
}
+ int actualchar = 0;
for( int ch = 0; ch < xq * yq; ch++ )
{
- glyph_index = FT_Get_Char_Index( face, ch );
+ glyph_index = FT_Get_Char_Index( face, actualchar );
error = FT_Load_Glyph( face, glyph_index, 0 ); //FT_LOAD_NO_BITMAP (try as last parameter)
@@ -96,13 +110,13 @@
FT_Bitmap l_bitmap = face->glyph->bitmap;
- printf( "%d (%c) %d %d\n", ch, ch, face->glyph->bitmap_left, face->glyph->bitmap_top );
-
+ int goffx = (xpp*(ch%xq));
+ int goffy = (ypp*(ch/xq));
for( int x = 0; x < xpp; x++ )
for( int y = 0; y < ypp; y++ )
{
- int offx = x+(xpp*(ch%xq)) + face->glyph->bitmap_left+0;
- int offy = y+(ypp*(ch/xq)) - face->glyph->bitmap_top+64;
+ int offx = x+goffx;
+ int offy = y+goffy;
if( x >= l_bitmap.width ) continue;
if( y >= l_bitmap.rows ) continue;
@@ -112,7 +126,18 @@
imagedata[(offx + offy*(xq*xpp))*2+1] = l_bitmap.buffer[x+y*l_bitmap.pitch ];
imagedata[(offx + offy*(xq*xpp))*2+0] = 0;
+
}
+
+ float loffx = float(goffx)/float(xpp*xq);
+ float loffy = float(goffy)/float(ypp*yq);
+ float loffxe = float(goffx+l_bitmap.width)/float(xpp*xq);
+ float loffye = float(goffy+l_bitmap.rows)/float(ypp*yq);
+
+ fprintf( fontfile, "%d %f %f %f %f %d %d %d %d\n", actualchar, loffx, loffy, loffxe, loffye,
+ l_bitmap.width, l_bitmap.rows, face->glyph->bitmap_left, face->glyph->bitmap_top );
+
+ actualchar++;
}
for( int x = 0; x < 1024; x+=64 )
@@ -131,6 +156,7 @@
int my_write_png( const char * fname, unsigned char * imagedata, int width, int height )
{
+ FILE * fout;
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 k;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-21 01:22:49
|
Revision: 348
http://hgengine.svn.sourceforge.net/hgengine/?rev=348&view=rev
Author: cnlohr
Date: 2009-06-21 00:50:41 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
get closer to actual run
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-06-21 00:10:49 UTC (rev 347)
+++ Mercury2/tools/fonter/main.cpp 2009-06-21 00:50:41 UTC (rev 348)
@@ -29,7 +29,7 @@
for( int y = 0; y < 1024; y++ )
{
imagedata[(x+y*1024)*2+0] = 255; //red
- imagedata[(x+y*1024)*2+1] = 255; //alpha
+ imagedata[(x+y*1024)*2+1] = 0; //alpha
// imagedata[(x+y*1024)*4+2] = 255; //blue
// imagedata[(x+y*1024)*4+3] = 255; //alpha
}
@@ -125,7 +125,7 @@
if( offy < 0 || offy >= yq*ypp ) continue;
imagedata[(offx + offy*(xq*xpp))*2+1] = l_bitmap.buffer[x+y*l_bitmap.pitch ];
- imagedata[(offx + offy*(xq*xpp))*2+0] = 0;
+ imagedata[(offx + offy*(xq*xpp))*2+0] = 255;
}
@@ -140,6 +140,8 @@
actualchar++;
}
+
+/* Draw grid
for( int x = 0; x < 1024; x+=64 )
for( int y = 0; y < 1024; y++ )
{
@@ -152,6 +154,7 @@
imagedata[(x+y*(xq*xpp))*2+0] = 0;
imagedata[(x+y*(xq*xpp))*2+1] = 255;
}
+*/
}
int my_write_png( const char * fname, unsigned char * imagedata, int width, int height )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-23 04:54:19
|
Revision: 361
http://hgengine.svn.sourceforge.net/hgengine/?rev=361&view=rev
Author: cnlohr
Date: 2009-06-23 04:54:16 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
cleanup font size and names of files
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-06-23 04:53:59 UTC (rev 360)
+++ Mercury2/tools/fonter/main.cpp 2009-06-23 04:54:16 UTC (rev 361)
@@ -8,6 +8,8 @@
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#endif
+#define FONTSIZE 64
+
FILE * fontfile;
int my_write_png( const char * fname, unsigned char * imagedata, int x, int y );
@@ -46,7 +48,7 @@
fprintf( stderr, "Could not open font output file: %s\n", fname );
exit( -1 );
}
- fprintf( fontfile, "%s\n", pngname );
+ fprintf( fontfile, "%s\n%d\n", pngname, FONTSIZE );
my_read_font( argv[1], imagedata, 64, 64, 16, 16 );
my_write_png( pngname, imagedata, 1024, 1024 );
@@ -81,7 +83,7 @@
exit( -1 );
}
- error = FT_Set_Pixel_Sizes( face, 0, 64 );
+ error = FT_Set_Pixel_Sizes( face, 0, FONTSIZE );
if( error )
{
fprintf( stderr, "Error with FT_Set_Pixel_Sizes\n" );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-06-25 03:29:10
|
Revision: 373
http://hgengine.svn.sourceforge.net/hgengine/?rev=373&view=rev
Author: cnlohr
Date: 2009-06-25 03:29:06 +0000 (Thu, 25 Jun 2009)
Log Message:
-----------
add default values to font (space, tab, advance)
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-06-24 10:28:29 UTC (rev 372)
+++ Mercury2/tools/fonter/main.cpp 2009-06-25 03:29:06 UTC (rev 373)
@@ -48,7 +48,7 @@
fprintf( stderr, "Could not open font output file: %s\n", fname );
exit( -1 );
}
- fprintf( fontfile, "%s\n%d\n", pngname, FONTSIZE );
+ fprintf( fontfile, "%s\n%d %f %f %f\n", pngname, FONTSIZE, 4, 15, 80 );
my_read_font( argv[1], imagedata, 64, 64, 16, 16 );
my_write_png( pngname, imagedata, 1024, 1024 );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-10-22 19:51:33
|
Revision: 578
http://hgengine.svn.sourceforge.net/hgengine/?rev=578&view=rev
Author: cnlohr
Date: 2009-10-22 19:51:23 +0000 (Thu, 22 Oct 2009)
Log Message:
-----------
elaborate on fixed width-ness
Modified Paths:
--------------
Mercury2/tools/fonter/main.cpp
Modified: Mercury2/tools/fonter/main.cpp
===================================================================
--- Mercury2/tools/fonter/main.cpp 2009-10-22 19:17:38 UTC (rev 577)
+++ Mercury2/tools/fonter/main.cpp 2009-10-22 19:51:23 UTC (rev 578)
@@ -12,6 +12,8 @@
FILE * fontfile;
+int iForceWidth = -1;
+
int my_write_png( const char * fname, unsigned char * imagedata, int x, int y );
int my_read_font( const char * fname, unsigned char * imagedata, int xpp, int ypp, int xq, int yq );
@@ -20,13 +22,18 @@
unsigned char imagedata[1024*1024*4];
int x, y;
- if( argc != 3 )
+ if( argc != 3 && argc != 4 )
{
fprintf( stderr, "Mercury Fonter\n" );
- fprintf( stderr, "Usage: %s [font file] [font name]\n", argv[0] );
+ fprintf( stderr, "Usage: %s [font file] [font name] [forced with (optional)]\n", argv[0] );
exit( -1 );
}
+ if( argc == 4 )
+ {
+ iForceWidth = atoi( argv[3] );
+ }
+
for( int x = 0; x < 1024; x++ )
for( int y = 0; y < 1024; y++ )
{
@@ -114,10 +121,14 @@
int goffx = (xpp*(ch%xq));
int goffy = (ypp*(ch/xq));
+
+ int localoffx = 0;
+ if( iForceWidth > 0 )
+ localoffx += (iForceWidth - l_bitmap.width) / 2;
for( int x = 0; x < xpp; x++ )
for( int y = 0; y < ypp; y++ )
{
- int offx = x+goffx;
+ int offx = x+goffx + localoffx;
int offy = y+goffy;
if( x >= l_bitmap.width ) continue;
@@ -131,13 +142,21 @@
}
- float loffx = float(goffx)/float(xpp*xq);
+ int iW = l_bitmap.width;
+ if( iForceWidth > 0 )
+ {
+ iW = iForceWidth;
+ }
+
+ float xppoffset = 0;
+
+ float loffx = float(goffx+xppoffset)/float(xpp*xq);
float loffy = float(goffy)/float(ypp*yq);
- float loffxe = float(goffx+l_bitmap.width)/float(xpp*xq);
+ float loffxe = float(goffx+iW+xppoffset)/float(xpp*xq);
float loffye = float(goffy+l_bitmap.rows)/float(ypp*yq);
fprintf( fontfile, "%d %f %f %f %f %d %d %d %d\n", actualchar, loffx, loffy, loffxe, loffye,
- l_bitmap.width, l_bitmap.rows, face->glyph->bitmap_left, face->glyph->bitmap_top );
+ iW, l_bitmap.rows, face->glyph->bitmap_left, face->glyph->bitmap_top );
actualchar++;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|