Back to index

tetex-bin  3.0
Functions
t1aaset.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

GLYPHT1_AASetChar (int FontID, char charcode, float size, T1_TMATRIX *transform)
GLYPHT1_AASetString (int FontID, char *string, int len, long spaceoff, int modflag, float size, T1_TMATRIX *transform)
GLYPHT1_AASetRect (int FontID, float size, float width, float height, T1_TMATRIX *transform)
int T1_AASetGrayValues (unsigned long white, unsigned long gray75, unsigned long gray50, unsigned long gray25, unsigned long black)
int T1_AAHSetGrayValues (unsigned long *grayvals)
int T1_AANSetGrayValues (unsigned long bg, unsigned long fg)
int T1_AAGetGrayValues (long *pgrayvals)
int T1_AAHGetGrayValues (long *pgrayvals)
int T1_AANGetGrayValues (long *pgrayvals)
int T1_AASetBitsPerPixel (int bpp)
int T1_AAGetBitsPerPixel (void)
int T1_AASetLevel (int level)
int T1_AAGetLevel (void)
GLYPHT1_AAFillOutline (T1_OUTLINE *path, int modflag)
int T1_AASetSmartLimits (float limit1, float limit2)
int T1_AASetSmartMode (int smart)

Function Documentation

GLYPH* T1_AAFillOutline ( T1_OUTLINE path,
int  modflag 
)

Definition at line 1672 of file t1aaset.c.

{
  
  GLYPH *glyph;   /* pointer to bitmap glyph */
  static GLYPH aaglyph={NULL,{0,0,0,0,0,0},NULL,DEFAULTBPP};/* The anti-aliased glyph */
  long asc, dsc, ht, wd;
  long i;
  long n_horz, n_horz_pad, n_vert, n_asc, n_dsc;
  long v_start, v_end;
  char *target_ptr;
  long offset;
  char *ptr;
  int y;
  long lsb, aalsb, aahstart;
  int memsize;
  LONG paddedW;
 

  /* Reset character glyph, if necessary */
  if (aaglyph.bits!=NULL){
    free(aaglyph.bits);
    aaglyph.bits=NULL;
  }
  aaglyph.metrics.leftSideBearing=0;
  aaglyph.metrics.rightSideBearing=0;
  aaglyph.metrics.advanceX=0;
  aaglyph.metrics.advanceY=0;
  aaglyph.metrics.ascent=0;
  aaglyph.metrics.descent=0;
  aaglyph.pFontCacheInfo=NULL;
  aaglyph.bpp=T1aa_bpp;


  /* First, scale outline appropriately: */
  path=T1_ScaleOutline( path, T1aa_level);
  
  /* Second, call routine to fill outline, all error checking is
     done in this function: */ 
  if ((glyph=T1_FillOutline( path, modflag))==NULL)
    return(NULL); /* An error occured */
  
  /* In case there are no black pixels, we simply set the dimensions and
     then return */
  if ( glyph->bits == NULL) {
    aaglyph.bits=NULL;
    aaglyph.metrics.leftSideBearing=0;
    aaglyph.metrics.rightSideBearing=0;
    aaglyph.metrics.advanceX=(int) floor(glyph->metrics.advanceX/(float)T1aa_level+0.5);
    aaglyph.metrics.advanceY=(int) floor(glyph->metrics.advanceY/(float)T1aa_level+0.5);
    aaglyph.metrics.ascent=0;
    aaglyph.metrics.descent=0;
    aaglyph.pFontCacheInfo=NULL;
    return(&aaglyph);
  }

  /* Get dimensions of bitmap: */
  asc=glyph->metrics.ascent;
  dsc=glyph->metrics.descent;
  lsb=glyph->metrics.leftSideBearing;
  ht=asc-dsc;
  wd=glyph->metrics.rightSideBearing-lsb;
  

  if (T1aa_level==T1_AA_NONE){
    /* we only convert bitmap to bytemap */
    aaglyph=*glyph;
    aaglyph.bpp=T1aa_bpp;
    /* Compute scanline length and such */
    n_horz_pad=PAD( wd*T1aa_bpp, pFontBase->bitmap_pad )>>3;
    /* Allocate memory for glyph, we alloc 12 bytes more to simplify
       subsampling! */
    memsize = n_horz_pad*ht*8;
    aaglyph.bits = (char *)malloc(memsize*sizeof( char) +12);
    if (aaglyph.bits == NULL) {
      T1_errno=T1ERR_ALLOC_MEM;
      return(NULL);
    }
    paddedW=PAD(wd,pFontBase->bitmap_pad)>>3;
    ptr=glyph->bits;
    target_ptr=aaglyph.bits;
    for (i = 0; i < ht; i++) {
      T1_DoLine ( wd, paddedW, ptr, target_ptr );
      ptr += paddedW;
      target_ptr += n_horz_pad;
    }
    return(&aaglyph);
  }
  

  /* Set some looping parameters for subsampling */
  if (lsb<0){
    aalsb=lsb/T1aa_level-1;
    aahstart=T1aa_level+(lsb%T1aa_level);
  }
  else{
    aalsb=lsb/T1aa_level;
    aahstart=lsb%T1aa_level;
  }
  
  /* The horizontal number of steps: */
  n_horz=(wd+aahstart+T1aa_level-1)/T1aa_level;
  /* And the padded value */
  n_horz_pad=PAD( n_horz*T1aa_bpp, pFontBase->bitmap_pad )>>3;
  
  /* vertical number of steps: */
  if (asc % T1aa_level){ /* not aligned */
    if ( asc > 0){
      n_asc=asc/T1aa_level+1;
      v_start=asc % T1aa_level;
    }
    else{
      n_asc=asc/T1aa_level;
      v_start=T1aa_level + (asc % T1aa_level); 
    }
  }
  else{
    n_asc=asc/T1aa_level;
    v_start=T1aa_level;
  }
  if (dsc % T1aa_level){ /* not aligned */
    if ( dsc < 0){
      n_dsc=dsc/T1aa_level-1;
      v_end=-(dsc % T1aa_level);
    }
    else{
      n_dsc=dsc/T1aa_level;
      v_end=T1aa_level - (dsc % T1aa_level);
    }
  }
  else{
    n_dsc=dsc/T1aa_level;
    v_end=T1aa_level;
  }
  /* the total number of lines: */
  n_vert=n_asc-n_dsc;
  
  /* Allocate memory for glyph */
  memsize = n_horz_pad*n_vert;
  
  aaglyph.bits = (char *)malloc(memsize*sizeof( char)+12);
  if (aaglyph.bits == NULL) {
    T1_errno=T1ERR_ALLOC_MEM;
    return(NULL);
  }
  
  paddedW=PAD(wd,pFontBase->bitmap_pad)/8;
  offset=0;
  target_ptr=aaglyph.bits;
  
  /* We must check for n_vert==1 because the computation above is not
     valid in this case */
  if (n_vert==1)
    v_start=v_start < v_end ? v_start : v_end;

  ptr = glyph->bits;
  for (i = 0; i < n_vert; i++) {
    if (i==0)
      y=v_start;
    else if (i==n_vert-1)
      y=v_end;
    else
      y=T1aa_level;
    T1_AADoLine ( T1aa_level, wd, y, paddedW, ptr, target_ptr, aahstart );
    ptr += y * paddedW;
    target_ptr += n_horz_pad;
  }
  
  /* .. and set them in aaglyph */
  aaglyph.metrics.leftSideBearing=aalsb;
  aaglyph.metrics.rightSideBearing=aalsb + n_horz;
  aaglyph.metrics.advanceX=(int) floor(glyph->metrics.advanceX/(float)T1aa_level+0.5);
  aaglyph.metrics.advanceY=(int) floor(glyph->metrics.advanceY/(float)T1aa_level+0.5);
  aaglyph.metrics.ascent=n_asc;
  aaglyph.metrics.descent=n_dsc;
  aaglyph.pFontCacheInfo=NULL;

  return(&aaglyph);
}

Definition at line 1629 of file t1aaset.c.

{
  return( T1aa_bpp);
  
}
int T1_AAGetGrayValues ( long *  pgrayvals)

Definition at line 1524 of file t1aaset.c.

{
  int i;
  
  if (T1_CheckForInit()) {
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1);
  }

  if (pgrayvals==NULL) {
    T1_errno=T1ERR_INVALID_PARAMETER;
    return(-1);
  }
  
  for ( i=0; i<5; i++) { /* bg (i=0)  to fg (i=4) */
    pgrayvals[i]=gv[i];
  }
  return( 0);
  
}

Definition at line 1665 of file t1aaset.c.

{
  return( T1aa_level);
}
int T1_AAHGetGrayValues ( long *  pgrayvals)

Definition at line 1550 of file t1aaset.c.

{
  int i;

  if (T1_CheckForInit()) {
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1);
  }

  if (pgrayvals==NULL) {
    T1_errno=T1ERR_INVALID_PARAMETER;
    return(-1);
  }

  for ( i=0; i<17; i++) { /* bg (i=0)  to fg (i=16) */
    pgrayvals[i]=gv[i];
  }
  return( 0);
}
int T1_AAHSetGrayValues ( unsigned long *  grayvals)

Definition at line 1470 of file t1aaset.c.

{
  int i;
  
  if (T1_CheckForInit()){
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1);
  }

  /* 0==white(background) ... 16==black(foreground) */
  for (i=0; i<17; i++){
    gv_h[i]=(unsigned T1_AA_TYPE32)grayvals[i];
  }
  

  T1aa_bg=grayvals[0];
  
  if ((T1_AAInit( T1_AA_HIGH)))
    return(-1);
  return(0);
  
}
int T1_AANGetGrayValues ( long *  pgrayvals)

Definition at line 1575 of file t1aaset.c.

{

  if (T1_CheckForInit()) {
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1);
  }

  if (pgrayvals==NULL) {
    T1_errno=T1ERR_INVALID_PARAMETER;
    return(-1);
  }
  pgrayvals[0]=gv[0]; /* background */
  pgrayvals[1]=gv[1]; /* foreground */
  return( 0);
}
int T1_AANSetGrayValues ( unsigned long  bg,
unsigned long  fg 
)

Definition at line 1500 of file t1aaset.c.

{
  
  if (T1_CheckForInit()){
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1);
  }

  gv_n[0]=bg;
  gv_n[1]=fg;
  
  T1aa_bg=bg;
  
  if ((T1_AAInit( T1_AA_NONE)))
    return(-1);
  return(0);
  
}

Definition at line 1597 of file t1aaset.c.

{
  
  if (T1_CheckForInit()){
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1);
  }
  

  /* T1aa_level = 0; */

  if (bpp==8){
    T1aa_bpp=8;
    return(0);
  }
  if (bpp==16){
    T1aa_bpp=16;
    return(0);
  }
  if ((bpp==32)|(bpp==24)){
    T1aa_bpp=32;
    return(0);
  }

  T1_errno=T1ERR_INVALID_PARAMETER;
  return(-1);
}
GLYPH* T1_AASetChar ( int  FontID,
char  charcode,
float  size,
T1_TMATRIX transform 
)

Definition at line 746 of file t1aaset.c.

{
  
  GLYPH *glyph;   /* pointer to bitmap glyph */
  static GLYPH aaglyph={NULL,{0,0,0,0,0,0},NULL,DEFAULTBPP};/* The anti-aliased glyph */
  long asc, dsc, ht, wd;
  long i;
  long n_horz, n_horz_pad, n_vert, n_asc, n_dsc;
  long v_start, v_end;
  char *target_ptr;
  long offset;
  char *ptr;
  int y;
  long lsb, aalsb, aahstart;
  int memsize;
  LONG paddedW;
  int savelevel;
  FONTSIZEDEPS *font_ptr=NULL;
  unsigned char ucharcode;
  

  /* Reset character glyph, if necessary */
  if (aaglyph.bits!=NULL){
    free(aaglyph.bits);
    aaglyph.bits=NULL;
  }
  aaglyph.metrics.leftSideBearing=0;
  aaglyph.metrics.rightSideBearing=0;
  aaglyph.metrics.advanceX=0;
  aaglyph.metrics.advanceY=0;
  aaglyph.metrics.ascent=0;
  aaglyph.metrics.descent=0;
  aaglyph.pFontCacheInfo=NULL;
  aaglyph.bpp=T1aa_bpp;


  ucharcode=charcode;
  
  /* Check for smart antialiasing */
  savelevel=T1aa_level;
  if (T1aa_SmartOn){
    if (size>=T1aa_smartlimit2) {
      T1aa_level=T1_AA_NONE;
    }
    else if (size>=T1aa_smartlimit1) {
      T1aa_level=T1_AA_LOW;
    }
    else {
      T1aa_level=T1_AA_HIGH;
    }
  }


  /* The following code is only exectued if caching of antialiased
     chracters is enabled. */
  /* Check if char is in cache */
  if ((pFontBase->t1lib_flags & T1_AA_CACHING)) {
    if (transform==NULL){
      /* if size/aa is not existent we create it */
      if ((font_ptr=T1int_QueryFontSize( FontID, size, T1aa_level))==NULL){
       /* We create the required size struct and leave the rest
          for T1_SetChar() */
       font_ptr=T1int_CreateNewFontSize( FontID, size, T1aa_level);
       if (font_ptr==NULL){
         T1_errno=T1ERR_ALLOC_MEM;
         T1aa_level=savelevel;
         return(NULL);
       }
      }
      else {/* size is already existent in cache */
       if (font_ptr->pFontCache[ucharcode].bits != NULL){
         /* Character is already in Chache -> create a copy of cache
            and return a pointer to the result: */
         memcpy( &aaglyph, &(font_ptr->pFontCache[ucharcode]), sizeof(GLYPH));
         memsize = (aaglyph.metrics.ascent-aaglyph.metrics.descent) *
           PAD((aaglyph.metrics.rightSideBearing-aaglyph.metrics.leftSideBearing) *
              T1aa_bpp,pFontBase->bitmap_pad)/8;
         aaglyph.bits = (char *)malloc(memsize*sizeof( char));
         if (aaglyph.bits == NULL){
           T1_errno=T1ERR_ALLOC_MEM;
           T1aa_level=savelevel;
           return(NULL);
         }
         memcpy( aaglyph.bits, font_ptr->pFontCache[ucharcode].bits, memsize);
         return(&(aaglyph));
       }
      }
    } /* (transform==NULL) */ 
  } /* T1_AA_CACHING */
  

  /* First, call routine to rasterize character, all error checking is
     done in this function: */ 
  if ((glyph=T1_SetChar( FontID, charcode, T1aa_level*size, transform))==NULL){
    /* restore level */
    T1aa_level=savelevel;
    return(NULL); /* An error occured */
  }
  
  /* In case there are no black pixels, we simply set the dimensions and
     then return */
  if ( glyph->bits == NULL) {
    aaglyph.bits=NULL;
    aaglyph.metrics.leftSideBearing=0;
    aaglyph.metrics.rightSideBearing=0;
    aaglyph.metrics.advanceX=(int) floor(glyph->metrics.advanceX/(float)T1aa_level+0.5);
    aaglyph.metrics.advanceY=(int) floor(glyph->metrics.advanceY/(float)T1aa_level+0.5);
    aaglyph.metrics.ascent=0;
    aaglyph.metrics.descent=0;
    aaglyph.pFontCacheInfo=NULL;
    /* restore level and return */
    T1aa_level=savelevel;
    return(&aaglyph);
  }

  /* Get dimensions of bitmap: */
  asc=glyph->metrics.ascent;
  dsc=glyph->metrics.descent;
  lsb=glyph->metrics.leftSideBearing;
  ht=asc-dsc;
  wd=glyph->metrics.rightSideBearing-lsb;

  
  
  if (T1aa_level==T1_AA_NONE){
    /* we only convert bitmap to bytemap */
    aaglyph=*glyph;
    aaglyph.bpp=T1aa_bpp;
    /* Compute scanline length and such */
    n_horz_pad=PAD( wd*T1aa_bpp, pFontBase->bitmap_pad )>>3;
    /* Allocate memory for glyph */
    memsize = n_horz_pad*ht*8;
    /*    aaglyph.bits = (char *)malloc(memsize*sizeof( char)); */
    aaglyph.bits = (char *)malloc(memsize*sizeof( char));
    if (aaglyph.bits == NULL) {
      T1_errno=T1ERR_ALLOC_MEM;
      /* restore level */
      T1aa_level=savelevel;
      return(NULL);
    }
    paddedW=PAD(wd,pFontBase->bitmap_pad)>>3;
    ptr=glyph->bits;
    target_ptr=aaglyph.bits;
    for (i = 0; i < ht; i++) {
      T1_DoLine ( wd, paddedW, ptr, target_ptr );
      ptr += paddedW;
      target_ptr += n_horz_pad;
    }
    /* restore level */
    T1aa_level=savelevel;
    return(&aaglyph);
  }
  

  /* Set some looping parameters for subsampling */
  if (lsb<0){
    aalsb=lsb/T1aa_level-1;
    aahstart=T1aa_level+(lsb%T1aa_level);
  }
  else{
    aalsb=lsb/T1aa_level;
    aahstart=lsb%T1aa_level;
  }
  
  /* The horizontal number of steps: */
  n_horz=(wd+aahstart+T1aa_level-1)/T1aa_level;
  /* And the padded value */
  n_horz_pad=PAD( n_horz*T1aa_bpp, pFontBase->bitmap_pad )>>3;

  /* vertical number of steps: */
  if (asc % T1aa_level){ /* not aligned */
    if ( asc > 0){
      n_asc=asc/T1aa_level+1;
      v_start=asc % T1aa_level;
    }
    else{
      n_asc=asc/T1aa_level;
      v_start=T1aa_level + (asc % T1aa_level); 
    }
  }
  else{
    n_asc=asc/T1aa_level;
    v_start=T1aa_level;
  }
  if (dsc % T1aa_level){ /* not aligned */
    if ( dsc < 0){
      n_dsc=dsc/T1aa_level-1;
      v_end=-(dsc % T1aa_level);
    }
    else{
      n_dsc=dsc/T1aa_level;
      v_end=T1aa_level - (dsc % T1aa_level);
    }
  }
  else{
    n_dsc=dsc/T1aa_level;
    v_end=T1aa_level;
  }
  /* the total number of lines: */
  n_vert=n_asc-n_dsc;
  
  /* Allocate memory for glyph */
  memsize = n_horz_pad*n_vert;

  /* Note: we allocate 12 bytes more than necessary */
  aaglyph.bits = (char *)malloc(memsize*sizeof( char) +12);
  if (aaglyph.bits == NULL) {
    T1_errno=T1ERR_ALLOC_MEM;
    /* restore level */
    T1aa_level=savelevel;
    return(NULL);
  }
  

  paddedW=PAD(wd,pFontBase->bitmap_pad)/8;
  offset=0;
  target_ptr=aaglyph.bits;
  
  /* We must check for n_vert==1 because the computation above is not
     valid in this case */
  if (n_vert==1)
    v_start=v_start < v_end ? v_start : v_end;

  ptr = glyph->bits;
  for (i = 0; i < n_vert; i++) {
    if (i==0)
      y=v_start;
    else if (i==n_vert-1)
      y=v_end;
    else
      y=T1aa_level;
    T1_AADoLine ( T1aa_level, wd, y, paddedW, ptr, target_ptr, aahstart );
    ptr += y * paddedW;
    target_ptr += n_horz_pad;
  }
  
  /* .. and set them in aaglyph */
  aaglyph.metrics.leftSideBearing=aalsb;
  aaglyph.metrics.rightSideBearing=aalsb + n_horz;
  aaglyph.metrics.advanceX=(int) floor(glyph->metrics.advanceX/(float)T1aa_level+0.5);
  aaglyph.metrics.advanceY=(int) floor(glyph->metrics.advanceY/(float)T1aa_level+0.5);
  aaglyph.metrics.ascent=n_asc;
  aaglyph.metrics.descent=n_dsc;
  aaglyph.pFontCacheInfo=NULL;

  
  if ((pFontBase->t1lib_flags & T1_AA_CACHING) && (transform==NULL)) {
    /* Put char into cache area */
    memcpy( &(font_ptr->pFontCache[ucharcode]), &aaglyph, sizeof(GLYPH));
    font_ptr->pFontCache[ucharcode].bits = (char *)malloc(memsize*sizeof( char));
    if (font_ptr->pFontCache[ucharcode].bits == NULL){
      T1_errno=T1ERR_ALLOC_MEM;
      T1aa_level=savelevel;
      return(NULL);
    }
    memcpy( font_ptr->pFontCache[ucharcode].bits, aaglyph.bits, memsize);
  }
  
  /* restore level */
  T1aa_level=savelevel;

  return(&aaglyph);
}
int T1_AASetGrayValues ( unsigned long  white,
unsigned long  gray75,
unsigned long  gray50,
unsigned long  gray25,
unsigned long  black 
)

Definition at line 1438 of file t1aaset.c.

{
  
  if (T1_CheckForInit()){
    T1_errno=T1ERR_OP_NOT_PERMITTED;
    return(-1);
  }
  
  gv[4]=(unsigned T1_AA_TYPE32)black;    /* black value */
  gv[3]=(unsigned T1_AA_TYPE32)gray25;   /* gray 25% value */
  gv[2]=(unsigned T1_AA_TYPE32)gray50;   /* gray 50% value */   
  gv[1]=(unsigned T1_AA_TYPE32)gray75;   /* gray 75% value */
  gv[0]=(unsigned T1_AA_TYPE32)white;    /* white value */
  
  T1aa_bg=white;
  
  if ((T1_AAInit( T1_AA_LOW)))
    return(-1);
  return(0);
  
}
int T1_AASetLevel ( int  level)

Definition at line 1637 of file t1aaset.c.

{
  
   if (T1_CheckForInit()){
     T1_errno=T1ERR_OP_NOT_PERMITTED;
     return(-1);
   }

   if (level==T1_AA_LOW){
     T1aa_level=T1_AA_LOW;
     return(0);
   }
   else if (level==T1_AA_HIGH){
     T1aa_level=T1_AA_HIGH;
     return(0);
   }
   else if (level==T1_AA_NONE){
     T1aa_level=T1_AA_NONE;
     return(0);
   }
   
   T1_errno=T1ERR_INVALID_PARAMETER;
   return(-1);
   
}
GLYPH* T1_AASetRect ( int  FontID,
float  size,
float  width,
float  height,
T1_TMATRIX transform 
)

Definition at line 1224 of file t1aaset.c.

{
  GLYPH *glyph;   /* pointer to bitmap glyph */
  static GLYPH aaglyph={NULL,{0,0,0,0,0,0},NULL,DEFAULTBPP};/* The anti-aliased glyph */
  long asc, dsc, ht, wd;
  long i;
  long n_horz, n_horz_pad, n_vert, n_asc, n_dsc;
  long v_start, v_end;
  char *target_ptr;
  long offset;
  char *ptr;
  int y;
  long lsb, aalsb, aahstart;
  int memsize;
  LONG paddedW;
  int savelevel;
  

  /* Reset character glyph, if necessary */
  if (aaglyph.bits!=NULL){
    free(aaglyph.bits);
    aaglyph.bits=NULL;
  }
  aaglyph.metrics.leftSideBearing=0;
  aaglyph.metrics.rightSideBearing=0;
  aaglyph.metrics.advanceX=0;
  aaglyph.metrics.advanceY=0;
  aaglyph.metrics.ascent=0;
  aaglyph.metrics.descent=0;
  aaglyph.pFontCacheInfo=NULL;
  aaglyph.bpp=T1aa_bpp;


  /* Check for smart antialiasing */
  savelevel=T1aa_level;
  if (T1aa_SmartOn){
    if (size>=T1aa_smartlimit2) {
      T1aa_level=T1_AA_NONE;
    }
    else if (size>=T1aa_smartlimit1) {
      T1aa_level=T1_AA_LOW;
    }
    else {
      T1aa_level=T1_AA_HIGH;
    }
  }


  /* First, call routine to rasterize character, all error checking is
     done in this function: */ 
  if ((glyph=T1_SetRect( FontID, T1aa_level*size, width, height, transform))==NULL){
    /* restore level */
    T1aa_level=savelevel;
    return(NULL); /* An error occured */
  }
  
  /* In case there are no black pixels, we simply set the dimensions and
     then return */
  if ( glyph->bits == NULL) {
    aaglyph.bits=NULL;
    aaglyph.metrics.leftSideBearing=0;
    aaglyph.metrics.rightSideBearing=0;
    aaglyph.metrics.advanceX=(int) floor(glyph->metrics.advanceX/(float)T1aa_level+0.5);
    aaglyph.metrics.advanceY=(int) floor(glyph->metrics.advanceY/(float)T1aa_level+0.5);
    aaglyph.metrics.ascent=0;
    aaglyph.metrics.descent=0;
    aaglyph.pFontCacheInfo=NULL;
    /* restore level and return */
    T1aa_level=savelevel;
    return(&aaglyph);
  }

  /* Get dimensions of bitmap: */
  asc=glyph->metrics.ascent;
  dsc=glyph->metrics.descent;
  lsb=glyph->metrics.leftSideBearing;
  ht=asc-dsc;
  wd=glyph->metrics.rightSideBearing-lsb;
  
  if (T1aa_level==T1_AA_NONE){
    /* we only convert bitmap to bytemap */
    aaglyph=*glyph;
    aaglyph.bpp=T1aa_bpp;
    /* Compute scanline length and such */
    n_horz_pad=PAD( wd*T1aa_bpp, pFontBase->bitmap_pad )>>3;
    /* Allocate memory for glyph */
    memsize = n_horz_pad*ht*8;
    /*    aaglyph.bits = (char *)malloc(memsize*sizeof( char)); */
    aaglyph.bits = (char *)malloc(memsize*sizeof( char));
    if (aaglyph.bits == NULL) {
      T1_errno=T1ERR_ALLOC_MEM;
      /* restore level */
      T1aa_level=savelevel;
      return(NULL);
    }
    paddedW=PAD(wd,pFontBase->bitmap_pad)>>3;
    ptr=glyph->bits;
    target_ptr=aaglyph.bits;
    for (i = 0; i < ht; i++) {
      T1_DoLine ( wd, paddedW, ptr, target_ptr );
      ptr += paddedW;
      target_ptr += n_horz_pad;
    }
    /* restore level */
    T1aa_level=savelevel;
    return(&aaglyph);
  }
  

  /* Set some looping parameters for subsampling */
  if (lsb<0){
    aalsb=lsb/T1aa_level-1;
    aahstart=T1aa_level+(lsb%T1aa_level);
  }
  else{
    aalsb=lsb/T1aa_level;
    aahstart=lsb%T1aa_level;
  }
  
  /* The horizontal number of steps: */
  n_horz=(wd+aahstart+T1aa_level-1)/T1aa_level;
  /* And the padded value */
  n_horz_pad=PAD( n_horz*T1aa_bpp, pFontBase->bitmap_pad )>>3;

  /* vertical number of steps: */
  if (asc % T1aa_level){ /* not aligned */
    if ( asc > 0){
      n_asc=asc/T1aa_level+1;
      v_start=asc % T1aa_level;
    }
    else{
      n_asc=asc/T1aa_level;
      v_start=T1aa_level + (asc % T1aa_level); 
    }
  }
  else{
    n_asc=asc/T1aa_level;
    v_start=T1aa_level;
  }
  if (dsc % T1aa_level){ /* not aligned */
    if ( dsc < 0){
      n_dsc=dsc/T1aa_level-1;
      v_end=-(dsc % T1aa_level);
    }
    else{
      n_dsc=dsc/T1aa_level;
      v_end=T1aa_level - (dsc % T1aa_level);
    }
  }
  else{
    n_dsc=dsc/T1aa_level;
    v_end=T1aa_level;
  }
  /* the total number of lines: */
  n_vert=n_asc-n_dsc;
  
  /* Allocate memory for glyph */
  memsize = n_horz_pad*n_vert;

  /* Note: we allocate 12 bytes more than necessary */
  aaglyph.bits = (char *)malloc(memsize*sizeof( char) +12);
  if (aaglyph.bits == NULL) {
    T1_errno=T1ERR_ALLOC_MEM;
    /* restore level */
    T1aa_level=savelevel;
    return(NULL);
  }
  

  paddedW=PAD(wd,pFontBase->bitmap_pad)/8;
  offset=0;
  target_ptr=aaglyph.bits;
  
  /* We must check for n_vert==1 because the computation above is not
     valid in this case */
  if (n_vert==1)
    v_start=v_start < v_end ? v_start : v_end;

  ptr = glyph->bits;
  for (i = 0; i < n_vert; i++) {
    if (i==0)
      y=v_start;
    else if (i==n_vert-1)
      y=v_end;
    else
      y=T1aa_level;
    T1_AADoLine ( T1aa_level, wd, y, paddedW, ptr, target_ptr, aahstart );
    ptr += y * paddedW;
    target_ptr += n_horz_pad;
  }
  
  /* .. and set them in aaglyph */
  aaglyph.metrics.leftSideBearing=aalsb;
  aaglyph.metrics.rightSideBearing=aalsb + n_horz;
  aaglyph.metrics.advanceX=(int) floor(glyph->metrics.advanceX/(float)T1aa_level+0.5);
  aaglyph.metrics.advanceY=(int) floor(glyph->metrics.advanceY/(float)T1aa_level+0.5);
  aaglyph.metrics.ascent=n_asc;
  aaglyph.metrics.descent=n_dsc;
  aaglyph.pFontCacheInfo=NULL;

  /* restore level */
  T1aa_level=savelevel;

  return(&aaglyph);

}
int T1_AASetSmartLimits ( float  limit1,
float  limit2 
)

