Commit f2438e1da975672c22e8794030e3c4450f7a3525

Werner Lemberg 2004-12-14T16:01:29

* src/base/ftbitmap.c, include/freetype/ftbitmap.h: New files for handling various bitmap formats. * include/freetype/config/ftheader.h (FT_BITMAP_H): New macro. * src/base/rules.mk (BASE_EXT_SRC): Add ftbitmap.c. * src/bdf/bdfdrivr.c (BDF_Glyph_Load): Don't convert bitmaps to 8bpp but return them as-is. * docs/CHANGES: Mention new bitmap API. * include/freetype/ftchapter.s: Updated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
diff --git a/ChangeLog b/ChangeLog
index 5274c64..8fb96f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2004-12-14  Werner Lemberg  <wl@gnu.org>
+
+	* src/base/ftbitmap.c, include/freetype/ftbitmap.h: New files for
+	handling various bitmap formats.
+
+	* include/freetype/config/ftheader.h (FT_BITMAP_H): New macro.
+
+	* src/base/rules.mk (BASE_EXT_SRC): Add ftbitmap.c.
+
+	* src/bdf/bdfdrivr.c (BDF_Glyph_Load): Don't convert bitmaps to 8bpp
+	but return them as-is.
+
+	* docs/CHANGES: Mention new bitmap API.
+	* include/freetype/ftchapter.s: Updated.
+
 2004-12-11  Robert Clark  <freetype@ratty.org.uk>
 
 	* src/base/ftobjs.c (FT_Get_Kerning): Make kerning amount
diff --git a/docs/CHANGES b/docs/CHANGES
index 2d07a12..24e4bf8 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -36,6 +36,18 @@ LATEST CHANGES BETWEEN 2.1.10 and 2.1.9
       JSTF).   After validation  it is  no longer  necessary to  check
       for errors in those tables while accessing them.
 
