Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes
x_font_rep Struct Reference

#include <x_font.hpp>

Inheritance diagram for x_font_rep:
Inheritance graph
[legend]
Collaboration diagram for x_font_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 x_font_rep (string name, string family, int size, int dpi)
void get_extents (string s, metric &ex)
void get_xpositions (string s, SI *xpos)
void draw (renderer ren, string s, SI x, SI y)
glyph get_glyph (string s)
void copy_math_pars (font fn)
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

string family
int dpi
font_metric fnm
font_glyphs fng
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 31 of file x_font.hpp.


Constructor & Destructor Documentation

x_font_rep::x_font_rep ( string  name,
string  family,
int  size,
int  dpi 
)

Definition at line 306 of file x_font.cpp.

                                                                       :
  font_rep (name)
{
  metric ex;
  load_system_font (family2, size2, dpi2, fnm, fng);

  family       = family2;
  size         = size2;
  dpi          = dpi2;

  // get main font parameters
  get_extents ("f", ex);
  y1= ex->y1;
  y2= ex->y2;
  display_size = y2-y1;
  design_size  = size << 8;

  // get character dimensions
  get_extents ("x", ex);
  yx           = ex->y2;
  get_extents ("M", ex);
  wquad        = ex->x2;

  // compute other heights
  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;

  // compute other widths
  wpt          = (dpi*PIXEL)/72;
  wfn          = (wpt*design_size) >> 8;
  wline        = wfn/20;

  // get fraction bar parameters
  get_extents ("-", ex);
  yfrac= (ex->y3 + ex->y4) >> 1;

  // get space length
  get_extents (" ", ex);
  spc  = space ((3*(ex->x2-ex->x1))>>2, ex->x2-ex->x1, (ex->x2-ex->x1)<<1);
  extra= spc;
  sep  = wfn/10;

  // get_italic space
  get_extents ("f", ex);
  SI italic_spc= (ex->x4-ex->x3)-(ex->x2-ex->x1);
  slope= ((double) italic_spc) / ((double) display_size);
  if (slope<0.15) slope= 0.0;
}

Here is the call graph for this function:


Member Function Documentation

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

Implements font_rep.

Definition at line 402 of file x_font.cpp.

                                                    {
  if (N(s)!=0) {
    int i;
    for (i=0; i<N(s); i++) {
      QN c= s[i];
      ren->draw (c, fng, x, y);
      metric_struct* ex= fnm->get (c);
      x += ex->x2;
    }
  }
}

Here is the call graph for this function:

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

Implements font_rep.

Definition at line 361 of file x_font.cpp.

                                             {
  if (N(s)==0) {
    ex->x1= ex->x3= ex->x2= ex->x4=0;
    ex->y3= ex->y1= 0; ex->y4= ex->y2= yx;
  }
  else {
    QN c= s[0];
    metric_struct* first= fnm->get (c);
    ex->x1= first->x1; ex->y1= first->y1;
    ex->x2= first->x2; ex->y2= first->y2;
    ex->x3= first->x3; ex->y3= first->y3;
    ex->x4= first->x4; ex->y4= first->y4;
    SI x= first->x2;

    int i;
    for (i=1; i<N(s); i++) {
      QN c= s[i];
      metric_struct* next= fnm->get (c);
      ex->x1= min (ex->x1, x+ next->x1); ex->y1= min (ex->y1, next->y1);
      ex->x2= max (ex->x2, x+ next->x2); ex->y2= max (ex->y2, next->y2);
      ex->x3= min (ex->x3, x+ next->x3); ex->y3= min (ex->y3, next->y3);
      ex->x4= max (ex->x4, x+ next->x4); ex->y4= max (ex->y4, next->y4);
      x += next->x2;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from font_rep.

Definition at line 415 of file x_font.cpp.

                               {
  if (N(s)!=1) return font_rep::get_glyph (s);
  int c= ((QN) s[0]);
  glyph gl= fng->get (c);
  if (is_nil (gl)) return font_rep::get_glyph (s);
  return gl;
}

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 x_font_rep::get_xpositions ( string  s,
SI xpos 
) [virtual]

Reimplemented from font_rep.

Definition at line 389 of file x_font.cpp.

                                              {
  register int i, n= N(s);
  if (n == 0) return;
  
  register SI x= 0;
  for (i=0; i<N(s); i++) {
    metric_struct* next= fnm->get ((QN) s[i]);
    x += next->x2;
    xpos[i+1]= 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 32 of file font.hpp.

Definition at line 33 of file font.hpp.

Definition at line 33 of file x_font.hpp.

space font_rep::extra [inherited]

Definition at line 36 of file font.hpp.

Definition at line 32 of file x_font.hpp.

font_glyphs x_font_rep::fng

Definition at line 35 of file x_font.hpp.

Definition at line 34 of file x_font.hpp.

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.

int font_rep::type [inherited]

Definition at line 30 of file font.hpp.

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 files: