1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 04_ftstrpnm_utf8.dpatch by Davide Viti <zinosat@tiscali.it>, 2007-01-16
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: [freetype1-tools] ftstrpnm should work with non-ASCII input (#407204)
7
## DP: I just discovered the ftstrpnm tool which is very useful for testing
8
## DP: font files without the need of installing them; unfortunately input is
9
## DP: limited to ASCII chars. The attached patch extends the support to wide
10
## DP: chars: the patch is less invasive as possible and I reckon there's
11
## DP: still space for loads of improvements.
13
## DP: See http://bugs.debian.org/407204 for further details.
16
diff -urNad freetype1-1.4pre.cvs20060210~/test/ftstrpnm.c freetype1-1.4pre.cvs20060210/test/ftstrpnm.c
17
--- freetype1-1.4pre.cvs20060210~/test/ftstrpnm.c 2001-12-26 04:14:29.000000000 +0800
18
+++ freetype1-1.4pre.cvs20060210/test/ftstrpnm.c 2007-09-08 05:27:40.000000000 +0800
29
/* glyph management */
31
- static void Load_Glyphs( char* txt, int txtlen )
32
+ static void Load_Glyphs( wchar_t* txt, int txtlen )
34
unsigned short i, n, code, load_flags;
35
unsigned short num_glyphs = 0, no_cmap = 0;
38
for ( i = 0; i < txtlen; ++i )
40
- unsigned char j = txt[i];
44
if ( TT_VALID( glyphs[j] ) )
48
/* rasterization stuff */
50
- static void Init_Raster_Areas( const char* txt, int txtlen )
51
+ static void Init_Raster_Areas( wchar_t* txt, int txtlen )
53
int i, upm, ascent, descent;
54
TT_Face_Properties properties;
57
for ( i = 0; i < txtlen; ++i )
59
- unsigned char j = txt[i];
63
if ( !TT_VALID( glyphs[j] ) )
66
TT_Get_Glyph_Metrics( glyphs[j], &gmetrics );
67
pnm_width += gmetrics.advance / 64;
71
Init_Raster_Map( &bit, pnm_width, pnm_height );
72
Clear_Raster_Map( &bit );
78
- static void Render_All_Glyphs( char* txt, int txtlen )
79
+ static void Render_All_Glyphs( wchar_t* txt, int txtlen )
82
TT_F26Dot6 x, y, adjx;
85
for ( i = 0; i < txtlen; i++ )
87
- unsigned char j = txt[i];
90
if ( !TT_VALID( glyphs[j] ) )
98
+ setlocale(LC_ALL, "");
104
txt = "The quick brown fox jumps over the lazy dog";
106
- txtlen = strlen( txt );
107
+ wp = (wchar_t *)malloc( strlen(txt) * sizeof(wchar_t) );
108
+ txtlen = mbstowcs(wp, txt, strlen(txt) * sizeof(wchar_t));
110
/* Initialize engine and other stuff */
112
@@ -507,12 +512,12 @@
113
Panic( "Error while initializing engine, code = 0x%x.\n", error );
115
Init_Face( filename );
116
- Load_Glyphs( txt, txtlen );
117
- Init_Raster_Areas( txt, txtlen );
119
+ Load_Glyphs( wp, txtlen );
120
+ Init_Raster_Areas( wp, txtlen );
121
/* Do the real work now */
122
+ Render_All_Glyphs( wp, txtlen );
124
- Render_All_Glyphs( txt, txtlen );
125
Dump_Raster_Map( &bit, stdout );