示例#1
0
void pdf_out_char (internal_font_number f, ASCII_code c)
{
  pdf_rect rect;
  char cbuf[2];
  cbuf[0] = c;
  cbuf[1] = 0;
  pdf_dev_set_string(cur_h, -cur_v, cbuf, 1, char_width(f, char_info(f, c)), font_id[f], 1);
  pdf_dev_set_rect(&rect, cur_h, -cur_v, char_width(f, char_info(f, c)),
      char_height(f, height_depth(char_info(f, c))),
      char_depth(f, height_depth(char_info(f, c))));
  pdf_doc_expand_box(&rect);
}
示例#2
0
void tex::make_accent ()
	{
	fnt	f;
	qcell	i;
	ptr	p, q, r;
	scal	a, h, w, x;
	float	s, t;
	scal	delta;

	scan_char_num();
	f = cur_font;
	p = new_character(f, cur_val);
	if (p != null) {
		x = x_height(f);
		s = (float) slant(f) / 65536.0;
		a = char_width(f, char_info(f, character(p)));
		do_assignments();
		q = null;
		f = cur_font;
		if (cur_cmd == LETTER
		|| cur_cmd == OTHER_CHAR
		|| cur_cmd ==  CHAR_GIVEN) {
			q = new_character(f, cur_chr);
		} else if (cur_cmd ==  CHAR_NUM) {
			scan_char_num();
			q = new_character(f, cur_val);
		} else {
			back_input();
		}
		if (q != null) {
			t = (float) slant(f) / 65536.0;
			i = char_info(f, character(q));
			w = char_width(f, i); 
			h = char_height(f, height_depth(i));
			if (h != x) {
				p = hpack(p, 0, ADDITIONAL);
				shift_amount(p) = x - h;
			}
			delta = round((float) (w - a) / 2.0 + h * t - x * s);
			r = new_kern(delta);
			subtype(r) = ACC_KERN;
			link(tail) = r;
			link(r) = p;
			tail = new_kern(-a - delta);
			subtype(tail) = ACC_KERN;
			link(p) = tail;
			p = q;
		}
		tail_append(p);
		space_factor = 1000;
		}
	}
示例#3
0
liginfo 
get_ligature (internal_font_number f, integer lc, integer rc) {
  liginfo t, u;
  charinfo * co;
  t.lig = 0;
  t.type = 0;
  t.adj = 0;
  if (lc == non_boundarychar || rc == non_boundarychar || (!has_lig(f,lc)) )
    return t;
  k = 0;
  co = char_info(f,lc);
  while (1) {
    u = charinfo_ligature(co,k);
    if (lig_end(u))
      break;    
    if (lig_char(u) == rc) {
      if (lig_disabled(u)) {
	return t;
      } else {
	return u;
      }
    }
    k++;
  }
  return t;
}
示例#4
0
void
set_tag_code (internal_font_number f, integer c, integer i) {
  integer fixedi;
  charinfo * co;
  if (char_exists(f,c)) {
    /* abs(fix_int(i-7,0)) */
    fixedi = - (i<-7 ? -7 : (i>0 ? 0 : i )) ;
    co = char_info(f,c);
    if (fixedi >= 4) {
      if (char_tag(f,c) == ext_tag) 
	set_charinfo_tag(co,(char_tag(f,c)- ext_tag));
      fixedi = fixedi - 4;
    }
    if (fixedi >= 2) {
      if (char_tag(f,c) == list_tag) 
	set_charinfo_tag(co,(char_tag(f,c)- list_tag));
      fixedi = fixedi - 2;
    };
    if (fixedi >= 1) {
      if (has_lig(f,c)) 
	set_charinfo_ligatures(co,NULL);
      if (has_kern(f,c)) 
	set_charinfo_kerns(co,NULL);
    }
  }
}
示例#5
0
void 
set_ef_code(internal_font_number f, integer c, integer i) {
  charinfo * co;
  if (char_exists(f,c)) {
    co = char_info(f,c);
	set_charinfo_ef(co,i);
  }
}
示例#6
0
char_info font_face_set::character_dimensions(const unsigned c)
{
    //Check if char is already in cache
    std::map<unsigned, char_info>::const_iterator itr;
    itr = dimension_cache_.find(c);
    if (itr != dimension_cache_.end()) {
        return itr->second;
    }

    FT_Matrix matrix;
    FT_Vector pen;
    FT_Error  error;

    pen.x = 0;
    pen.y = 0;

    FT_BBox glyph_bbox;
    FT_Glyph image;

    glyph_ptr glyph = get_glyph(c);
    FT_Face face = glyph->get_face()->get_face();

    matrix.xx = (FT_Fixed)( 1 * 0x10000L );
    matrix.xy = (FT_Fixed)( 0 * 0x10000L );
    matrix.yx = (FT_Fixed)( 0 * 0x10000L );
    matrix.yy = (FT_Fixed)( 1 * 0x10000L );

    FT_Set_Transform(face, &matrix, &pen);

    error = FT_Load_Glyph (face, glyph->get_index(), FT_LOAD_NO_HINTING);
    if ( error )
        return char_info();

    error = FT_Get_Glyph(face->glyph, &image);
    if ( error )
        return char_info();

    FT_Glyph_Get_CBox(image, ft_glyph_bbox_pixels, &glyph_bbox);
    FT_Done_Glyph(image);

    unsigned tempx = face->glyph->advance.x >> 6;

    char_info dim(c, tempx, glyph_bbox.yMax, glyph_bbox.yMin, face->size->metrics.height/64.0 /* >> 6 */);
    dimension_cache_.insert(std::pair<unsigned, char_info>(c, dim));
    return dim;
}
示例#7
0
void 
set_no_ligatures (internal_font_number f) {
  integer c;
  charinfo * co;
  
  if (font_tables[f]->ligatures_disabled)
	return;

  co = char_info(f,left_boundarychar);
  set_charinfo_ligatures(co,NULL);
  co = char_info(f,right_boundarychar); /* this is weird */
  set_charinfo_ligatures(co,NULL);
  for (c=0;c<font_tables[f]->charinfo_count;c++) {
	co = font_tables[f]->charinfo+c;
	set_charinfo_ligatures(co,NULL);
  }
  font_tables[f]->ligatures_disabled =1;
}
示例#8
0
void
dump_charinfo (int f , int c) {
  charinfo *co;
  int x;
  liginfo *lig;
  kerninfo *kern;

  dump_int(c);
  co = char_info(f,c);
  set_charinfo_used(co,0);
  dump_int(get_charinfo_width(co));
  dump_int(get_charinfo_height(co));
  dump_int(get_charinfo_depth(co));
  dump_int(get_charinfo_italic(co));
  dump_int(get_charinfo_tag(co));
  dump_int(get_charinfo_ef(co));
  dump_int(get_charinfo_rp(co));
  dump_int(get_charinfo_lp(co));
  dump_int(get_charinfo_remainder(co));
  dump_int(get_charinfo_used(co));
  dump_int(get_charinfo_index(co));
  dump_string(get_charinfo_name(co));
  dump_string(get_charinfo_tounicode(co));

  /* ligatures */
  x = 0;
  if ((lig = get_charinfo_ligatures(co)) != NULL) {
    while (!lig_end(lig[x])) { x++; }
    x++;
    dump_int(x);  dump_things(*lig, x);
  } else {
    dump_int(x);
  }
  /* kerns */
  x = 0;
  if ((kern = get_charinfo_kerns(co)) != NULL) {
    while (!kern_end(kern[x])) { x++; }
    x++;
    dump_int(x);  dump_things(*kern, x);
  } else {
    dump_int(x);	
  }
  /* packets */
  x= vf_packet_bytes(co);
  dump_int(x);  
  if (x>0) {
    dump_things(*get_charinfo_packets(co), x);
  }

  if (get_charinfo_tag(co)==ext_tag) {
    x = get_charinfo_extensible(co,EXT_TOP);       dump_int(x);
    x = get_charinfo_extensible(co,EXT_BOT);       dump_int(x);
    x = get_charinfo_extensible(co,EXT_MID);       dump_int(x);
    x = get_charinfo_extensible(co,EXT_REP);       dump_int(x);
  }
}
示例#9
0
charinfo_short
char_info_short (internal_font_number f, integer c) {
  charinfo_short s;
  charinfo *i;
  i = char_info(f,c);
  s.ci_wd = i->width;
  s.ci_dp = i->depth;
  s.ci_ht = i->height;
  return s;
}
示例#10
0
void tex::append_italic_correction ()
	{
	ptr	p;
	fnt	f;

	if (tail != head) {
		if (is_char_node(tail))
			p = tail;
		else if (type(tail) == LIGATURE_NODE)
			p = lig_char(tail);
		else return;
		f = font(p);
		tail = link(tail) =
			new_kern(char_italic(f, char_info(f, character(p))));
		subtype(tail) = EXPLICIT;
		}
	}
示例#11
0
void delete_font (integer f) {
  int i;
  charinfo *co;
  assert(f>0);
  if (font_tables[f]!=NULL) {
    set_font_name(f,NULL);
    set_font_filename(f,NULL);
    set_font_fullname(f,NULL);
    set_font_encodingname(f,NULL);
    set_font_area(f,NULL);
    set_font_cidregistry(f,NULL);
    set_font_cidordering(f,NULL);
    set_left_boundary(f,NULL);
    set_right_boundary(f,NULL);
    
    for(i=font_bc(f); i<=font_ec(f); i++) {
      if (char_exists(f,i)) {
		co = char_info(f,i);
		set_charinfo_name(co,NULL);
		set_charinfo_tounicode(co,NULL);
		set_charinfo_packets(co,NULL);
		set_charinfo_ligatures(co,NULL);
		set_charinfo_kerns(co,NULL);
		set_charinfo_extensible(co,0,0,0,0);
      }
    }
	/* free .notdef */
	set_charinfo_name(font_tables[f]->charinfo+0,NULL);
    free(font_tables[f]->charinfo);
    destroy_sa_tree(font_tables[f]->characters);

    free(param_base(f));
    free(font_tables[f]);
    font_tables[f] = NULL;

    if (font_id_maxval==f) {
      font_id_maxval--;
    }
  }
}
示例#12
0
scaled 
get_kern(internal_font_number f, integer lc, integer rc)
{
  integer k;
  kerninfo u;
  charinfo * co;
  if (lc == non_boundarychar || rc == non_boundarychar || (!has_kern(f,lc)) )
    return 0;
  k = 0;
  co = char_info(f,lc);
  while (1) {
    u = charinfo_kern(co,k);
    if (kern_end(u))
      break;
    if (kern_char(u) == rc) {
      if (kern_disabled(u))
	return 0;
      else
	return kern_kern(u);
    }
    k++;
  }
  return 0;
}
示例#13
0
integer ext_rep  (internal_font_number f, integer c) { 
  charinfo *ci = char_info(f,c);
  integer w = get_charinfo_extensible(ci,EXT_REP);
  /*fprintf(stdout,"rep of char 0x%4x in font %s: %i\n",c,font_name(f),w);*/
  return w;
}
示例#14
0
char *char_name (internal_font_number f, integer c) {
  charinfo *ci = char_info(f,c);
  return get_charinfo_name(ci);
}
示例#15
0
scaled char_height (internal_font_number f, integer c) { 
  charinfo *ci = char_info(f,c);
  scaled w = get_charinfo_height(ci);
  /*fprintf(stdout,"height of char 0x%x in font %s: %i\n",c,font_name(f),w);*/
  return w;
}
示例#16
0
integer
get_ef_code (internal_font_number f, integer c) {
  charinfo *ci = char_info(f,c);
  return get_charinfo_ef(ci);
}
示例#17
0
scaled char_italic (internal_font_number f, integer c) { 
  charinfo *ci = char_info(f,c);
  return get_charinfo_italic(ci);
}
示例#18
0
real_eight_bits * char_packets (internal_font_number f, integer c) {
  charinfo *ci = char_info(f,c);
  return get_charinfo_packets(ci);
}
示例#19
0
void tex::init_math ()
	{
	fnt	f;
	int	m, n;
	ptr	p, q;
	scal	d, l, s, v, w;

	get_token();
	if (cur_cmd == MATH_SHIFT && mode > 0) {
		if (head == tail) {
			pop_nest();
			w = -MAX_DIMEN;
		} else {
			line_break(display_widow_penalty);
			v = shift_amount(just_box) + 2 * quad(cur_font);
			w = -MAX_DIMEN;
			p = list_ptr(just_box);
			while (p != null) {
		reswitch:
				if (is_char_node(p)) {
					f = font(p);
					d = char_width(f,
						char_info(f, character(p)));
					goto found;
				}
				switch (type(p))
				{
				case HLIST_NODE:
				case VLIST_NODE:
				case RULE_NODE:
					d = box_width(p);
					goto found;
				
				case LIGATURE_NODE:
					p = make_char_from_lig(p);
					goto reswitch;
				
				case KERN_NODE:
					d = kern_width(p);
					break;

				case MATH_NODE:
					d = box_width(p);
					break;

				case GLUE_NODE:
					q = glue_ptr(p);
					d = box_width(q);
					if (glue_sign(just_box) ==
						STRETCHING) {
						if (glue_order(just_box) ==
							stretch_order(q)
						&& stretch(q) != 0)
							v = MAX_DIMEN;
					} else if (glue_sign(just_box) ==
						SHRINKING)  {
						if (glue_order(just_box) ==
							shrink_order(q)
						&& shrink(q) != 0) 
							v = MAX_DIMEN;
					}
					if (subtype(p) >= A_LEADERS)	
						goto found;
					break;

				case WHATSIT_NODE: 
					d = 0;
					break;

				default:
					d = 0;
					break;
				}
				if (v < MAX_DIMEN)
					v += d;
				goto not_found;
			
			found:
				if (v < MAX_DIMEN) {
					v += d;
					w = v;
				} else {
					w = MAX_DIMEN;
					break;
				}

			not_found:
				p = link(p);
			}
		}
		if (par_shape_ptr == null) {
			if (hang_indent != 0
			&& (hang_after >= 0
				&& prev_graf + 2 > hang_after
					|| prev_graf + 1 < -hang_after)) {
				l = hsize - abs(hang_indent);
				s = (hang_indent > 0) ? hang_indent : 0;
			} else {
				l = hsize;
				s = 0;
			}
		} else {
			n = info(par_shape_ptr);
			if (prev_graf + 2 >= n)
				m = n;
			else m = prev_graf + 2;
			l = par_shape_width(m);
			s = par_shape_indent(m);
		}
		push_math(MATH_SHIFT_GROUP);
		mode = MMODE;
		reg_define(int_reg[CUR_FAM_CODE], INT_REG, -1);
		reg_define(dimen_reg[PRE_DISPLAY_SIZE_CODE], DIMEN_REG, w);
		reg_define(dimen_reg[DISPLAY_WIDTH_CODE], DIMEN_REG, l);
		reg_define(dimen_reg[DISPLAY_INDENT_CODE], DIMEN_REG, s);
		if (every_display != null)
			begin_token_list(every_display, EVERY_DISPLAY_TEXT);
		if (nest_ptr == nest + 1)
			build_page();
	} else {
		back_input(); 
		push_math(MATH_SHIFT_GROUP);
		reg_define(int_reg[CUR_FAM_CODE], INT_REG, -1);
		if (every_math != null)
			begin_token_list(every_math, EVERY_MATH_TEXT);
	}
}
示例#20
0
integer char_index (internal_font_number f, integer c) {
  charinfo *ci = char_info(f,c);
  return get_charinfo_index(ci);
}
示例#21
0
liginfo * char_ligatures (internal_font_number f, integer c) {
  charinfo *ci = char_info(f,c);
  return get_charinfo_ligatures(ci);
}
示例#22
0
文件: info.c 项目: dylanyaga/openMerc
static void info(int cn)
{
	int n, cap, tmp;
	time_t t;
	double proz1, proz2;

	if (cn)
	{
		char_info(cn);
		return;
	}

	t = time(NULL);

	printf("<b>Statistics</b><br><br>\n");

	printf("Characters: %d of %d (%4.0f%%)<br>", globs->character_cnt, MAXCHARS, 100.0 / MAXCHARS * globs->character_cnt);
	printf("Awake: %d of %d (%4.0f%%)<br>", globs->awake, globs->character_cnt, 100.0 / globs->character_cnt * globs->awake);
	printf("Items: %d of %d (%4.0f%%)<br>", globs->item_cnt, MAXITEM, 100.0 / MAXITEM * globs->item_cnt);
	printf("Effects: %d of %d (%4.0f%%)<br><br>", globs->effect_cnt, MAXEFFECT, 100.0 / MAXEFFECT * globs->effect_cnt);

	printf("Items expired: %d in %d runs<br>", globs->expire_cnt, globs->expire_run);
	printf("Garbage items destroyed: %d in %d runs<br>", globs->gc_cnt, globs->gc_run);
	printf("Lost links reset: %d in %d runs<br><br>", globs->lost_cnt, globs->lost_run);

	proz1 = 100.0 / ((t - globs->transfer_reset_time) * (80.0 / 30 / 24 / 60 / 60)) * ((globs->recv + globs->send) / (1024.0 * 1024 * 1024));
	proz2 = globs->load_avg / 100.0;

	printf("Total bandwith usage: %.4fGB recv, %.4fGB send<br>", (globs->recv / (1024.0 * 1024.0 * 1024.0)), (globs->send / (1024.0 * 1024.0 * 1024.0)));
	printf("Sum: %.4fGB, Allowed: %.4fGB (%.2f%%)<br>",
	       (globs->recv + globs->send) / (1024.0 * 1024 * 1024),
	       (double)(t - globs->transfer_reset_time) * (80.0 / 30 / 24 / 60 / 60),
	       proz1);

	printf("CPU usage: %ld%% (current) %.2f%% (avg)<br>", globs->load, proz2);

	cap = (double)(globs->total_online_time) / (double)(globs->uptime) * 100 / proz1;

	printf("Suggested CAP=%d (%d)<br><br>", cap, (int)((double)(globs->total_online_time) / (double)(globs->uptime)));

	printf("<table>");
	printf("<tr><td>Uptime: </td><td>%lldh</td><td>%lldm</td><td>%llds</td></tr>",
	       (globs->uptime / (TICKS * 60 * 60)),
	       (globs->uptime / (TICKS * 60) % 60),
	       (globs->uptime / (TICKS)) % 60);
	printf("<tr><td>Total online time: </td><td>%lldh</td><td>%lldm</td><td>%llds</td></tr>",
	       (globs->total_online_time / (TICKS * 60 * 60)),
	       (globs->total_online_time / (TICKS * 60) % 60),
	       (globs->total_online_time / (TICKS)) % 60);

	if (globs->uptime && globs->total_online_time)
	{
		printf("<tr><td>Average players online: </td><td>%.2f</td></tr>\n",
		       (float)(globs->total_online_time) / (float)(globs->uptime));
	}
	printf("</table><br>");

	printf("Today is the %d%s%s%s%s day of the Year %d. It is %d:%02d Astonian Standard Time.<br>",
	       globs->mdday,
	       (globs->mdday==1 ? "st" : ""),
	       (globs->mdday==2 ? "nd" : ""),
	       (globs->mdday==3 ? "rd" : ""),
	       (globs->mdday>3 ? "th" : ""),
	       globs->mdyear, globs->mdtime / 3600, (globs->mdtime / 60) % 60);

	if (globs->mdday % 28 + 1==1)
	{
		printf("New Moon tonight!<br><br>");
	}
	else if (globs->mdday % 28 + 1<15)
	{
		printf("The Moon is growing.<br><br>");
	}
	else if (globs->mdday % 28 + 1==15)
	{
		printf("Full Moon tonight!<br><br>");
	}
	else
	{
		printf("The moon is dwindling.<br><br>");
	}
}
示例#23
0
kerninfo * char_kerns (internal_font_number f, integer c) {
  charinfo *ci = char_info(f,c);
  return get_charinfo_kerns(ci);
}
示例#24
0
void pdf_hlist_out (void)
{
  scaled base_line;
  scaled left_edge;
  scaled save_h, save_v;
  pointer this_box;
  // glue_ord g_order;
  int g_order;
  // char g_sign;
  int g_sign;
  pointer p;
  integer save_loc;
  pointer leader_box;
  scaled leader_wd;
  scaled lx;
  boolean outer_doing_leaders;
  scaled edge;
  real glue_temp;
  real cur_glue;
  scaled cur_g;

  cur_g = 0;
  cur_glue = 0.0;
  this_box = temp_ptr;
  g_order = glue_order(this_box);
  g_sign = glue_sign(this_box);
  p = list_ptr(this_box);
  incr(cur_s);

  if (cur_s > max_push)
    max_push = cur_s;

  save_loc = dvi_offset + dvi_ptr;
  base_line = cur_v;
  left_edge = cur_h;

  while (p != 0)
reswitch:
  if (is_char_node(p))
  {
    pdf_synch_h();
    pdf_synch_v();

    do
    {
      f = font(p);
      c = character(p);

      if (f != dvi_f)
      {
        if (!font_used[f])
        {
          font_used[f] = true;
          font_id[f]   = pdf_get_font_id(f);
        }

        dvi_f = f;
      }

      pdf_out_char(dvi_f, c);
      cur_h = cur_h + char_width(f, char_info(f, c));
      p = link(p);
    } while (!(!is_char_node(p)));

    dvi_h = cur_h;
  }
  else
  {
    switch (type(p))
    {
      case hlist_node:
      case vlist_node:
        if (list_ptr(p) == 0)
          cur_h = cur_h + width(p);
        else
        {
          save_h = dvi_h;
          save_v = dvi_v;
          cur_v = base_line + shift_amount(p);
          temp_ptr = p;
          edge = cur_h;

          if (type(p) == vlist_node)
            pdf_vlist_out();
          else
            pdf_hlist_out();

          dvi_h = save_h;
          dvi_v = save_v;
          cur_h = edge + width(p);
          cur_v = base_line;
        }
        break;

      case rule_node:
        {
          rule_ht = height(p);
          rule_dp = depth(p);
          rule_wd = width(p);
          goto fin_rule;
        }
        break;

      case whatsit_node:
        out_what(p);
        break;

      case glue_node:
        {
          g = glue_ptr(p);
          rule_wd = width(g) - cur_g;

          if (g_sign != normal)
          {
            if (g_sign == stretching)
            {
              if (stretch_order(g) == g_order)
              {
                cur_glue = cur_glue + stretch(g);
                vet_glue(glue_set(this_box) * cur_glue);
                cur_g = round(glue_temp);
              }
            }
            else if (shrink_order(g) == g_order)
            {
              cur_glue = cur_glue - shrink(g);
              vet_glue(glue_set(this_box) * cur_glue);
              cur_g = round(glue_temp);
            }
          }

          rule_wd = rule_wd + cur_g;

          if (subtype(p) >= a_leaders)
          {
            leader_box = leader_ptr(p);

            if (type(leader_box) == rule_node)
            {
              rule_ht = height(leader_box);
              rule_dp = depth(leader_box);
              goto fin_rule;
            }

            leader_wd = width(leader_box);

            if ((leader_wd > 0) && (rule_wd > 0))
            {
              rule_wd = rule_wd + 10;
              edge = cur_h + rule_wd;
              lx = 0;

              if (subtype(p) == a_leaders)
              {
                save_h = cur_h;
                cur_h = left_edge + leader_wd * ((cur_h - left_edge) / leader_wd);

                if (cur_h < save_h)
                  cur_h = cur_h + leader_wd;
              }
              else
              {
                lq = rule_wd / leader_wd;
                lr = rule_wd % leader_wd;

                if (subtype(p) == c_leaders)
                  cur_h = cur_h + (lr / 2);
                else
                {
                  lx = (2 * lr + lq + 1) / (2 * lq + 2);
                  cur_h = cur_h + ((lr - (lq - 1)* lx) / 2);
                }
              }

              while (cur_h + leader_wd <= edge)
              {
                cur_v = base_line + shift_amount(leader_box);
                pdf_synch_v();
                save_v = dvi_v;
                pdf_synch_h();
                save_h = dvi_h;
                temp_ptr = leader_box;
                outer_doing_leaders = doing_leaders;
                doing_leaders = true;

                if (type(leader_box) == vlist_node)
                  pdf_vlist_out();
                else
                  pdf_hlist_out();

                doing_leaders = outer_doing_leaders;
                dvi_v = save_v;
                dvi_h = save_h;
                cur_v = base_line;
                cur_h = save_h + leader_wd + lx;
              }

              cur_h = edge - 10;
              goto next_p;
            }
          }

          goto move_past;
        }
        break;

      case kern_node:
      case math_node:
        cur_h = cur_h + width(p);
        break;

      case ligature_node:
        {
          mem[lig_trick] = mem[lig_char(p)];
          link(lig_trick) = link(p);
          p = lig_trick;
          goto reswitch;
        }
        break;

      default:
        break;
    }

    goto next_p;

fin_rule:
    if (is_running(rule_ht))
      rule_ht = height(this_box);

    if (is_running(rule_dp))
      rule_dp = depth(this_box);

    rule_ht = rule_ht + rule_dp;

    if ((rule_ht > 0) && (rule_wd > 0))
    {
      pdf_synch_h();
      cur_v = base_line + rule_dp;
      pdf_synch_v();
      pdf_dev_set_rule(dvi_h, -dvi_v, rule_wd, rule_ht);
      cur_v = base_line;
      dvi_h = dvi_h + rule_wd;
    }

move_past:
    cur_h = cur_h + rule_wd;

next_p:
    p = link(p);
  }

  prune_movements(save_loc);
  decr(cur_s);
}
示例#25
0
文件: eval.c 项目: syntheticpp/cpptex
void tex::main_control()
	{
	if (every_job != null)
		begin_token_list(every_job, EVERY_JOB_TEXT);
	
	big_switch:
	get_x_token();

   reswitch:
	if (tracing_commands > 0)
		show_cur_cmd_chr();
	
	switch(abs(mode) + cur_cmd) {
		hmode(LETTER):
		hmode(OTHER_CHAR):
		hmode(CHAR_GIVEN):
			goto main_loop;
		
		hmode(CHAR_NUM):
			scan_char_num();
		   cur_chr = cur_val;
		   goto main_loop;
		
		hmode(NO_BOUNDARY):
			get_x_token();
		   if (cur_cmd == LETTER || cur_cmd == OTHER_CHAR
				 || cur_cmd == CHAR_GIVEN || cur_cmd == CHAR_NUM) {
				cancel_boundary = TRUE;
				}
			goto reswitch;

		hmode(SPACER):
			if (space_factor == 1000) {
				goto append_normal_space;
				} 
			else {
				app_space();
				}
		   break;
	
	hmode(EX_SPACE):
	mmode(EX_SPACE):
		goto append_normal_space;
	
	any_mode(RELAX):
	vmode(SPACER):
	mmode(SPACER):
	mmode(NO_BOUNDARY):
		break;
	
	any_mode(IGNORE_SPACES):
		get_nbx_token();
		goto reswitch;

	vmode(STOP):
		if (its_all_over())
			return;
		break;

	any_mode(LAST_ITEM):
	any_mode(MAC_PARAM):
	non_math(EQ_NO):
	vmode(VMOVE):
	hmode(HMOVE):
	mmode(HMOVE):
	vmode(VADJUST):
	vmode(ITAL_CORR):
		report_illegal_case();
		break;

	non_math(SUP_MARK):
	non_math(SUB_MARK):
	non_math(MATH_CHAR_NUM):
	non_math(MATH_GIVEN):
	non_math(MATH_COMP):
	non_math(DELIM_NUM):
	non_math(LEFT_RIGHT):
	non_math(ABOVE):
	non_math(RADICAL):
	non_math(MATH_STYLE):
	non_math(MATH_CHOICE):
	non_math(VCENTER):
	non_math(NON_SCRIPT):
	non_math(MKERN):
	non_math(LIMIT_SWITCH):
	non_math(MSKIP):
	non_math(MATH_ACCENT):
	mmode(ENDV):
	mmode(PAR_END):
	mmode(STOP):
	mmode(VSKIP):
	mmode(UN_VBOX):
	mmode(VALIGN):
	mmode(HRULE):
		insert_dollar_sign();
		break;
	
	vmode(HRULE):
	hmode(VRULE):
	mmode(VRULE):
		tail_append(scan_rule_spec());
		if (abs(mode) == VMODE)
			prev_depth = IGNORE_DEPTH;
		else if (abs(mode) == HMODE)
			space_factor = 1000;
		break;
	
	vmode(VSKIP):
	hmode(HSKIP):
	mmode(HSKIP):
	mmode(MSKIP):
		append_glue();
		break;
	
	any_mode(KERN):
	mmode(MKERN):
		append_kern();
		break;
	
	non_math(LEFT_BRACE):
		new_save_level(SIMPLE_GROUP);
		break;

	any_mode(BEGIN_GROUP):
		new_save_level(SEMI_SIMPLE_GROUP);
		break;

	any_mode(END_GROUP):
		if (cur_group == SEMI_SIMPLE_GROUP) {
			unsave();
		} else {
			off_save();
		}
		break;
	
	any_mode(RIGHT_BRACE):
		handle_right_brace();
		break;

	vmode(HMOVE):
	hmode(VMOVE):
	mmode(VMOVE): {
		int	t;

		t = cur_chr;
		scan_normal_dimen();
		if (t == 0) {
			scan_box(cur_val);
		} else {
			scan_box(-cur_val);
		}
		break;
	}
	any_mode(LEADER_SHIP):
		scan_box(LEADER_FLAG + cur_chr - A_LEADERS);
		break;
	
	any_mode(MAKE_BOX):
		begin_box(0);
		break;

	vmode(START_PAR):
		new_graf(cur_chr > 0);
		break;
	
	vmode(LETTER):
	vmode(OTHER_CHAR):
	vmode(CHAR_NUM):
	vmode(CHAR_GIVEN):
	vmode(MATH_SHIFT):
	vmode(UN_HBOX):
	vmode(VRULE):
	vmode(ACCENT):
	vmode(DISCRETIONARY):
	vmode(HSKIP):
	vmode(VALIGN):
	vmode(EX_SPACE):
	vmode(NO_BOUNDARY):
		back_input();
		new_graf(TRUE);
		break;
	
	hmode(START_PAR):
	mmode(START_PAR):
		indent_in_hmode();
		break;
	
	vmode(PAR_END):
		normal_paragraph();
		if (mode > 0)
			build_page();
		break;

	hmode(PAR_END):
		if (align_state < 0)
			off_save();
		end_graf();
		if (mode == VMODE)	
			build_page();
		break;
	
	hmode(STOP):
	hmode(VSKIP):
	hmode(HRULE):
	hmode(UN_VBOX):
	hmode(HALIGN):
		head_for_vmode();
		break;
	
	any_mode(INSERT):
	hmode(VADJUST):
	mmode(VADJUST):
		begin_insert_or_adjust();
		break;
	
	any_mode(MARK):
		make_mark();
		break;
	
	any_mode(BREAK_PENALTY):
		append_penalty();
		break;
	
	any_mode(REMOVE_ITEM):
		delete_last();
		break;
	
	vmode(UN_VBOX):
	hmode(UN_HBOX):
	mmode(UN_HBOX):
		unpackage();
		break;
	
	hmode(ITAL_CORR):
		append_italic_correction();
		break;
	
	mmode(ITAL_CORR):
		tail_append(new_kern(0));
		break;

	hmode(DISCRETIONARY):
	mmode(DISCRETIONARY):
		append_discretionary();
		break;
	
	hmode(ACCENT):
		make_accent();
		break;
	
	any_mode(CAR_RET):
	any_mode(TAB_MARK):
		align_error();
		break;

	any_mode(NO_ALIGN):
		no_align_error();
		break;
	
	any_mode(OMIT):
		omit_error();
		break;

	vmode(HALIGN):
	hmode(VALIGN):
		init_align();
		break;
	
	mmode(HALIGN):
		if (privileged()) {
			if (cur_group == MATH_SHIFT_GROUP) {
				init_align();
			} else {
				off_save();
			}
		}
		break;

	vmode(ENDV):
	hmode(ENDV):
		do_endv();
		break;
	
	any_mode(END_CS_NAME):
		cs_error();
		break;

	hmode(MATH_SHIFT):
		init_math();
		break;
	
	mmode(EQ_NO):
		if (privileged()) {
			if (cur_group == MATH_SHIFT_GROUP) {
				start_eq_no();
			} else {
				off_save();
			}
		}
		break;
	
	mmode(LEFT_BRACE):
		tail_append(new_noad());
		back_input();
		scan_math(nucleus(tail));
		break;

	mmode(LETTER):
	mmode(OTHER_CHAR):
	mmode(CHAR_GIVEN):
		if (cur_chr < 256)
			set_math_char(math_code(cur_chr));
		else set_math_char(cur_chr);
		break;
	
	mmode(CHAR_NUM):
		scan_char_num();
		cur_chr = cur_val;
		if (cur_chr < 256)
			set_math_char(math_code(cur_chr));
		else set_math_char(cur_chr);
		break;
	
	mmode(MATH_CHAR_NUM):
		scan_fifteen_bit_int();
		set_math_char(cur_val);
		break;
	
	mmode(MATH_GIVEN):
		set_math_char(cur_chr);
		break;

	mmode(DELIM_NUM):
		scan_twenty_seven_bit_int();
		set_math_char(cur_val / 010000);
		break;
	
	mmode(MATH_COMP):
		tail_append(new_noad());
		type(tail) = cur_chr;
		scan_math(nucleus(tail));
		break;
	
	mmode(LIMIT_SWITCH):
		math_limit_switch();
		break;

	mmode(RADICAL):
		math_radical();
		break;

	mmode(ACCENT):
	mmode(MATH_ACCENT):
		math_ac();
		break;

	mmode(VCENTER):
		scan_spec(VCENTER_GROUP, FALSE);
		normal_paragraph();
		push_nest();
		mode = -VMODE;
		prev_depth = IGNORE_DEPTH;
		if (every_vbox != null)
			begin_token_list(every_vbox, EVERY_VBOX_TEXT);
		break;
	
	mmode(MATH_STYLE):
		tail_append(new_style(cur_chr));
		break;
	
	mmode(NON_SCRIPT):
		tail_append(new_glue(zero_glue));
		subtype(tail) = COND_MATH_GLUE;
		break;
	
	mmode(MATH_CHOICE):
		append_choices();
		break;

	mmode(SUB_MARK):
	mmode(SUP_MARK):
		sub_sup();
		break;
	
	mmode(ABOVE):
		math_fraction();
		break;
	
	mmode(LEFT_RIGHT):
		math_left_right();
		break;

	mmode(MATH_SHIFT):
		if (cur_group == MATH_SHIFT_GROUP) {
			after_math();
		} else {
			off_save();
		}
		break;

	any_mode(AFTER_ASSIGNMENT):
		get_token();
		after_token = cur_tok;
		break;
	
	any_mode(AFTER_GROUP):
		get_token();
		save_for_after(cur_tok);
		break;

	any_mode(IN_STREAM):
		clopen_stream();
		break;

	any_mode(MESSAGE):
		issue_message();
		break;
	
	any_mode(CASE_SHIFT):
		shift_case();
		break;
	
	any_mode(XRAY):
		show_whatever();
		break;
	
	any_mode(EXTENSION):
		do_extension();
		break;
	
	default:
		prefixed_command();
		break;
	}
	goto big_switch;

#define adjust_space_factor() \
{ \
	main_s = sf_code(cur_chr); \
	if (main_s == 1000) { \
		space_factor = 1000; \
	} else if (main_s < 1000) { \
		if (main_s > 0) { \
			space_factor = main_s; \
		} \
	} else if (space_factor < 1000) { \
		space_factor = 1000; \
	} else { \
		space_factor = main_s; \
	} \
}
		
main_loop:
	adjust_space_factor();
	main_f = cur_font;
	bchar = font_bchar(main_f);
	false_bchar = font_false_bchar(main_f);
	if (mode > 0 && language != clang)
		fix_language();
	fast_new_avail(lig_stack);
	font(lig_stack) = main_f;
	character(lig_stack) = cur_l = cur_chr;
	cur_q = tail;
	if (cancel_boundary) {
		cancel_boundary = FALSE;
		main_k = NON_ADDRESS;
	} else {
		main_k = bchar_label(main_f);
	}
	if (main_k == NON_ADDRESS)
		goto main_loop_move_2;
	cur_r = cur_l;
	cur_l = NON_CHAR;
	goto main_lig_loop_1;

#define pack_lig(RT_HIT) \
{ \
	main_p = new_ligature(main_f, cur_l, link(cur_q)); \
	if (lft_hit) { \
		subtype(main_p) = 2; \
		lft_hit = FALSE; \
	} \
	if (RT_HIT && lig_stack == null) { \
		incr(subtype(main_p)); \
		rt_hit = FALSE; \
	} \
	tail = link(cur_q) = main_p; \
	ligature_present = FALSE; \
}

#define wrapup(RT_HIT) \
{ \
	if (cur_l < NON_CHAR) { \
		if (character(tail) == hyphen_char(main_f) \
		&& link(cur_q) != null) \
			ins_disc = TRUE; \
		if (ligature_present) \
			pack_lig(RT_HIT); \
		if (ins_disc) { \
			ins_disc = FALSE; \
			if (mode > 0) \
				tail_append(new_disc()); \
		} \
	} \
}

main_loop_wrapup:
	wrapup(rt_hit);

main_loop_move:
	if (lig_stack == null)
		goto reswitch;
	cur_q = tail;
	cur_l = cur_r;

main_loop_move_1:
	if (!is_char_node(lig_stack))
		goto main_loop_move_lig;

main_loop_move_2:
	if (cur_chr < font_bc(main_f) || cur_chr > font_ec(main_f)) {
		char_warning(main_f, cur_chr);
		free_avail(lig_stack);
		goto big_switch;
	}
	main_i = char_info(main_f, cur_l);
	if (!char_exists(main_i)) {
		char_warning(main_f, cur_chr);
		free_avail(lig_stack);
		goto big_switch;
	}
	tail_append(lig_stack);

main_loop_lookahead:
	get_next();
	if (cur_cmd == LETTER
	|| cur_cmd == OTHER_CHAR
	|| cur_cmd == CHAR_GIVEN) {
		goto main_loop_lookahead_1;
	}
	x_token();
	if (cur_cmd == LETTER
	|| cur_cmd == OTHER_CHAR
	|| cur_cmd == CHAR_GIVEN) {
		goto main_loop_lookahead_1;
	}
	if (cur_cmd == CHAR_NUM) {
		scan_char_num();
		cur_chr = cur_val;
		goto main_loop_lookahead_1;
	}
	if (cur_cmd == NO_BOUNDARY) {
		bchar = NON_CHAR;
	}
	cur_r = bchar;
	lig_stack = null;
	goto main_lig_loop;

main_loop_lookahead_1:
	adjust_space_factor();
	fast_new_avail(lig_stack);
	font(lig_stack) = main_f;
	character(lig_stack) = cur_r = cur_chr;
	if (cur_r == false_bchar) {
		cur_r = NON_CHAR;
	}

main_lig_loop:
	if (char_tag(main_i) != LIG_TAG) {
		goto main_loop_wrapup;
	}
	main_k = lig_kern_start(main_f, main_i);
	main_j = *main_k;
	if (skip_byte(main_j) <= STOP_FLAG) {
		goto main_lig_loop_2;
	}
	main_k = lig_kern_restart(main_f, main_j);

main_lig_loop_1:
	main_j = *main_k;

main_lig_loop_2:
	if (next_char(main_j) == cur_r
	&& skip_byte(main_j) <= STOP_FLAG) {
		if (op_byte(main_j) >= KERN_FLAG) {
			wrapup(rt_hit);
			tail_append(new_kern(char_kern(main_f, main_j)));
			goto main_loop_move;
		}
		if (cur_l == NON_CHAR) {
			lft_hit = TRUE;
		} else if (lig_stack == null) {
			rt_hit = TRUE;
		}
		if(interrupted) throw std::logic_error("interrupted");
		switch (op_byte(main_j))
		{
		case 1: case 5:
			cur_l = rem_byte(main_j);
			main_i = char_info(main_f, cur_l);
			ligature_present = TRUE;
			break;
			
		case 2: case 6:
			cur_r = rem_byte(main_j);
			if (lig_stack == null) {
				lig_stack = new_lig_item(cur_r);
				bchar = NON_CHAR;
			} else if (is_char_node(lig_stack)) {
				main_p = lig_stack;
				lig_stack = new_lig_item(cur_r);
				lig_ptr(lig_stack) = main_p;
			} else {
				character(lig_stack) = cur_r;
			}
			break;

		case 3:
			cur_r = rem_byte(main_j);
			main_p = lig_stack;
			lig_stack = new_lig_item(cur_r);
			link(lig_stack) = main_p;
			break;

		case 7: case 11:
			wrapup(FALSE);
			cur_q = tail;
			cur_l = rem_byte(main_j);
			main_i = char_info(main_f, cur_l);
			ligature_present = TRUE;
			break;

		default:
			cur_l = rem_byte(main_j);
			ligature_present = TRUE;
			if (lig_stack == null) {
				goto main_loop_wrapup;
			} else {
				goto main_loop_move_1;
			}
			break;
		}
		if (op_byte(main_j) > 4 && op_byte(main_j) != 7)
			goto main_loop_wrapup;
		if (cur_l < NON_CHAR)
			goto main_lig_loop;
		main_k = bchar_label(main_f);
		goto main_lig_loop_1;
	}
	if (skip_byte(main_j) == 0) {
		incr(main_k);
	} else {
		if (skip_byte(main_j) >= STOP_FLAG)
			goto main_loop_wrapup;
		main_k += skip_byte(main_j) + 1;
	}
	goto main_lig_loop_1;

main_loop_move_lig:
	main_p = lig_ptr(lig_stack);
	if (main_p != null) {
		tail_append(main_p);
	}
	main_t = lig_stack;
	lig_stack = link(main_t);
	free_node(main_t, SMALL_NODE_SIZE);
	main_i = char_info(main_f, cur_l);
	ligature_present = TRUE;
	if (lig_stack == null) {
		if (main_p != null) {
			goto main_loop_lookahead;
		} else {
			cur_r = bchar;
		}
	} else {
		cur_r = character(lig_stack);
	}
	goto main_lig_loop;

append_normal_space:
	if (space_skip == zero_glue) {
		main_p = font_glue(cur_font);
		if (main_p == null)
			main_p = find_font_glue(cur_font);
		main_t = new_glue(main_p);
	} else {
		main_t = new_param_glue(SPACE_SKIP_CODE);
	}
	tail_append(main_t);
	goto big_switch;
}