+    - A new API in FT_BITMAP_H  (`FT_Bitmap_New', `FT_Bitmap_Convert',
+      `FT_Bitmap_Done')  has  been  added.   Its  use  is  to  convert
+      an FT_Bitmap structure in 1bpp, 2bpp, 4bpp, or 8bpp format  into
+      another 8bpp FT_Bitmap, probably using a different pitch.
+
+  III. MISCELLANEOUS
+
+    - The BDF driver  no longer converts  all returned bitmaps  with a
+      depth of 2bpp or 4bpp to a depth of 8bpp.  The documentation has
+      not  mentioned  this  explicitly,  but  implementors  might have
+      relied on this after looking into the source files.
+
 
 LATEST CHANGES BETWEEN 2.1.9 and 2.1.8
 
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index 7b18813..a6df10d 100644
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -416,6 +416,18 @@
   /*************************************************************************/
   /*                                                                       */
   /* @macro:                                                               */
+  /*    FT_BITMAP_H                                                        */
+  /*                                                                       */
+  /* @description:                                                         */
+  /*    A macro used in #include statements to name the file containing    */
+  /*    the API of the optional bitmap conversion component.               */
+  /*                                                                       */
+#define FT_BITMAP_H  <freetype/ftbitmap.h>
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* @macro:                                                               */
   /*    FT_BBOX_H                                                          */
   /*                                                                       */
   /* @description:                                                         */
diff --git a/include/freetype/ftbitmap.h b/include/freetype/ftbitmap.h
new file mode 100644
index 0000000..d699238
--- /dev/null
+++ b/include/freetype/ftbitmap.h
@@ -0,0 +1,133 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftbitmap.h                                                             */
+/*                                                                         */
+/*    FreeType utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp */
+/*    bitmaps into 8bpp format (specification).                            */  
+/*                                                                         */
+/*  Copyright 2004 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef __FTBITMAP_H__
+#define __FTBITMAP_H__
+
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#ifdef FREETYPE_H
+#error "freetype.h of FreeType 1 has been loaded!"
+#error "Please fix the directory search order for header files"
+#error "so that freetype.h of FreeType 2 is found first."
+#endif
+
+
+FT_BEGIN_HEADER
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Section>                                                             */
+  /*    bitmap_handling                                                    */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_Bitmap_New                                                      */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Initialize a pointer to an FT_Bitmap structure.                    */
+  /*                                                                       */
+  /* <InOut>                                                               */
+  /*    abitmap :: A pointer to the bitmap structure.                      */
+  /*                                                                       */
+  FT_EXPORT( void )
+  FT_Bitmap_New( FT_Bitmap  *abitmap );
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_Bitmap_Convert                                                  */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, or 8bpp to a  */
+  /*    bitmap object with depth 8bpp, making the number of used bytes per */
+  /*    line (a.k.a. the `pitch') a multiple of `alignment'.               */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    library   :: A handle to a library object.                         */
+  /*                                                                       */
+  /*    source    :: The source bitmap.                                    */
+  /*                                                                       */
+  /*    alignment :: The pitch of the bitmap is a multiple of this         */
+  /*                 parameter.  Common values are 1, 2, or 4.             */
+  /*                                                                       */
+  /* <Output>                                                              */
+  /*    target    :: The target bitmap.                                    */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    It is possible to call @FT_Bitmap_Convert multiple times without   */
+  /*    calling @FT_Bitmap_Done (the memory is simply reallocated).        */
+  /*                                                                       */
+  /*    Use @FT_Bitmap_Done to finally remove the bitmap object.           */
+  /*                                                                       */
+  /*    The `library' argument is taken to have access to FreeType's       */
+  /*    memory handling functions.                                         */
+  /*                                                                       */
+  FT_EXPORT( FT_Error )
+  FT_Bitmap_Convert( FT_Library        library,
+                     const FT_Bitmap  *source,
+                     FT_Bitmap        *target,
+                     FT_Int            alignment );
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_Bitmap_Done                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Destroy a bitmap object created with @FT_Bitmap_New.               */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    library :: A handle to a library object.                           */
+  /*                                                                       */
+  /*    bitmap  :: The bitmap object to be freed.                          */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    The `library' argument is taken to have access to FreeType's       */
+  /*    memory handling functions.                                         */
+  /*                                                                       */
+  FT_EXPORT( FT_Error )
+  FT_Bitmap_Done( FT_Library  library,
+                  FT_Bitmap  *bitmap );
+
+
+  /* */
+
+
+FT_END_HEADER
+
+#endif /* __FTBITMAP_H__ */
+
+
+/* END */
diff --git a/include/freetype/ftchapters.h b/include/freetype/ftchapters.h
index 4628599..781160b 100644
--- a/include/freetype/ftchapters.h
+++ b/include/freetype/ftchapters.h
@@ -71,6 +71,7 @@
 /*    computations                                                         */
 /*    list_processing                                                      */
 /*    outline_processing                                                   */
+/*    bitmap_handling                                                      */
 /*    raster                                                               */
 /*    glyph_stroker                                                        */
 /*    system_interface                                                     */
@@ -79,4 +80,3 @@
 /*    lzw                                                                  */
 /*                                                                         */
 /***************************************************************************/
-
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
new file mode 100644
index 0000000..3e3d0fc
--- /dev/null
+++ b/src/base/ftbitmap.c
@@ -0,0 +1,262 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftbitmap.c                                                             */
+/*                                                                         */
+/*    FreeType utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp */
+/*    bitmaps into 8bpp format (body).                                     */
+/*                                                                         */
+/*  Copyright 2004 by                                                      */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_IMAGE_H
+#include FT_INTERNAL_OBJECTS_H
+
+
+  static
+  const FT_Bitmap  null_bitmap = { 0, 0, 0, 0, 0, 0, 0, 0 };
+
+
+  /* documentation is in ftbitmap.h */
+
+  FT_EXPORT_DEF( void )
+  FT_Bitmap_New( FT_Bitmap  *abitmap )
+  {
+    *abitmap = null_bitmap;
+  }
+
+
+  /* documentation is in ftbitmap.h */
+
+  FT_EXPORT_DEF( FT_Error )
+  FT_Bitmap_Convert( FT_Library        library,
+                     const FT_Bitmap  *source,
+                     FT_Bitmap        *target,
+                     FT_Int            alignment )
+  {
+    FT_Error   error;
+    FT_Memory  memory;
+    FT_Int     i, j, old_size;
+    FT_Byte    *s, *ss, *t, *tt;
+
+
+    if ( !library )
+      return FT_Err_Invalid_Library_Handle;
+
+    memory = library->memory;
+
+    switch ( source->pixel_mode )
+    {
+    case FT_PIXEL_MODE_MONO:
+    case FT_PIXEL_MODE_GRAY:
+    case FT_PIXEL_MODE_GRAY2:
+    case FT_PIXEL_MODE_GRAY4:
+      old_size = target->rows * target->pitch;
+
+      target->pixel_mode = FT_PIXEL_MODE_GRAY;
+      target->rows       = source->rows;
+      target->width      = source->width;
+      target->pitch      = ( source->width + alignment - 1 )
+                             / alignment * alignment;
+
+      if ( target->rows * target->pitch > old_size )
+        if ( FT_QREALLOC( target->buffer,
+                          old_size, target->rows * target->pitch ) )
+          return error;
+
+      break;
+
+    default:
+      error = FT_Err_Invalid_Argument;
+    }
+
+    s = source->buffer;
+    t = target->buffer;
+
+    switch ( source->pixel_mode )
+    {
+    case FT_PIXEL_MODE_MONO:
+      target->num_grays = 2;
+
+      for ( i = 0; i < source->rows; i++ )
+      {
+        ss = s;
+        tt = t;
+
+        /* get the full bytes */
+        for ( j = 0; j < ( source->width >> 3 ); j++ )
+        {
+          *(tt++) = (FT_Byte)( ( *ss & 0x80 ) >> 7 );
+          *(tt++) = (FT_Byte)( ( *ss & 0x40 ) >> 6 );
+          *(tt++) = (FT_Byte)( ( *ss & 0x20 ) >> 5 );
+          *(tt++) = (FT_Byte)( ( *ss & 0x10 ) >> 4 );
+          *(tt++) = (FT_Byte)( ( *ss & 0x08 ) >> 3 );
+          *(tt++) = (FT_Byte)( ( *ss & 0x04 ) >> 2 );
+          *(tt++) = (FT_Byte)( ( *ss & 0x02 ) >> 1 );
+          *(tt++) = (FT_Byte)(   *ss & 0x01 );
+
+          ss++;
+        }
+
+        /* get remaining pixels (if any) */
+        switch ( source->width & 7 )
+        {
+        case 7:
+          *(tt++) = (FT_Byte)( ( *ss & 0x80 ) >> 7 );
+          /* fall through */
+        case 6:
+          *(tt++) = (FT_Byte)( ( *ss & 0x40 ) >> 6 );
+          /* fall through */
+        case 5:
+          *(tt++) = (FT_Byte)( ( *ss & 0x20 ) >> 5 );
+          /* fall through */
+        case 4:
+          *(tt++) = (FT_Byte)( ( *ss & 0x10 ) >> 4 );
+          /* fall through */
+        case 3:
+          *(tt++) = (FT_Byte)( ( *ss & 0x08 ) >> 3 );
+          /* fall through */
+        case 2:
+          *(tt++) = (FT_Byte)( ( *ss & 0x04 ) >> 2 );
+          /* fall through */
+        case 1:
+          *(tt++) = (FT_Byte)( ( *ss & 0x02 ) >> 1 );
+          /* fall through */
+        case 0:
+          break;
+        }
+
+        s += source->pitch;
+        t += target->pitch;
+      }
+      break;
+
+    case FT_PIXEL_MODE_GRAY:
+      target->num_grays = 256;
+
+      for ( i = 0; i < source->rows; i++ )
+      {
+        ss = s;
+        tt = t;
+
+        for ( j = 0; j < source->width; j++ )
+          *(tt++) = *(ss++);
+
+        s += source->pitch;
+        t += target->pitch;
+      }
+      break;
+
+    case FT_PIXEL_MODE_GRAY2:
+      target->num_grays = 4;
+
+      for ( i = 0; i < source->rows; i++ )
+      {
+        ss = s;
+        tt = t;
+
+        /* get the full bytes */
+        for ( j = 0; j < ( source->width >> 2 ); j++ )
+        {
+          *(tt++) = (FT_Byte)( ( *ss & 0xC0 ) >> 6 );
+          *(tt++) = (FT_Byte)( ( *ss & 0x30 ) >> 4 );
+          *(tt++) = (FT_Byte)( ( *ss & 0x0C ) >> 2 );
+          *(tt++) = (FT_Byte)(   *ss & 0x03 );
+
+          ss++;
+        }
+
+        /* get remaining pixels (if any) */
+        switch ( source->width & 3 )
+        {
+        case 3:
+          *(tt++) = (FT_Byte)( ( *ss & 0xC0 ) >> 6 );
+          /* fall through */
+        case 2:
+          *(tt++) = (FT_Byte)( ( *ss & 0x30 ) >> 4 );
+          /* fall through */
+        case 1:
+          *(tt++) = (FT_Byte)( ( *ss & 0x0C ) >> 2 );
+          /* fall through */
+        case 0:
+          break;
+        }
+
+        s += source->pitch;
+        t += target->pitch;
+      }
+      break;
+
+    case FT_PIXEL_MODE_GRAY4:
+      target->num_grays = 16;
+
+      for ( i = 0; i < source->rows; i++ )
+      {
+        ss = s;
+        tt = t;
+
+        /* get the full bytes */
+        for ( j = 0; j < ( source->width >> 1 ); j++ )
+        {
+          *(tt++) = (FT_Byte)( ( *ss & 0xF0 ) >> 4 );
+          *(tt++) = (FT_Byte)(   *ss & 0x0F );
+
+          ss++;
+        }
+
+        /* get remaining pixels (if any) */
+        switch ( source->width & 1 )
+        {
+        case 1:
+          *(tt++) = (FT_Byte)( ( *ss & 0xF0 ) >> 4 );
+          /* fall through */
+        case 0:
+          break;
+        }
+
+        s += source->pitch;
+        t += target->pitch;
+      }
+      break;
+
+    }
+
+    return error;
+  }
+
+
+  /* documentation is in ftbitmap.h */
+
+  FT_EXPORT_DEF( FT_Error )
+  FT_Bitmap_Done( FT_Library  library,
+                  FT_Bitmap  *bitmap )
+  {
+    FT_Memory  memory;
+
+
+    if ( !library )
+      return FT_Err_Invalid_Library_Handle;
+
+    if ( !bitmap )
+      return FT_Err_Invalid_Argument;
+
+    memory = library->memory;
+
+    FT_FREE( bitmap->buffer );
+    *bitmap = null_bitmap;
+
+    return FT_Err_Ok;
+  }
+
+
+/* END */
diff --git a/src/base/rules.mk b/src/base/rules.mk
index 74e66e2..993b532 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -50,7 +50,8 @@ BASE_SRC := $(BASE_DIR)/ftapi.c    \
 # object.  It will then be linked to the final executable only if one of its
 # symbols is used by the application.
 #
-BASE_EXT_SRC := $(BASE_DIR)/ftbbox.c   \
+BASE_EXT_SRC := $(BASE_DIR)/ftbitmap.c \
+                $(BASE_DIR)/ftbbox.c   \
                 $(BASE_DIR)/ftbdf.c    \
                 $(BASE_DIR)/ftglyph.c  \
                 $(BASE_DIR)/ftmm.c     \
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index b32e70d..b28e7c3 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -643,13 +643,11 @@ THE SOFTWARE.
                   FT_UInt       glyph_index,
                   FT_Int32      load_flags )
   {
-    BDF_Face       face   = (BDF_Face)FT_SIZE_FACE( size );
-    FT_Error       error  = BDF_Err_Ok;
-    FT_Bitmap*     bitmap = &slot->bitmap;
-    bdf_glyph_t    glyph;
-    int            bpp    = face->bdffont->bpp;
-    int            i, j, count;
-    unsigned char  *p, *pp;
+    BDF_Face     face   = (BDF_Face)FT_SIZE_FACE( size );
+    FT_Error     error  = BDF_Err_Ok;
+    FT_Bitmap*   bitmap = &slot->bitmap;
+    bdf_glyph_t  glyph;
+    int          bpp    = face->bdffont->bpp;
 
     FT_UNUSED( load_flags );
 
@@ -671,109 +669,27 @@ THE SOFTWARE.
 
     bitmap->rows  = glyph.bbx.height;
     bitmap->width = glyph.bbx.width;
+    bitmap->pitch = glyph.bpr;
 
-    if ( bpp == 1 )
-    {
-      bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
-      bitmap->pitch      = glyph.bpr;
+    /* note: we don't allocate a new array to hold the bitmap; */
+    /*       we can simply point to it                         */
+    ft_glyphslot_set_bitmap( slot, glyph.bitmap );
 
-      /* note: we don't allocate a new array to hold the bitmap; */
-      /*       we can simply point to it                         */
-      ft_glyphslot_set_bitmap( slot, glyph.bitmap );
-    }
-    else
+    switch ( bpp )
     {
-      /* blow up pixmap to have 8 bits per pixel */
+    case 1:
+      bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
+      break;
+    case 2:
+      bitmap->pixel_mode = FT_PIXEL_MODE_GRAY2;
+      break;
+    case 4:
+      bitmap->pixel_mode = FT_PIXEL_MODE_GRAY4;
+      break;
+    case 8:
       bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
-      bitmap->pitch      = bitmap->width;
-
-      error = ft_glyphslot_alloc_bitmap( slot, bitmap->rows * bitmap->pitch );
-      if ( error )
-        goto Exit;
-
-      switch ( bpp )
-      {
-      case 2:
-        bitmap->num_grays = 4;
-
-        count = 0;
-        p     = glyph.bitmap;
-
-        for ( i = 0; i < bitmap->rows; i++ )
-        {
-          pp = p;
-
-          /* get the full bytes */
-          for ( j = 0; j < ( bitmap->width >> 2 ); j++ )
-          {
-            bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0xC0 ) >> 6 );
-            bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0x30 ) >> 4 );
-            bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0x0C ) >> 2 );
-            bitmap->buffer[count++] = (FT_Byte)(   *pp & 0x03 );
-
-            pp++;
-          }
-
-          /* get remaining pixels (if any) */
-          switch ( bitmap->width & 3 )
-          {
-          case 3:
-            bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0xC0 ) >> 6 );
-            /* fall through */
-          case 2:
-            bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0x30 ) >> 4 );
-            /* fall through */
-          case 1:
-            bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0x0C ) >> 2 );
-            /* fall through */
-          case 0:
-            break;
-          }
-
-          p += glyph.bpr;
-        }
-        break;
-
-      case 4:
-        bitmap->num_grays = 16;
-
-        count = 0;
-        p     = glyph.bitmap;
-
-        for ( i = 0; i < bitmap->rows; i++ )
-        {
-          pp = p;
-
-          /* get the full bytes */
-          for ( j = 0; j < ( bitmap->width >> 1 ); j++ )
-          {
-            bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0xF0 ) >> 4 );
-            bitmap->buffer[count++] = (FT_Byte)(   *pp & 0x0F );
-
-            pp++;
-          }
-
-          /* get remaining pixel (if any) */
-          switch ( bitmap->width & 1 )
-          {
-          case 1:
-            bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0xF0 ) >> 4 );
-            /* fall through */
-          case 0:
-            break;
-          }
-
-          p += glyph.bpr;
-        }
-        break;
-
-      case 8:
-        bitmap->num_grays = 256;
-
-        FT_MEM_COPY( bitmap->buffer, glyph.bitmap,
-                     bitmap->rows * bitmap->pitch );
-        break;
-      }
+      bitmap->num_grays  = 256;
+      break;
     }
 
     slot->bitmap_left = glyph.bbx.x_offset;