Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes
tex_font_rep Struct Reference
Inheritance diagram for tex_font_rep:
Inheritance graph
[legend]
Collaboration diagram for tex_font_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 tex_font_rep (string name, int status, string family, int size, int dpi, int dsize)
void get_extents (string s, metric &ex)
void get_xpositions (string s, SI *xpos)
void draw (renderer ren, string s, SI x, SI y)
SI get_left_correction (string s)
SI get_right_correction (string s)
glyph get_glyph (string s)
void special_get_extents (string s, metric &ex)
void special_get_xpositions (string s, SI *xpos)
void special_draw (renderer ren, string s, SI x, SI y)
SI special_get_left_correction (string s)
SI special_get_right_correction (string s)
void accented_get_extents (string s, metric &ex)
void accented_get_xpositions (string s, SI *xpos)
void accented_draw (renderer ren, string s, SI x, SI y)
SI accented_get_left_correction (string s)
SI accented_get_right_correction (string s)
void copy_math_pars (font fn)
virtual double get_left_slope (string s)
virtual double get_right_slope (string s)
void var_get_extents (string s, metric &ex)
void var_get_xpositions (string s, SI *xpos)
void var_draw (renderer ren, string s, SI x, SI y)

Public Attributes

int status
string family
int dpi
int dsize
tex_font_metric tfm
font_glyphs pk
double unit
int type
SI size
SI design_size
SI display_size
double slope
space spc
space extra
SI sep
SI y1
SI y2
SI yx
SI yfrac
SI ysub_lo_base
SI ysub_hi_lim
SI ysup_lo_lim
SI ysup_lo_base
SI ysup_hi_lim
SI yshift
SI wpt
SI wfn
SI wline
SI wquad
string res_name

Detailed Description

Definition at line 30 of file tex_font.cpp.


Constructor & Destructor Documentation

tex_font_rep::tex_font_rep ( string  name,
int  status,
string  family,
int  size,
int  dpi,
int  dsize 
)

Definition at line 66 of file tex_font.cpp.

                                                  :
  font_rep (name), status (status2), dsize (dsize2)
{
  load_tex (family2, size2, dpi2, dsize, tfm, pk);

  family       = family2;
  type         = FONT_TYPE_TEX;
  size         = size2;
  dpi          = dpi2;
  design_size  = tfm->design_size () >> 12;
  display_size = (((design_size*dpi)/72)*PIXEL) >> 8;
  unit         = ((double) display_size) / ((double) (1<<20));
  slope        = tfm->slope ();
  spc->def     = conv (tfm->spc ());
  spc->min     = spc->def - conv (tfm->spc_shrink ());
  spc->max     = spc->def + conv (tfm->spc_stretch ());
  extra        = conv (tfm->spc_extra ());
  extra->min   = extra->min >> 1;
  extra->max   = extra->min << 1;
  sep          = ((((dpi*PIXEL)/72)*design_size) >> 8) / 10;

  y1           = conv (-262080);   // -0.25 quad
  y2           = y1+ display_size; //  0.75 quad
  yx           = conv (tfm->x_height ());
  yfrac        = yx >> 1;
  ysub_lo_base = -yx/3;
  ysub_hi_lim  = (5*yx)/6;
  ysup_lo_lim  = yx/2;
  ysup_lo_base = (5*yx)/6;
  ysup_hi_lim  = yx;
  yshift       = yx/6;

  wpt          = (dpi*PIXEL)/72;
  wfn          = (wpt*design_size) >> 8;
  wline        = wfn/20;
  wquad        = conv (tfm->spc_quad ());

  if ((family == "cmr") || (family == "ecrm") || (family == "cmmi")) {
    if (size < 8)
      wline= wfn / (size==7? 16: (size==6? 14: 12));
    else if (size < 10) yfrac += (size * wfn) / 1600;
    else if (size <= 14) yfrac += (size * wfn) / 1000;
    else {
      wline= wfn / (size>16? 28: 24);
      yfrac += (size * wfn) / 700;
    }
  }

  special_initialize ();
}

Here is the call graph for this function:


Member Function Documentation

void tex_font_rep::accented_draw ( renderer  ren,
string  s,
SI  x,
SI  y 
)

Definition at line 417 of file tex_font.cpp.

                                                               {
  int old_status= status;
  status= TEX_ANY;

  register int i;
  string acc= get_accents (s);
  s= get_unaccented (s);
  draw (ren, s, x, y);

  for (i=0; i<N(acc); i++)
    if (acc[i] != ' ') {
      SI xx, yy;
      char c= acc[i];
      metric ey, ez;
      get_extents (s(0,i+1), ey); xx= ey->x2;
      get_extents (s[i], ey);
      get_extents (c, ez);
      xx -= (((ey->x2 - ey->x1) + (ez->x2 - ez->x1)) >> 1);
      yy  = ey->y2- yx;
      if (c == 24) yy=PIXEL;
      else if (c == ((char) 203)) yy= 0;
      else if (c == ((char) 206)) {
       yy= 0;
       if ((s[i] == 'a') || (s[i] == 'A')) xx += (ey->x2 - ey->x1) / 3;
       else xx += (ey->x2 - ey->x1) / 5;
      }
      else xx += (SI) (((double) yy) * slope);
      draw (ren, string (c), x+ xx, y+ yy);
    }

  status= old_status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 370 of file tex_font.cpp.

                                                        {
  int old_status= status;
  status= TEX_ANY;

  register int i;
  string acc= get_accents (s);
  s= get_unaccented (s);
  get_extents (s, ex);

  for (i=0; i<N(acc); i++)
    if (acc[i] != ' ') {
      SI xx, yy;
      char c= acc[i];
      metric ey, ez;
      get_extents (s(0,i+1), ey); xx= ey->x2;
      get_extents (s[i], ey);
      get_extents (c, ez);
      xx -= (((ey->x2 - ey->x1) + (ez->x2 - ez->x1)) >> 1);
      yy  = ey->y2- yx;
      if (c == 24) yy=PIXEL;
      else if (c == ((char) 203)) yy= 0;
      else if (c == ((char) 206)) {
       yy= 0;
       if ((s[i] == 'a') || (s[i] == 'A')) xx += (ey->x2 - ey->x1) / 3;
       else xx += (ey->x2 - ey->x1) / 5;
      }
      else xx += (SI) (((double) yy) * slope);
      ex->x3 = min (ex->x3, xx + ez->x3);
      ex->y3 = min (ex->y3, yy + ez->y3);
      ex->x4 = max (ex->x4, xx + ez->x4);
      ex->y4 = max (ex->y4, yy + ez->y4);
    }

  status= old_status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 451 of file tex_font.cpp.

                                                    {
  s= get_unaccented (s);
  return (SI) (slope * conv (tfm->d ((QN) s[0])));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 457 of file tex_font.cpp.

                                                     {
  s= get_unaccented (s);
  return conv (tfm->i ((QN) s[N(s)-1]));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 407 of file tex_font.cpp.

                                                         {
  int old_status= status;
  status= TEX_ANY;
  string acc= get_accents (s);
  s= get_unaccented (s);
  get_xpositions (s, xpos);
  status= old_status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void font_rep::copy_math_pars ( font  fn) [inherited]

Definition at line 45 of file font.cpp.

                                 {
  y1           = fn->y1;
  y2           = fn->y2;
  yx           = fn->yx;
  yfrac        = fn->yfrac;
  ysub_lo_base = fn->ysub_lo_base;
  ysub_hi_lim  = fn->ysub_hi_lim;
  ysup_lo_lim  = fn->ysup_lo_lim;
  ysup_lo_base = fn->ysup_lo_base;
  ysup_hi_lim  = fn->ysup_hi_lim;
  yshift       = fn->yshift;
  wpt          = fn->wpt;
  wfn          = fn->wfn;
  wline        = fn->wline;
  wquad        = fn->wquad;
}

Here is the caller graph for this function:

void tex_font_rep::draw ( renderer  ren,
string  s,
SI  x,
SI  y 
) [virtual]

Implements font_rep.

Definition at line 587 of file tex_font.cpp.

                                                       {
  register int i;
  switch (status) {
  case TEX_ANY:
    break;
  case TEX_EC:
  case TEX_LA:
    for (i=0; i<N(s); i++)
      if (s[i]=='<') {
       special_draw (ren, s, ox, y);
       return;
      }
    break;
  case TEX_CM:
  case TEX_ADOBE:
    for (i=0; i<N(s); i++) {
      if (s[i]=='<') {
       special_draw (ren, s, ox, y);
       return;
      }
      if ((s[i] & 128) != 0) {
       ACCENTS_PREPARE;
       accented_draw (ren, s, ox, y);
       return;
      }
    }
    break;
  }

  SI  x= ox;
  int n= N(s);
  int m= (n+16) << 1;
  STACK_NEW_ARRAY (str, int, n);
  STACK_NEW_ARRAY (buf, int, m);
  STACK_NEW_ARRAY (ker, int, m);
  for (i=0; i<n; i++) str[i]= ((QN) s[i]);
  tfm->execute (str, n, buf, ker, m);

  for (i=0; i<m; i++) {
    register int c= buf[i];
    glyph gl= pk->get (c);
    if (is_nil (gl)) continue;
    ren->draw (c, pk, x, y);
    x += conv (tfm->w(c)+ ker[i]);
  }
  STACK_DELETE_ARRAY (str);
  STACK_DELETE_ARRAY (buf);
  STACK_DELETE_ARRAY (ker);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tex_font_rep::get_extents ( string  s,
metric ex 
) [virtual]

Implements font_rep.

Definition at line 467 of file tex_font.cpp.

                                               {
  register int i;
  switch (status) {
  case TEX_ANY:
    break;
  case TEX_EC:
  case TEX_LA:
    for (i=0; i<N(s); i++)
      if (s[i]=='<') {
       special_get_extents (s, ex);
       return;
      }
    break;
  case TEX_CM:
  case TEX_ADOBE:
    for (i=0; i<N(s); i++) {
      if (s[i]=='<') {
       special_get_extents (s, ex);
       return;
      }
      if ((s[i] & 128) != 0) {
       ACCENTS_PREPARE;
       accented_get_extents (s, ex);
       return;
      }
    }
    break;
  }

  int n= N(s);
  int m= (n+16) << 1;
  STACK_NEW_ARRAY (s_copy, int, n);
  STACK_NEW_ARRAY (buf, int, m);
  STACK_NEW_ARRAY (ker, int, m);
  for (i=0; i<n; i++) s_copy[i]= ((QN) s[i]);
  tfm->execute (s_copy, n, buf, ker, m);

  SI x1= 0;
  SI x2= 0;
  SI x3= PLUS_INFINITY;
  SI x4= MINUS_INFINITY;
  SI y1= PLUS_INFINITY;
  SI y2= MINUS_INFINITY;
  SI y3= PLUS_INFINITY;
  SI y4= MINUS_INFINITY;

  for (i=0; i<m; i++) {
    int c= buf[i];
    glyph gl= pk->get (c);
    if (is_nil (gl)) continue;
    
    y1= min (y1, -conv (tfm->d(c)));
    y2= max (y2,  conv (tfm->h(c)));
    x3= min (x3, x2- ((int) gl->xoff) * PIXEL);
    x4= max (x4, x2+ ((int) (gl->width- gl->xoff)) * PIXEL);
    y3= min (y3, ((int) (gl->yoff- gl->height)) * PIXEL);
    y4= max (y4, ((int) gl->yoff) * PIXEL);
    x2 += conv (tfm->w(c)+ ker[i]);
  }

  if ((x3 == PLUS_INFINITY) || (x4 == MINUS_INFINITY) ||
      (y3 == PLUS_INFINITY) || (y4 == MINUS_INFINITY))
    {
      x1= x3= x2= x4= 0;
      y3= y1= 0; y4= y2= yx;
    }

  ex->x1= x1;
  ex->x2= x2;
  ex->x3= x3 - 2*PIXEL;
  ex->x4= x4 + 2*PIXEL;
  ex->y1= y1;
  ex->y2= y2;
  ex->y3= y3 - 2*PIXEL;
  ex->y4= y4 + 2*PIXEL;

  STACK_DELETE_ARRAY (s_copy);
  STACK_DELETE_ARRAY (buf);
  STACK_DELETE_ARRAY (ker);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from font_rep.

Definition at line 680 of file tex_font.cpp.

                                 {
  register int i;
  switch (status) {
  case TEX_ANY:
    break;
  case TEX_EC:
  case TEX_LA:
    if (s == "<less>") s= "<";
    if (s == "<gtr>") s= ">";
    break;
  case TEX_CM:
  case TEX_ADOBE:
    if (s == "<less>") s= "<";
    if (s == "<gtr>") s= ">";
    for (i=0; i<N(s); i++)
      if ((s[i] & 128) != 0)
       return font_rep::get_glyph (s);
    break;
  }
  if (N(s)!=1) return font_rep::get_glyph (s);
  int c= ((QN) s[0]);
  glyph gl= pk->get (c);
  if (is_nil (gl)) return font_rep::get_glyph (s);
  return gl;
}

Here is the call graph for this function:

Reimplemented from font_rep.

Definition at line 638 of file tex_font.cpp.

                                           {
  if (N(s) == 0) return 0;
  switch (status) {
  case TEX_ANY:
    break;
  case TEX_EC:
  case TEX_LA:
    if (s[0] == '<') return special_get_left_correction (s);
    break;
  case TEX_CM:
  case TEX_ADOBE:
    if (s[0] == '<') return special_get_left_correction (s);
    if ((s[0] & 128) != 0) {
      ACCENTS_PREPARE;
      return accented_get_left_correction (s);
    }
  }
  return (SI) (slope * conv (tfm->d ((QN) s[0])));
}

Here is the call graph for this function:

double font_rep::get_left_slope ( string  s) [virtual, inherited]

Reimplemented in math_font_rep, compound_font_rep, and tex_rubber_font_rep.

Definition at line 62 of file font.cpp.

{ (void) s; return slope; }

Reimplemented from font_rep.

Definition at line 659 of file tex_font.cpp.

                                            {
  if (N(s) == 0) return 0;
  switch (status) {
  case TEX_ANY:
    break;
  case TEX_EC:
  case TEX_LA:
    if (s[N(s)-1] == '>') return special_get_right_correction (s);
    break;
  case TEX_CM:
  case TEX_ADOBE:
    if (s[N(s)-1] == '>') return special_get_right_correction (s);
    if ((s[N(s)-1] & 128) != 0) {
      ACCENTS_PREPARE;
      return accented_get_right_correction (s);
    }
  }
  return conv (tfm->i ((QN) s[N(s)-1]));
}

Here is the call graph for this function:

double font_rep::get_right_slope ( string  s) [virtual, inherited]

Reimplemented in math_font_rep, compound_font_rep, and tex_rubber_font_rep.

Definition at line 63 of file font.cpp.

{ (void) s; return slope; }
void tex_font_rep::get_xpositions ( string  s,
SI xpos 
) [virtual]

Reimplemented from font_rep.

Definition at line 549 of file tex_font.cpp.

                                                {
  register int i, n= N(s);
  if (n == 0) return;

  switch (status) {
  case TEX_ANY:
    break;
  case TEX_EC:
  case TEX_LA:
    for (i=0; i<n; i++)
      if (s[i]=='<') {
       special_get_xpositions (s, xpos);
       return;
      }
    break;
  case TEX_CM:
  case TEX_ADOBE:
    for (i=0; i<n; i++) {
      if (s[i]=='<') {
       special_get_xpositions (s, xpos);
       return;
      }
      if ((s[i] & 128) != 0) {
       ACCENTS_PREPARE;
       accented_get_xpositions (s, xpos);
       return;
      }
    }
    break;
  }

  STACK_NEW_ARRAY (s_copy, int, n);
  for (i=0; i<n; i++) s_copy[i]= ((QN) s[i]);
  tfm->get_xpositions (s_copy, n, unit, xpos);
  STACK_DELETE_ARRAY (s_copy);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tex_font_rep::special_draw ( renderer  ren,
string  s,
SI  x,
SI  y 
)

Definition at line 206 of file tex_font.cpp.

                                                              {
  register int i, j;
  metric ex;
  for (i=0; i<N(s); i++)
    if (s[i]=='<') break;
  draw (ren, s (0, i), x, y);
  get_extents (s (0, i), ex);
  x += ex->x2;
  for (j=i+1; j<N(s); j++)
    if (s[j]=='>') break;
  if (j<N(s)) j++;

  int temp= status;
  status= TEX_ANY;
  string r= s (i, j);
  string rr= special_translate[r];
  color c= ren->get_color ();
  if (N(rr) != 0) r= rr;
  else ren->set_color (red);
  draw (ren, r, x, y);
  ren->set_color (c);
  get_extents (r, ex);
  x += ex->x2;
  status= temp;
  
  draw (ren, s (j, N(s)), x, y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 140 of file tex_font.cpp.

                                                       {
  register int i, j;
  for (i=0; i<N(s); i++)
    if (s[i]=='<') break;
  get_extents (s (0, i), ex);
  for (j=i+1; j<N(s); j++)
    if (s[j]=='>') break;
  if (j<N(s)) j++;

  SI x;
  metric ey;
  int temp= status;
  status= TEX_ANY;
  string r = s (i, j);
  string rr= special_translate[r];
  if (N(rr) != 0) r= rr;
  get_extents (r, ey);
  x= ex->x2;
  ex->x1= min (ex->x1, x+ ey->x1); ex->y1= min (ex->y1, ey->y1);
  ex->x2= max (ex->x2, x+ ey->x2); ex->y2= max (ex->y2, ey->y2);
  ex->x3= min (ex->x3, x+ ey->x3); ex->y3= min (ex->y3, ey->y3);
  ex->x4= max (ex->x4, x+ ey->x4); ex->y4= max (ex->y4, ey->y4);
  status= temp;
  
  get_extents (s (j, N(s)), ey);
  x= ex->x2;
  ex->x1= min (ex->x1, x+ ey->x1); ex->y1= min (ex->y1, ey->y1);
  ex->x2= max (ex->x2, x+ ey->x2); ex->y2= max (ex->y2, ey->y2);
  ex->x3= min (ex->x3, x+ ey->x3); ex->y3= min (ex->y3, ey->y3);
  ex->x4= max (ex->x4, x+ ey->x4); ex->y4= max (ex->y4, ey->y4);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 235 of file tex_font.cpp.

                                                   {
  int i= 0;
  tm_char_forwards (s, i);
  string r= special_translate (s (0, i));
  if (N(r)!=0) return (SI) (slope * conv (tfm->d ((QN) r[0])));
  return (SI) (slope * conv (tfm->d ((QN) '<')));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 244 of file tex_font.cpp.

                                                    {
  int n= N(s), i= n;
  tm_char_backwards (s, i);
  string r= special_translate (s (i, n));
  if (N(r)!=0) return conv (tfm->i ((QN) r[0]));
  return conv (tfm->i ((QN) '>'));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 173 of file tex_font.cpp.

                                                        {
  SI offset= 0;
  register int l=0, i, j, n=N(s);
  while (l<n) {
    for (i=l; i<n; i++)
      if (s[i]=='<') break;
    if (l<i) {
      get_xpositions (s (l, i), xpos + l);
      for (j=l+1; j<=i; j++) xpos[j] += offset;
      if (i==n) break;
      offset= xpos[i];
    }

    for (j=i+1; j<n; j++) {
      xpos[j]= offset;
      if (s[j]=='>') break;
    }
    if (j<n) j++;
    metric ey;
    int temp= status;
    status= TEX_ANY;
    string r= s (i, j);
    string rr= special_translate[r];
    if (N(rr) != 0) r= rr;
    get_extents (r, ey);
    status= temp;
    offset += ey->x2;
    xpos[j]= offset;
    l= j;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void font_rep::var_draw ( renderer  ren,
string  s,
SI  x,
SI  y 
) [inherited]

Definition at line 121 of file font.cpp.

                                                      {
  SI dx=0;
  int start=0, end;
  while (start<N(s)) {
    for (end=start; (end<N(s)) && (s[end]!=' '); end++) {}
    if (start<end) {
      metric ex;
      draw (ren, s (start, end), x+dx, y);
      get_extents (s (start, end), ex);
      dx += ex->x2;
    }
    for (; (end<N(s)) && (s[end]==' '); end++) dx += spc->def;
    start= end;
  }
}

Here is the call graph for this function:

void font_rep::var_get_extents ( string  s,
metric ex 
) [inherited]

Definition at line 86 of file font.cpp.

                                               {
  bool flag=true;
  int start=0, end;
  get_extents ("", ex);
  while (start<N(s)) {
    for (end=start; (end<N(s)) && (s[end]!=' '); end++) {}
    if (start<end) {
      metric ey;
      get_extents (s (start, end), ey);
      if (flag) {
       ex->x3= ey->x3+ ex->x2; ex->y3= ey->y3+ ex->x2;
       ex->x4= ey->x4; ex->y4= ey->y4;
       ex->x2 += ey->x2;
       flag= false;
      }
      else {
       ex->x3= min (ex->x3, ex->x2+ ey->x3);
       ex->x4= max (ex->x4, ex->x2+ ey->x4);
       ex->y3= min (ex->y3, ey->y3);
       ex->y4= max (ex->y4, ey->y4);
       ex->x2 += ey->x2;
      }
    }
    for (; (end<N(s)) && (s[end]==' '); end++) ex->x2 += spc->def;
    start= end;
  }
}

Here is the call graph for this function:

void font_rep::var_get_xpositions ( string  s,
SI xpos 
) [inherited]

Definition at line 115 of file font.cpp.

                                                {
  (void) s; (void) xpos;
  FAILED ("not yet implemented");
}

Member Data Documentation

Definition at line 32 of file font.hpp.

Definition at line 33 of file font.hpp.

Definition at line 33 of file tex_font.cpp.

Definition at line 34 of file tex_font.cpp.

space font_rep::extra [inherited]

Definition at line 36 of file font.hpp.

Definition at line 32 of file tex_font.cpp.

font_glyphs tex_font_rep::pk

Definition at line 36 of file tex_font.cpp.

string rep< font >::res_name [inherited]

Definition at line 17 of file resource.hpp.

SI font_rep::sep [inherited]

Definition at line 37 of file font.hpp.

SI font_rep::size [inherited]

Reimplemented in virtual_font_rep.

Definition at line 31 of file font.hpp.

double font_rep::slope [inherited]

Definition at line 34 of file font.hpp.

space font_rep::spc [inherited]

Definition at line 35 of file font.hpp.

Definition at line 31 of file tex_font.cpp.

tex_font_metric tex_font_rep::tfm

Definition at line 35 of file tex_font.cpp.

int font_rep::type [inherited]

Definition at line 30 of file font.hpp.

Definition at line 37 of file tex_font.cpp.

SI font_rep::wfn [inherited]

Definition at line 51 of file font.hpp.

SI font_rep::wline [inherited]

Definition at line 52 of file font.hpp.

SI font_rep::wpt [inherited]

Definition at line 50 of file font.hpp.

SI font_rep::wquad [inherited]

Definition at line 53 of file font.hpp.

SI font_rep::y1 [inherited]

Definition at line 39 of file font.hpp.

SI font_rep::y2 [inherited]

Definition at line 40 of file font.hpp.

SI font_rep::yfrac [inherited]

Definition at line 42 of file font.hpp.

SI font_rep::yshift [inherited]

Definition at line 48 of file font.hpp.

Definition at line 44 of file font.hpp.

Definition at line 43 of file font.hpp.

Definition at line 47 of file font.hpp.

Definition at line 46 of file font.hpp.

Definition at line 45 of file font.hpp.

SI font_rep::yx [inherited]

Definition at line 41 of file font.hpp.


The documentation for this struct was generated from the following file: