Back to index

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

List of all members.

Public Member Functions

 virtual_font_rep (string name, font base, string vname, int size, int dpi)
glyph compile (scheme_tree t, metric &ex)
int get_char (string s, font_metric &fnm, font_glyphs &fng)
glyph get_glyph (string s)
void get_extents (string s, metric &ex)
void draw (renderer ren, string s, SI x, SI y)
void copy_math_pars (font fn)
virtual void get_xpositions (string s, SI *xpos)
virtual double get_left_slope (string s)
virtual double get_right_slope (string s)
virtual SI get_left_correction (string s)
virtual SI get_right_correction (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

font base_fn
translator virt
int size
int dpi
int last
font_metric fnm
font_glyphs fng
double unit
int type
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 21 of file virtual_font.cpp.


Constructor & Destructor Documentation

virtual_font_rep::virtual_font_rep ( string  name,
font  base,
string  vname,
int  size,
int  dpi 
)

Definition at line 39 of file virtual_font.cpp.

                                                            :
    font_rep (name, base), base_fn (base),
    virt (load_translator (vname)), size (size2), dpi (dpi2),
    last (N(virt->virt_def)),
    fnm (std_font_metric (name, tm_new_array<metric> (last), 0, last-1)),
    fng (std_font_glyphs (name, tm_new_array<glyph> (last), 0, last-1))
{
  copy_math_pars (base_fn);
  unit= ((size*dpi)/72)*PIXEL;
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 68 of file virtual_font.cpp.

                                                    {
  // cout << "Compile " << t << "\n";

  if (is_atomic (t)) {
    string r= t->label;
    if (N(r)>1) r= "<" * r * ">";
    base_fn->get_extents (r, ex);
    return base_fn->get_glyph (r);
  }

  if (is_func (t, TUPLE, 3) &&
      (is_double (t[0])) && (is_double (t[1])))
    {
      SI x= (SI) (as_double (t[0]) * unit);
      SI y= (SI) (as_double (t[1]) * unit);
      glyph gl= compile (t[2], ex);
      ex->x1 += x; ex->y1 += y;
      ex->x2 += x; ex->y2 += y;
      ex->x3 += x - PIXEL; ex->y3 += y + PIXEL;
      ex->x4 += x - PIXEL; ex->y4 += y + PIXEL;
      return move (gl, x, y);
    }

  if (is_tuple (t, "join")) {
    int i, n= N(t);
    glyph gl1= compile (t[1], ex);
    for (i=2; i<n; i++) {
      metric ey;
      glyph gl2= compile (t[i], ey);
      outer_fit (ex, ey, 0, 0);
      gl1= join (gl1, gl2);
    }
    return gl1;
  }

  if (is_tuple (t, "glue", 2)) {
    metric ey;
    glyph gl1= compile (t[1], ex);
    glyph gl2= compile (t[2], ey);
    SI dx= ex->x2- ((base_fn->wpt*28)>>4);
    outer_fit (ex, ey, dx, 0);
    return join (gl1, move (gl2, dx, 0));
  }

  if (is_tuple (t, "glue*", 2)) {
    metric ey;
    glyph gl1= compile (t[1], ex);
    glyph gl2= compile (t[2], ey);
    SI dx= ex->x2;
    outer_fit (ex, ey, dx, 0);
    return join (gl1, move (gl2, dx, 0));
  }

  if (is_tuple (t, "add", 2)) {
    metric ey;
    glyph gl1= compile (t[1], ex);
    glyph gl2= compile (t[2], ey);
    SI dx= ((ex->x1+ ex->x2- ey->x1- ey->x2) >> 1);
    outer_fit (ex, ey, dx, 0);
    return join (gl1, move (gl2, dx, 0));
  }

  if (is_tuple (t, "enlarge")) {
    glyph gl= compile (t[1], ex);
    if (N(t)>2) ex->x1 -= (SI) (as_double (t[2]) * unit);
    if (N(t)>3) ex->x2 += (SI) (as_double (t[3]) * unit);
    if (N(t)>4) ex->y1 -= (SI) (as_double (t[4]) * unit);
    if (N(t)>5) ex->y2 += (SI) (as_double (t[5]) * unit);
    return gl;
  }

  if (is_tuple (t, "clip")) {
    glyph gl= compile (t[1], ex);
    if (N(t)>2 && t[2]!="*") ex->x1= ex->x3= (SI) (as_double (t[2]) * unit);
    if (N(t)>3 && t[3]!="*") ex->x2= ex->x4= (SI) (as_double (t[3]) * unit);
    if (N(t)>4 && t[4]!="*") ex->y1= ex->y3= (SI) (as_double (t[4]) * unit);
    if (N(t)>5 && t[5]!="*") ex->y2= ex->y4= (SI) (as_double (t[5]) * unit);
    return clip (gl, ex->x3, ex->y3, ex->x4, ex->y4);
  }

  if (is_tuple (t, "hor-flip", 1))
    return hor_flip (compile (t[1], ex));

  if (is_tuple (t, "ver-flip", 1))
    return ver_flip (compile (t[1], ex));

  if (is_tuple (t, "rot-left", 1)) {
    metric ey;
    glyph gl= pos_rotate (compile (t[1], ey));
    ex->x1= 0;
    ex->y1= 0;
    ex->x2= ey->y2- ey->y1;
    ex->y2= ey->x2- ey->x1;
    ex->x3= ey->y2- ey->y4;
    ex->y3= ey->x3- ey->x1;
    ex->x4= ey->y2- ey->y3;
    ex->y4= ey->x4- ey->x1;
    return move (gl, ey->y2, -ey->x1);
  }

  if (is_tuple (t, "rot-right", 1)) {
    metric ey;
    glyph gl= pos_rotate (pos_rotate (pos_rotate (compile (t[1], ey))));
    ex->x1= 0;
    ex->y1= 0;
    ex->x2= ey->y2- ey->y1;
    ex->y2= ey->x2- ex->x1;
    ex->x3= ey->y3- ey->y1;
    ex->y3= ey->x2- ey->x4;
    ex->x4= ey->y4- ey->y1;
    ex->y4= ey->x2- ey->x3;
    return move (gl, -ey->y1, ey->x2);
  }

  if (is_tuple (t, "hor-extend", 3) || is_tuple (t, "hor-extend", 4)) {
    glyph gl= compile (t[1], ex);
    int pos= (int) (as_double (t[2]) * gl->width);
    SI  add= (SI)  (as_double (t[3]) * unit);
    if (is_tuple (t, "hor-extend", 4))
      add= (SI)  (as_double (t[3]) * as_double (t[4]) * unit);
    int by = add / PIXEL;
    if (pos < 0) pos= 0;
    if (pos >= gl->width) pos= gl->width-1;
    ex->x2 += add;
    ex->x4 += by * PIXEL;
    return hor_extend (gl, pos, by);
  }

  if (is_tuple (t, "ver-extend", 3) || is_tuple (t, "ver-extend", 4)) {
    glyph gl= compile (t[1], ex);
    int pos= (int) (as_double (t[2]) * gl->height);
    SI  add= (SI)  (as_double (t[3]) * unit);
    if (is_tuple (t, "ver-extend", 4))
      add= (SI)  (as_double (t[3]) * as_double (t[4]) * unit);
    int by = add / PIXEL;
    if (pos < 0) pos= 0;
    if (pos >= gl->height) pos= gl->height-1;
    ex->y1 -= add;
    ex->y3 -= by * PIXEL;
    return ver_extend (gl, pos, by);
  }

  cerr << "TeXmacs] The defining tree is " << t << "\n";
  FAILED ("invalid virtual character");
  return glyph ();
}

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 virtual_font_rep::draw ( renderer  ren,
string  s,
SI  x,
SI  y 
) [virtual]

Implements font_rep.

Definition at line 286 of file virtual_font.cpp.

                                                          {
  font_metric cfnm;
  font_glyphs cfng;
  int c= get_char (s, cfnm, cfng);
  if (c != -1) ren->draw (c, cfng, x, y);
}

Here is the call graph for this function:

int virtual_font_rep::get_char ( string  s,
font_metric fnm,
font_glyphs &  fng 
)

Definition at line 248 of file virtual_font.cpp.

                                                                          {
  int c= ((N(s)==0)? -1: ((QN) s[0]));
  if ((c<0) || (c>=last)) return -1;
  if (N(s)==1) {
    cfnm= fnm;
    cfng= fng;
    if (is_nil (fng->get(c)))
      fng->get(c)= compile (virt->virt_def[c], fnm->get(c));
    return c;
  }
  else {
    make_char_font (res_name * s, cfnm, cfng);
    tree t= subst_sharp (virt->virt_def[c], s(1,N(s)));
    if (is_nil (cfng->get(0)))
      cfng->get(0)= compile (t, cfnm->get(0));
    return 0;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements font_rep.

Definition at line 268 of file virtual_font.cpp.

                                                   {
  font_metric cfnm;
  font_glyphs cfng;
  int c= get_char (s, cfnm, cfng);
  if (c == -1) {
    ex->y1= y1; ex->y2= y2;
    ex->x1= ex->x2= ex->x3= ex->x4= ex->y3= ex->y4= 0;
  }
  else {
    metric_struct* ey= cfnm->get(c);
    ex->x1= ey->x1; ex->y1= ey->y1;
    ex->x2= ey->x2; ex->y2= ey->y2;
    ex->x3= ey->x3; ex->y3= ey->y3;
    ex->x4= ey->x4; ex->y4= ey->y4;
  }
}

Here is the call graph for this function:

Reimplemented from font_rep.

Definition at line 294 of file virtual_font.cpp.

                                     {
  font_metric cfnm;
  font_glyphs cfng;
  int c= get_char (s, cfnm, cfng);
  if (c == -1) return font_rep::get_glyph (s);
  else return cfng->get(c);
}

Here is the call graph for this function:

SI font_rep::get_left_correction ( string  s) [virtual, inherited]

Reimplemented in math_font_rep, tex_font_rep, and compound_font_rep.

Definition at line 64 of file font.cpp.

{ (void) s; return 0; }
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; }
SI font_rep::get_right_correction ( string  s) [virtual, inherited]

Reimplemented in math_font_rep, tex_font_rep, compound_font_rep, and tex_rubber_font_rep.

Definition at line 65 of file font.cpp.

{ (void) s; return 0; }
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 font_rep::get_xpositions ( string  s,
SI xpos 
) [virtual, inherited]

Reimplemented in error_font_rep, math_font_rep, tex_font_rep, and x_font_rep.

Definition at line 68 of file font.cpp.

                                            {
  int i= 0;
  SI  x= 0;
  metric ex;
  while (i < N(s)) {
    if (s[i] == '<')
      while ((i < N(s)) && (s[i] != '>')) {
       i++;
       xpos[i]= x;
      }
    i++;
    get_extents (s (0, i), ex);
    x= ex->x2;
    xpos[i]= x;
  }
}

Here is the call 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 22 of file virtual_font.cpp.

Definition at line 32 of file font.hpp.

Definition at line 33 of file font.hpp.

Definition at line 24 of file virtual_font.cpp.

space font_rep::extra [inherited]

Definition at line 36 of file font.hpp.

font_glyphs virtual_font_rep::fng

Definition at line 27 of file virtual_font.cpp.

Definition at line 26 of file virtual_font.cpp.

Definition at line 25 of file virtual_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.

Reimplemented from font_rep.

Definition at line 24 of file virtual_font.cpp.

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.

int font_rep::type [inherited]

Definition at line 30 of file font.hpp.

Definition at line 28 of file virtual_font.cpp.

Definition at line 23 of file virtual_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: