misc/libfreetype/src/pcf/pcfutil.c
author nemo
Sun, 25 Sep 2011 15:40:01 -0400
changeset 6028 335eaf56d976
parent 5172 88f2e05288ba
permissions -rw-r--r--
rename to match prior mass hat rename
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
Copyright 1990, 1994, 1998  The Open Group
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
Permission to use, copy, modify, distribute, and sell this software and its
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
documentation for any purpose is hereby granted without fee, provided that
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
the above copyright notice appear in all copies and that both that
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
copyright notice and this permission notice appear in supporting
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
documentation.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
The above copyright notice and this permission notice shall be included in
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
all copies or substantial portions of the Software.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
Except as contained in this notice, the name of The Open Group shall not be
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
used in advertising or otherwise to promote the sale, use or other dealings
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
in this Software without prior written authorization from The Open Group.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
*/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
/* $XFree86: xc/lib/font/util/utilbitmap.c,v 1.3 1999/08/22 08:58:58 dawes Exp $ */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
/*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
 * Author:  Keith Packard, MIT X Consortium
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
/* Modified for use with FreeType */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
#include "pcfutil.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
   *  Invert bit order within each BYTE of an array.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  BitOrderInvert( unsigned char*  buf,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
                  size_t          nbytes )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    for ( ; nbytes > 0; nbytes--, buf++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
      unsigned int  val = *buf;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
      val = ( ( val >> 1 ) & 0x55 ) | ( ( val << 1 ) & 0xAA );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
      val = ( ( val >> 2 ) & 0x33 ) | ( ( val << 2 ) & 0xCC );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
      val = ( ( val >> 4 ) & 0x0F ) | ( ( val << 4 ) & 0xF0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
      *buf = (unsigned char)val;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
   *  Invert byte order within each 16-bits of an array.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
  TwoByteSwap( unsigned char*  buf,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
               size_t          nbytes )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    unsigned char  c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    for ( ; nbytes >= 2; nbytes -= 2, buf += 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
      c      = buf[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
      buf[0] = buf[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
      buf[1] = c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
   *  Invert byte order within each 32-bits of an array.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
  FourByteSwap( unsigned char*  buf,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
                size_t          nbytes )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    unsigned char  c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    for ( ; nbytes >= 4; nbytes -= 4, buf += 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
      c      = buf[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
      buf[0] = buf[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
      buf[3] = c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
      c      = buf[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
      buf[1] = buf[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
      buf[2] = c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
/* END */