Definition at line 1855 of file t1aaset.c.

{

  if (limit1 > 0.0 && limit2 > 0.0 && limit2 >= limit2) {
    T1aa_smartlimit1=limit1;
    T1aa_smartlimit2=limit2;
    return( 0);
  }
  else{
    T1_errno=T1ERR_INVALID_PARAMETER;
    return( -1);
  }
}

Definition at line 1872 of file t1aaset.c.

{

  if (smart==T1_YES) {
    T1aa_SmartOn=1;
  }
  else if (smart==T1_NO) {
    T1aa_SmartOn=0;
  }
  else {
    T1_errno=T1ERR_INVALID_PARAMETER;
    return( -1);
  }
  return( 0);
}
GLYPH* T1_AASetString ( int  FontID,
char *  string,
int  len,
long  spaceoff,
int  modflag,
float  size,
T1_TMATRIX transform 
)

Definition at line 1015 of file t1aaset.c.

{
  GLYPH *glyph;   /* pointer to bitmap glyph */
  static GLYPH aastring_glyph={NULL,{0,0,0,0,0,0},NULL,DEFAULTBPP};/* The anti-aliased glyph */
  long asc, dsc, ht, wd;
  long i;
  long n_horz, n_horz_pad, n_vert, n_asc, n_dsc;
  long v_start, v_end;
  char *target_ptr;
  long offset;
  char *ptr;
  int y;
  long lsb, aalsb, aahstart;
  int memsize;
  LONG paddedW;
  int savelevel;
  
  
  /* Reset character glyph, if necessary */
  if (aastring_glyph.bits!=NULL){
    free(aastring_glyph.bits);
    aastring_glyph.bits=NULL;
  }
  aastring_glyph.metrics.leftSideBearing=0;
  aastring_glyph.metrics.rightSideBearing=0;
  aastring_glyph.metrics.advanceX=0;
  aastring_glyph.metrics.advanceY=0;
  aastring_glyph.metrics.ascent=0;
  aastring_glyph.metrics.descent=0;
  aastring_glyph.pFontCacheInfo=NULL;
  aastring_glyph.bpp=T1aa_bpp;
  

  /* Check for smart antialiasing */
  savelevel=T1aa_level;
  if (T1aa_SmartOn){
    if (size>=T1aa_smartlimit2) {
      T1aa_level=T1_AA_NONE;
    }
    else if (size>=T1aa_smartlimit1) {
      T1aa_level=T1_AA_LOW;
    }
    else {
      T1aa_level=T1_AA_HIGH;
    }
  }
    
  /* First, call routine to rasterize character, all error checking is
     done in this function: */ 
  if ((glyph=T1_SetString( FontID, string, len, spaceoff,
                        modflag, T1aa_level*size, transform))==NULL){
    /* restore level */
    T1aa_level=savelevel;
    return(NULL); /* An error occured */
  }
  
  /* In case there are no black pixels, we simply set the dimensions and
     then return */
  if ( glyph->bits == NULL) {
    aastring_glyph.bits=NULL;
    aastring_glyph.metrics.leftSideBearing=0;
    aastring_glyph.metrics.rightSideBearing=0;
    aastring_glyph.metrics.advanceX=(int) floor(glyph->metrics.advanceX/(float)T1aa_level+0.5);
    aastring_glyph.metrics.advanceY=(int) floor(glyph->metrics.advanceY/(float)T1aa_level+0.5);
    aastring_glyph.metrics.ascent=0;
    aastring_glyph.metrics.descent=0;
    aastring_glyph.pFontCacheInfo=NULL;
    /* restore level and return */
    T1aa_level=savelevel;
    return(&aastring_glyph);
  }


  /* Get dimensions of bitmap: */
  asc=glyph->metrics.ascent;
  dsc=glyph->metrics.descent;
  lsb=glyph->metrics.leftSideBearing;
  ht=asc-dsc;
  wd=glyph->metrics.rightSideBearing-lsb;
  
  if (T1aa_level==T1_AA_NONE){
    /* we only convert bitmap to bytemap */
    aastring_glyph=*glyph;
    aastring_glyph.bpp=T1aa_bpp;
    /* Compute scanline length and such */
    n_horz_pad=PAD( wd*T1aa_bpp, pFontBase->bitmap_pad )>>3;
    /* Allocate memory for glyph */
    memsize = n_horz_pad*ht*8;
    aastring_glyph.bits = (char *)malloc(memsize*sizeof( char));
    if (aastring_glyph.bits == NULL) {
      T1_errno=T1ERR_ALLOC_MEM;
      /* restore level */
      T1aa_level=savelevel;
      return(NULL);
    }
    paddedW=PAD(wd,pFontBase->bitmap_pad)>>3;
    ptr=glyph->bits;
    target_ptr=aastring_glyph.bits;
    for (i = 0; i < ht; i++) {
      T1_DoLine ( wd, paddedW, ptr, target_ptr );
      ptr += paddedW;
      target_ptr += n_horz_pad;
    }
    /* restore level */
    T1aa_level=savelevel;
    return(&aastring_glyph);
  }
  

  /* Set some looping parameters for subsampling */
  if (lsb<0){
    aalsb=lsb/T1aa_level-1;
    aahstart=T1aa_level+(lsb%T1aa_level);
  }
  else{
    aalsb=lsb/T1aa_level;
    aahstart=lsb%T1aa_level;
  }
  
  /* The horizontal number of steps: */
  n_horz=(wd+aahstart+T1aa_level-1)/T1aa_level;
  /* And the padded value */
  n_horz_pad=PAD( n_horz*T1aa_bpp, pFontBase->bitmap_pad )>>3;

  /* vertical number of steps: */
  if (asc % T1aa_level){ /* not aligned */
    if ( asc > 0){
      n_asc=asc/T1aa_level+1;
      v_start=asc % T1aa_level;
    }
    else{
      n_asc=asc/T1aa_level;
      v_start=T1aa_level + (asc % T1aa_level); 
    }
  }
  else{
    n_asc=asc/T1aa_level;
    v_start=T1aa_level;
  }
  if (dsc % T1aa_level){ /* not aligned */
    if ( dsc < 0){
      n_dsc=dsc/T1aa_level-1;
      v_end=-(dsc % T1aa_level);
    }
    else{
      n_dsc=dsc/T1aa_level;
      v_end=T1aa_level - (dsc % T1aa_level);
    }
  }
  else{
    n_dsc=dsc/T1aa_level;
    v_end=T1aa_level;
  }
  /* the total number of lines: */
  n_vert=n_asc-n_dsc;
  
  /* Allocate memory for glyph */
  memsize = n_horz_pad*n_vert;

  /* Note: we allocate 12 bytes more than necessary */ 
  aastring_glyph.bits = (char *)malloc(memsize*sizeof( char) +12);
  if (aastring_glyph.bits == NULL) {
    T1_errno=T1ERR_ALLOC_MEM;
    return(NULL);
  }
  
  paddedW=PAD(wd,pFontBase->bitmap_pad)/8;
  offset=0;
  target_ptr=aastring_glyph.bits;
  
  /* We must check for n_vert==1 because the computation above is not
     valid in this case */
  if (n_vert==1)
    v_start=v_start < v_end ? v_start : v_end;
  
  ptr = glyph->bits;
  for (i = 0; i < n_vert; i++) {
    if (i==0)
      y=v_start;
    else if (i==n_vert-1)
      y=v_end;
    else
      y=T1aa_level;
    T1_AADoLine ( T1aa_level, wd, y, paddedW, ptr, target_ptr, aahstart );
    ptr += y * paddedW;
    target_ptr += n_horz_pad;
  }
  
  /* .. and set them in aastring_glyph */
  aastring_glyph.metrics.leftSideBearing=aalsb;
  aastring_glyph.metrics.rightSideBearing=aalsb + n_horz;
  aastring_glyph.metrics.advanceX=(int) floor(glyph->metrics.advanceX/(float)T1aa_level+0.5);
  aastring_glyph.metrics.advanceY=(int) floor(glyph->metrics.advanceY/(float)T1aa_level+0.5);
  aastring_glyph.metrics.ascent=n_asc;
  aastring_glyph.metrics.descent=n_dsc;
  aastring_glyph.pFontCacheInfo=NULL;

  /* restore level */
  T1aa_level=savelevel;

  return(&aastring_glyph);
}