/[freetype]/freetype2/src/pfr/pfrobjs.c
ViewVC logotype

Diff of /freetype2/src/pfr/pfrobjs.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.26 by freetype, Thu Mar 3 14:00:23 2005 UTC revision 1.27 by wl, Thu Mar 3 23:05:29 2005 UTC
# Line 4  Line 4 
4  /*                                                                         */  /*                                                                         */
5  /*    FreeType PFR object methods (body).                                  */  /*    FreeType PFR object methods (body).                                  */
6  /*                                                                         */  /*                                                                         */
7  /*  Copyright 2002, 2003, 2004 by                                          */  /*  Copyright 2002, 2003, 2004, 2005 by                                    */
8  /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */  /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
9  /*                                                                         */  /*                                                                         */
10  /*  This file is part of the FreeType project, and may only be used,       */  /*  This file is part of the FreeType project, and may only be used,       */
# Line 361  Line 361 
361        metrics->vertBearingX = 0;        metrics->vertBearingX = 0;
362        metrics->vertBearingY = 0;        metrics->vertBearingY = 0;
363    
364  #if 0 /* some fonts seem to be broken here !! */  #if 0 /* some fonts seem to be broken here! */
365    
366        /* Apply the font matrix, if any.                 */        /* Apply the font matrix, if any.                 */
367        /* TODO: Test existing fonts with unusual matrix  */        /* TODO: Test existing fonts with unusual matrix  */
# Line 423  Line 423 
423    /*************************************************************************/    /*************************************************************************/
424    
425  #ifdef FT_OPTIMIZE_MEMORY  #ifdef FT_OPTIMIZE_MEMORY
426    
427    FT_LOCAL_DEF( FT_Error )    FT_LOCAL_DEF( FT_Error )
428    pfr_face_get_kerning( FT_Face     pfrface,        /* PFR_Face */    pfr_face_get_kerning( FT_Face     pfrface,        /* PFR_Face */
429                          FT_UInt     glyph1,                          FT_UInt     glyph1,
430                          FT_UInt     glyph2,                          FT_UInt     glyph2,
431                          FT_Vector*  kerning )                          FT_Vector*  kerning )
432    {    {
433      PFR_Face      face     = (PFR_Face)pfrface;      PFR_Face     face     = (PFR_Face)pfrface;
434      FT_Error      error    = PFR_Err_Ok;      FT_Error     error    = PFR_Err_Ok;
435      PFR_PhyFont   phy_font = &face->phy_font;      PFR_PhyFont  phy_font = &face->phy_font;
436      FT_UInt32     code1, code2, pair;      FT_UInt32    code1, code2, pair;
437    
438    
439      kerning->x = 0;      kerning->x = 0;
440      kerning->y = 0;      kerning->y = 0;
# Line 450  Line 452 
452    
453      code1 = phy_font->chars[glyph1].char_code;      code1 = phy_font->chars[glyph1].char_code;
454      code2 = phy_font->chars[glyph2].char_code;      code2 = phy_font->chars[glyph2].char_code;
455      pair  = PFR_KERN_INDEX(code1,code2);      pair  = PFR_KERN_INDEX( code1, code2 );
456    
457      /* now search the list of kerning items */      /* now search the list of kerning items */
458      {      {
459        PFR_KernItem  item   = phy_font->kern_items;        PFR_KernItem  item   = phy_font->kern_items;
460        FT_Stream     stream = pfrface->stream;        FT_Stream     stream = pfrface->stream;
461    
462    
463        for ( ; item; item = item->next )        for ( ; item; item = item->next )
464        {        {
465          if ( pair >= item->pair1 && pair <= item->pair2 )          if ( pair >= item->pair1 && pair <= item->pair2 )
# Line 465  Line 468 
468        goto Exit;        goto Exit;
469    
470      FoundPair: /* we found an item, now parse it and find the value if any */      FoundPair: /* we found an item, now parse it and find the value if any */
471        if ( FT_STREAM_SEEK( item->offset )                     ||        if ( FT_STREAM_SEEK( item->offset )                       ||
472             FT_FRAME_ENTER( item->pair_count*item->pair_size ) )             FT_FRAME_ENTER( item->pair_count * item->pair_size ) )
473          goto Exit;          goto Exit;
474    
475        {        {
476          FT_UInt   count    = item->pair_count;          FT_UInt    count    = item->pair_count;
477          FT_UInt   size     = item->pair_size;          FT_UInt    size     = item->pair_size;
478          FT_UInt   power    = (FT_UInt)ft_highpow2( (FT_UInt32)count );          FT_UInt    power    = (FT_UInt)ft_highpow2( (FT_UInt32)count );
479          FT_UInt   probe    = power*size;          FT_UInt    probe    = power * size;
480          FT_UInt   extra    = count - power;          FT_UInt    extra    = count - power;
481          FT_Byte*  base     = stream->cursor;          FT_Byte*   base     = stream->cursor;
482          FT_Bool   twobytes = item->flags & 1;          FT_Bool    twobytes = item->flags & 1;
483          FT_Byte*  p;          FT_Byte*   p;
484          FT_UInt32 cpair;          FT_UInt32  cpair;
485    
486    
487          if ( extra > 0 )          if ( extra > 0 )
488          {          {
489            p    = base + extra*size;            p = base + extra * size;
490    
491            if ( twobytes )            if ( twobytes )
492              cpair = FT_NEXT_ULONG(p);              cpair = FT_NEXT_ULONG( p );
493            else            else
494              cpair = PFR_NEXT_KPAIR(p);              cpair = PFR_NEXT_KPAIR( p );
495    
496            if ( cpair == pair )            if ( cpair == pair )
497              goto Found;              goto Found;
# Line 499  Line 504 
504          {          {
505            probe >>= 1;            probe >>= 1;
506            p       = base + probe;            p       = base + probe;
507    
508            if ( twobytes )            if ( twobytes )
509              cpair = FT_NEXT_ULONG(p);              cpair = FT_NEXT_ULONG( p );
510            else            else
511              cpair = PFR_NEXT_KPAIR(p);              cpair = PFR_NEXT_KPAIR( p );
512    
513            if ( cpair == pair )            if ( cpair == pair )
514              goto Found;              goto Found;
# Line 512  Line 518 
518          }          }
519    
520          p = base;          p = base;
521    
522          if ( twobytes )          if ( twobytes )
523            cpair = FT_NEXT_ULONG(p);            cpair = FT_NEXT_ULONG( p );
524          else          else
525            cpair = PFR_NEXT_KPAIR(p);            cpair = PFR_NEXT_KPAIR( p );
526    
527          if ( cpair == pair )          if ( cpair == pair )
528          {          {
529            FT_Int  value;            FT_Int  value;
530    
531    
532          Found:          Found:
533            if ( item->flags & 2 )            if ( item->flags & 2 )
534              value = FT_PEEK_SHORT(p);              value = FT_PEEK_SHORT( p );
535            else            else
536              value = p[0];              value = p[0];
537    
# Line 539  Line 547 
547    }    }
548    
549  #else /* !FT_OPTIMIZE_MEMORY */  #else /* !FT_OPTIMIZE_MEMORY */
550    
551    FT_LOCAL_DEF( FT_Error )    FT_LOCAL_DEF( FT_Error )
552    pfr_face_get_kerning( FT_Face     pfrface,        /* PFR_Face */    pfr_face_get_kerning( FT_Face     pfrface,        /* PFR_Face */
553                          FT_UInt     glyph1,                          FT_UInt     glyph1,
# Line 580  Line 589 
589    
590      return error;      return error;
591    }    }
592    
593  #endif /* !FT_OPTIMIZE_MEMORY */  #endif /* !FT_OPTIMIZE_MEMORY */
594    
595    
596  /* END */  /* END */

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26