/[freetype]/freetype2/src/cff/cffgload.c
ViewVC logotype

Diff of /freetype2/src/cff/cffgload.c

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

revision 1.69 by freetype, Fri Oct 28 16:14:14 2005 UTC revision 1.70 by wl, Thu Nov 17 08:12:00 2005 UTC
# Line 569  Line 569 
569    }    }
570    
571    
572      /*************************************************************************/
573      /*                                                                       */
574      /* <Function>                                                            */
575      /*    cff_face_get_vertical_metrics                                      */
576      /*                                                                       */
577      /* <Description>                                                         */
578      /*    Return the vertical metrics in font units for a given glyph.  The  */
579      /*    metrics are the top side bearing and advance height.               */
580      /*                                                                       */
581      /* <Input>                                                               */
582      /*    header  :: A pointer to the vertical metrics structure.            */
583      /*                                                                       */
584      /*    idx     :: The glyph index.                                        */
585      /*                                                                       */
586      /* <Output>                                                              */
587      /*    bearing :: The top side bearing.                                   */
588      /*                                                                       */
589      /*    advance :: The advance height.                                     */
590      /*                                                                       */
591      /* <Note>                                                                */
592      /*    Horizontal metric values are directly computed from the CFF data,  */
593      /*    bypassing the `hmtx' table completely.                             */
594      /*                                                                       */
595    #ifdef FT_OPTIMIZE_MEMORY
596    
597      static void
598      cff_face_get_vertical_metrics( TT_Face     face,
599                                     FT_UInt     idx,
600                                     FT_Short   *abearing,
601                                     FT_UShort  *aadvance )
602      {
603        TT_VertHeader*  header;
604        FT_Byte*        p;
605        FT_Byte*        limit;
606        FT_UShort       k;
607    
608    
609        header = &face->vertical;
610        p      = face->vert_metrics;
611        limit  = p + face->vert_metrics_size;
612        
613        k = header->number_Of_VMetrics;
614        
615        if ( k > 0 )
616        {
617          if ( idx < (FT_UInt)k )
618          {
619            p += 4 * idx;
620            if ( p + 4 > limit )
621              goto NoData;
622              
623            *aadvance = FT_NEXT_USHORT( p );
624            *abearing = FT_NEXT_SHORT( p );
625          }
626          else
627          {
628            p += 4 * ( k - 1 );
629            if ( p + 4 > limit )
630              goto NoData;
631              
632            *aadvance = FT_NEXT_USHORT( p );
633            p += 2 + 2 * ( idx - k );
634            if ( p + 2 > limit )
635              *abearing = 0;
636            else
637              *abearing = FT_PEEK_SHORT( p );
638          }
639        }
640        else
641        {
642        NoData:
643          *abearing = 0;
644          *aadvance = 0;
645        }
646      }
647    
648    #else /* !FT_OPTIMIZE_MEMORY */
649    
650      static void
651      cff_face_get_vertical_metrics( TT_Face     face,
652                                     FT_UInt     idx,
653                                     FT_Short   *abearing,
654                                     FT_UShort  *aadvance )
655      {
656        TT_VertHeader*  header = &face->vertical;
657        TT_LongMetrics  longs_m;
658        FT_UShort       k      = header->number_Of_VMetrics;
659    
660    
661        if ( k == 0 )
662        {
663          *abearing = *aadvance = 0;
664          return;
665        }
666    
667        if ( idx < (FT_UInt)k )
668        {
669          longs_m   = (TT_LongMetrics)header->long_metrics + idx;
670          *abearing = longs_m->bearing;
671          *aadvance = longs_m->advance;
672        }
673        else
674        {
675          *abearing = ((TT_ShortMetrics*)header->short_metrics)[idx - k];
676          *aadvance = ((TT_LongMetrics)header->long_metrics)[k - 1].advance;
677        }
678      }
679    
680    #endif /* !FT_OPTIMIZE_MEMORY */
681    
682    
683    static FT_Error    static FT_Error
684    cff_get_glyph_data( TT_Face    face,    cff_get_glyph_data( TT_Face    face,
685                        FT_UInt    glyph_index,                        FT_UInt    glyph_index,
# Line 1299  Line 1410 
1410                goto Fail;                goto Fail;
1411    
1412              args = stack;              args = stack;
1413              while (args < decoder->top )              while ( args < decoder->top )
1414              {              {
1415                if ( phase )                if ( phase )
1416                  x += args[0];                  x += args[0];
# Line 1425  Line 1536 
1536                goto Fail;                goto Fail;
1537    
1538              args = stack;              args = stack;
1539              if (num_args < 4 || ( num_args % 4 ) > 1 )              if ( num_args < 4 || ( num_args % 4 ) > 1 )
1540                goto Stack_Underflow;                goto Stack_Underflow;
1541    
1542              if ( check_points( builder, ( num_args / 4 ) * 3 ) )              if ( check_points( builder, ( num_args / 4 ) * 3 ) )
# Line 1772  Line 1883 
1883              /* close hints recording session */              /* close hints recording session */
1884              if ( hinter )              if ( hinter )
1885              {              {
1886                if (hinter->close( hinter->hints, builder->current->n_points ) )                if ( hinter->close( hinter->hints,
1887                                      builder->current->n_points ) )
1888                  goto Syntax_Error;                  goto Syntax_Error;
1889    
1890                /* apply hints to the loaded glyph outline now */                /* apply hints to the loaded glyph outline now */
# Line 2048  Line 2160 
2160    
2161          case cff_op_ifelse:          case cff_op_ifelse:
2162            {            {
2163              FT_Fixed  cond = (args[2] <= args[3]);              FT_Fixed  cond = ( args[2] <= args[3] );
2164    
2165    
2166              FT_TRACE4(( " ifelse" ));              FT_TRACE4(( " ifelse" ));
# Line 2268  Line 2380 
2380  #endif /* 0 */  #endif /* 0 */
2381    
2382    
   /*************************************************************************/  
   /*************************************************************************/  
   /*************************************************************************/  
   /**********                                                      *********/  
   /**********                                                      *********/  
   /**********               UNHINTED GLYPH LOADER                  *********/  
   /**********                                                      *********/  
   /**********    The following code is in charge of loading a      *********/  
   /**********    single outline.  It completely ignores hinting    *********/  
   /**********    and is used when FT_LOAD_NO_HINTING is set.       *********/  
   /**********                                                      *********/  
   /*************************************************************************/  
   /*************************************************************************/  
   /*************************************************************************/  
   
   
2383    FT_LOCAL_DEF( FT_Error )    FT_LOCAL_DEF( FT_Error )
2384    cff_slot_load( CFF_GlyphSlot  glyph,    cff_slot_load( CFF_GlyphSlot  glyph,
2385                   CFF_Size       size,                   CFF_Size       size,
# Line 2515  Line 2611 
2611    
2612          /* make up vertical ones */          /* make up vertical ones */
2613          metrics->vertAdvance  = 0;          metrics->vertAdvance  = 0;
2614            metrics->vertBearingX = 0;
2615            metrics->vertBearingY = 0;
2616    
2617          glyph->root.linearVertAdvance = 0;          glyph->root.linearVertAdvance = 0;
2618    
2619            /* get the vertical metrics from the vtmx table if we have one */
2620            if ( face->vertical_info                   &&
2621                 face->vertical.number_Of_VMetrics > 0 &&
2622                 face->vertical.long_metrics != 0      )
2623            {
2624              FT_Short   vertBearingY = 0;
2625              FT_UShort  vertAdvance  = 0;
2626    
2627    
2628              cff_face_get_vertical_metrics( face, glyph_index,
2629                                             &vertBearingY, &vertAdvance );
2630              metrics->vertBearingY = vertBearingY;
2631              metrics->vertAdvance  = vertAdvance;
2632            }
2633    
2634          glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;          glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
2635    
2636          glyph->root.outline.flags = 0;          glyph->root.outline.flags = 0;
# Line 2536  Line 2650 
2650          advance.y = 0;          advance.y = 0;
2651          FT_Vector_Transform( &advance, &font_matrix );          FT_Vector_Transform( &advance, &font_matrix );
2652          metrics->horiAdvance = advance.x + font_offset.x;          metrics->horiAdvance = advance.x + font_offset.x;
2653    
2654          advance.x = 0;          advance.x = 0;
2655          advance.y = metrics->vertAdvance;          advance.y = metrics->vertAdvance;
2656          FT_Vector_Transform( &advance, &font_matrix );          FT_Vector_Transform( &advance, &font_matrix );
# Line 2560  Line 2675 
2675              }              }
2676    
2677            /* Then scale the metrics */            /* Then scale the metrics */
2678            metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );            metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
2679            metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );            metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
2680          }          }
2681    
2682          /* compute the other metrics */          /* compute the other metrics */
# Line 2573  Line 2688 
2688          metrics->horiBearingX = cbox.xMin;          metrics->horiBearingX = cbox.xMin;
2689          metrics->horiBearingY = cbox.yMax;          metrics->horiBearingY = cbox.yMax;
2690    
         /* make up vertical ones */  
         metrics->vertBearingX = 0;  
         metrics->vertBearingY = 0;  
   
2691          if ( hinting )          if ( hinting )
2692            ft_glyphslot_grid_fit_metrics( &glyph->root );            ft_glyphslot_grid_fit_metrics( &glyph->root );
2693        }        }

Legend:
Removed from v.1.69  
changed lines
  Added in v.1.70

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