Exemple #1
0
int overline_box::compute_metrics(int style)
{
  int r = p->compute_metrics(cramped_style(style));
  // 9
  printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]+%dM\n",
	 uid, p->uid, default_rule_thickness*5);
  printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
  printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
  return r;
}
Exemple #2
0
int over_box::compute_metrics(int style)
{
  if (reduce_size) {
    style = script_style(style);
    printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
    set_script_size();
    printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
  }
  int mark_uid = 0;
  int res = num->compute_metrics(style);
  if (res)
    mark_uid = num->uid;
  int r = den->compute_metrics(cramped_style(style));
  if (r && res)
    error("multiple marks and lineups");
  else {
    mark_uid = den->uid;
    res = r;
  }
  if (reduce_size)
    printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
  printf(".nr " WIDTH_FORMAT " (\\n[" WIDTH_FORMAT "]>?\\n[" WIDTH_FORMAT "]", 
	 uid, num->uid, den->uid);
  // allow for \(ru being wider than both the numerator and denominator
  if (!draw_flag)
    fputs(">?\\w" DELIMITER_CHAR "\\(ru" DELIMITER_CHAR, stdout);
  printf(")+%dM\n", null_delimiter_space*2 + over_hang*2);
  // 15b
  printf(".nr " SUP_RAISE_FORMAT " %dM\n",
	 uid, (reduce_size ? num2 : num1));
  printf(".nr " SUB_LOWER_FORMAT " %dM\n",
	 uid, (reduce_size ? denom2 : denom1));

  // 15d
  printf(".nr " SUP_RAISE_FORMAT " +(\\n[" DEPTH_FORMAT
	 "]-\\n[" SUP_RAISE_FORMAT "]+%dM+(%dM/2)+%dM)>?0\n",
	 uid, num->uid, uid, axis_height, default_rule_thickness,
	 default_rule_thickness*(reduce_size ? 1 : 3));
  printf(".nr " SUB_LOWER_FORMAT " +(\\n[" HEIGHT_FORMAT
	 "]-\\n[" SUB_LOWER_FORMAT "]-%dM+(%dM/2)+%dM)>?0\n",
	 uid, den->uid, uid, axis_height, default_rule_thickness,
	 default_rule_thickness*(reduce_size ? 1 : 3));


  printf(".nr " HEIGHT_FORMAT " \\n[" SUP_RAISE_FORMAT "]+\\n["
	 HEIGHT_FORMAT "]\n",
	 uid, uid, num->uid);
  printf(".nr " DEPTH_FORMAT " \\n[" SUB_LOWER_FORMAT "]+\\n["
	 DEPTH_FORMAT "]\n",
	 uid, uid, den->uid);
  if (res)
    printf(".nr " MARK_REG " +(\\n[" WIDTH_FORMAT "]-\\n["
	   WIDTH_FORMAT "]/2)\n", uid, mark_uid);
  return res;
}
Exemple #3
0
int limit_box::compute_metrics(int style)
{
  printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
  if (!(style <= SCRIPT_STYLE && one_size_reduction_flag))
    set_script_size();
  printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
  int res = 0;
  int mark_uid = -1;
  if (from != 0) {
    res = from->compute_metrics(cramped_style(script_style(style)));
    if (res)
      mark_uid = from->uid;
  }
  if (to != 0) {
    int r = to->compute_metrics(script_style(style));
    if (res && r)
      error("multiple marks and lineups");
    else  {
      mark_uid = to->uid;
      res = r;
    }
  }
  printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
  int r = p->compute_metrics(style);
  p->compute_subscript_kern();
  if (res && r)
    error("multiple marks and lineups");
  else {
    mark_uid = p->uid;
    res = r;
  }
  printf(".nr " LEFT_WIDTH_FORMAT " "
	 "0\\n[" WIDTH_FORMAT "]",
	 uid, p->uid);
  if (from != 0)
    printf(">?(\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
	   p->uid, from->uid);
  if (to != 0)
    printf(">?(-\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
	   p->uid, to->uid);
  printf("/2\n");
  printf(".nr " WIDTH_FORMAT " "
	 "0\\n[" WIDTH_FORMAT "]",
	 uid, p->uid);
  if (from != 0)
    printf(">?(-\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
	   p->uid, from->uid);
  if (to != 0)
    printf(">?(\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
	   p->uid, to->uid);
  printf("/2+\\n[" LEFT_WIDTH_FORMAT "]\n", uid);
  printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]", uid, p->uid);
  if (to != 0)
    printf(">?\\n[" WIDTH_FORMAT "]", to->uid);
  if (from != 0)
    printf(">?\\n[" WIDTH_FORMAT "]", from->uid);
  printf("\n");
  if (res)
    printf(".nr " MARK_REG " +(\\n[" LEFT_WIDTH_FORMAT "]"
	   "-(\\n[" WIDTH_FORMAT "]/2))\n",
	   uid, mark_uid);
  if (to != 0) {
    printf(".nr " SUP_RAISE_FORMAT " %dM+\\n[" DEPTH_FORMAT
	   "]>?%dM+\\n[" HEIGHT_FORMAT "]\n",
	   uid, big_op_spacing1, to->uid, big_op_spacing3, p->uid);
    printf(".nr " HEIGHT_FORMAT " \\n[" SUP_RAISE_FORMAT "]+\\n["
	   HEIGHT_FORMAT "]+%dM\n",
	   uid, uid, to->uid, big_op_spacing5);
  }
  else
    printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
  if (from != 0) {
    printf(".nr " SUB_LOWER_FORMAT " %dM+\\n[" HEIGHT_FORMAT
	   "]>?%dM+\\n[" DEPTH_FORMAT "]\n",
	   uid, big_op_spacing2, from->uid, big_op_spacing4, p->uid);
    printf(".nr " DEPTH_FORMAT " \\n[" SUB_LOWER_FORMAT "]+\\n["
	   DEPTH_FORMAT "]+%dM\n",
	   uid, uid, from->uid, big_op_spacing5);
  }
  else
    printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
  return res;
}
Exemple #4
0
int sqrt_box::compute_metrics(int style)
{
  // 11
  int r = p->compute_metrics(cramped_style(style));
  printf(".nr " TEMP_REG " \\n[" HEIGHT_FORMAT "]+\\n[" DEPTH_FORMAT
	 "]+%dM+(%dM/4)\n",
	 p->uid, p->uid, default_rule_thickness,
	 (style > SCRIPT_STYLE ? x_height : default_rule_thickness));
  printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
  printf(".ds " SQRT_STRING_FORMAT " " SQRT_CHAR "\n", uid);
  printf(".ds " BAR_STRING " " RADICAL_EXTENSION_CHAR "\n");
  printf(".nr " SQRT_WIDTH_FORMAT
	 " 0\\w" DELIMITER_CHAR SQRT_CHAR DELIMITER_CHAR "\n",
	 uid);
  printf(".if \\n[rst]-\\n[rsb]-%dM<\\n[" TEMP_REG "] \\{",
	 default_rule_thickness);

  printf(".nr " INDEX_REG " 0\n"
	 ".de " TEMP_MACRO "\n"
	 ".ie c" SQRT_CHAIN " \\{"
	 ".ds " SQRT_STRING_FORMAT " " SQRT_CHAIN "\n"
	 ".ie c" BAR_CHAIN " .ds " BAR_STRING " " BAR_CHAIN "\n"
	 ".el .ds " BAR_STRING " " RADICAL_EXTENSION_CHAR "\n"
	 ".nr " SQRT_WIDTH_FORMAT
	 " 0\\w" DELIMITER_CHAR SQRT_CHAIN DELIMITER_CHAR "\n"
	 ".if \\\\n[rst]-\\\\n[rsb]-%dM<\\n[" TEMP_REG "] \\{"
	 ".nr " INDEX_REG " +1\n"
	 "." TEMP_MACRO "\n"
	 ".\\}\\}\n"
	 ".el .nr " INDEX_REG " 0-1\n"
	 "..\n"
	 "." TEMP_MACRO "\n",
	 uid, uid, default_rule_thickness);

  printf(".if \\n[" INDEX_REG "]<0 \\{");

  // Determine the maximum point size
  printf(".ps 1000\n");
  printf(".nr " MAX_SIZE_REG " \\n[.ps]\n");
  printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
  // We define a macro that will increase the current point size
  // until we get a radical sign that's tall enough or we reach
  // the maximum point size.
  printf(".de " TEMP_MACRO "\n"
	 ".nr " SQRT_WIDTH_FORMAT
	 " 0\\w" DELIMITER_CHAR "\\*[" SQRT_STRING_FORMAT "]" DELIMITER_CHAR "\n"
	 ".if \\\\n[rst]"
	 "&(\\\\n[rst]-\\\\n[rsb]-%dM<\\n[" TEMP_REG "])"
	 "&(\\\\n[.ps]<\\n[" MAX_SIZE_REG "]) \\{"
	 ".ps +1\n"
	 "." TEMP_MACRO "\n"
	 ".\\}\n"
	 "..\n"
	 "." TEMP_MACRO "\n",
	 uid, uid, default_rule_thickness);
  
  printf(".\\}\\}\n");

  printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
  // set TEMP_REG to the amount by which the radical sign is too big
  printf(".nr " TEMP_REG " \\n[rst]-\\n[rsb]-%dM-\\n[" TEMP_REG "]\n",
	 default_rule_thickness);
  // If TEMP_REG is negative, the bottom of the radical sign should
  // be -TEMP_REG above the bottom of p. If it's positive, the bottom
  // of the radical sign should be TEMP_REG/2 below the bottom of p.
  // This calculates the amount by which the baseline of the radical
  // should be raised.
  printf(".nr " SUP_RAISE_FORMAT " (-\\n[" TEMP_REG "]>?(-\\n[" TEMP_REG "]/2))"
	 "-\\n[rsb]-\\n[" DEPTH_FORMAT "]\n", uid, p->uid);
  printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]"
	 ">?(\\n[" SUP_RAISE_FORMAT "]+\\n[rst])\n",
	 uid, p->uid, uid);
  printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]"
	 ">?(-\\n[" SUP_RAISE_FORMAT "]-\\n[rsb])\n",
	 uid, p->uid, uid);
  // Do this last, so we don't lose height and depth information on
  // the radical sign.
  // Remember that the width of the bar might be greater than the width of p.

  printf(".nr " TEMP_REG " "
	 "\\n[" WIDTH_FORMAT "]"
	 ">?\\w" DELIMITER_CHAR "\\*[" BAR_STRING "]" DELIMITER_CHAR "\n",
	 p->uid);
  printf(".as " SQRT_STRING_FORMAT " "
	 "\\l'\\n[" TEMP_REG "]u\\&\\*[" BAR_STRING "]'\n",
	 uid);
  printf(".nr " WIDTH_FORMAT " \\n[" TEMP_REG "]"
	 "+\\n[" SQRT_WIDTH_FORMAT "]\n",
	 uid, uid);

  if (r)
    printf(".nr " MARK_REG " +\\n[" SQRT_WIDTH_FORMAT "]\n", uid);
  // the top of the bar might be higher than the top of the radical sign
  printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]"
	 ">?(\\n[" SUP_RAISE_FORMAT "]+\\n[rst])\n",
	 uid, p->uid, uid);
  // put a bit of extra space above the bar
  printf(".nr " HEIGHT_FORMAT " +%dM\n", uid, default_rule_thickness);
  printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
  return r;
}
Exemple #5
0
int script_box::compute_metrics(int style)
{
  int res = p->compute_metrics(style);
  p->compute_subscript_kern();
  printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
  if (!(style <= SCRIPT_STYLE && one_size_reduction_flag))
    set_script_size();
  printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
  if (sub != 0)
    sub->compute_metrics(cramped_style(script_style(style)));
  if (sup != 0)
    sup->compute_metrics(script_style(style));
  // 18a
  if (p->is_char()) {
    printf(".nr " SUP_RAISE_FORMAT " 0\n", uid);
    printf(".nr " SUB_LOWER_FORMAT " 0\n", uid);
  }
  else {
    printf(".nr " SUP_RAISE_FORMAT " \\n[" HEIGHT_FORMAT "]-%dM>?0\n",
	   uid, p->uid, sup_drop);
    printf(".nr " SUB_LOWER_FORMAT " \\n[" DEPTH_FORMAT "]+%dM\n",
	   uid, p->uid, sub_drop);
  }
  printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
  if (sup == 0) {
    assert(sub != 0);
    // 18b
    printf(".nr " SUB_LOWER_FORMAT " \\n[" SUB_LOWER_FORMAT "]>?%dM>?(\\n["
	   HEIGHT_FORMAT "]-(%dM*4/5))\n",
	   uid, uid, sub1, sub->uid, x_height);
  }
  else {
    // sup != 0
    // 18c
    int pos;
    if (style == DISPLAY_STYLE)
      pos = sup1;
    else if (style & 1)		// not cramped
      pos = sup2;
    else
      pos = sup3;
    printf(".nr " SUP_RAISE_FORMAT " \\n[" SUP_RAISE_FORMAT
	   "]>?%dM>?(\\n[" DEPTH_FORMAT "]+(%dM/4))\n",
	   uid, uid, pos, sup->uid, x_height);
    // 18d
    if (sub != 0) {
      printf(".nr " SUB_LOWER_FORMAT " \\n[" SUB_LOWER_FORMAT "]>?%dM\n",
	     uid, uid, sub2);
      // 18e
      printf(".nr " TEMP_REG " \\n[" DEPTH_FORMAT "]-\\n["
	     SUP_RAISE_FORMAT "]+\\n[" HEIGHT_FORMAT "]-\\n["
	     SUB_LOWER_FORMAT "]+(4*%dM)\n",
	     sup->uid, uid, sub->uid, uid, default_rule_thickness);
      printf(".if \\n[" TEMP_REG "] \\{");
      printf(".nr " SUB_LOWER_FORMAT " +\\n[" TEMP_REG "]\n", uid);
      printf(".nr " TEMP_REG " (%dM*4/5)-\\n[" SUP_RAISE_FORMAT
	     "]+\\n[" DEPTH_FORMAT "]>?0\n",
	     x_height, uid, sup->uid);
      printf(".nr " SUP_RAISE_FORMAT " +\\n[" TEMP_REG "]\n", uid);
      printf(".nr " SUB_LOWER_FORMAT " -\\n[" TEMP_REG "]\n", uid);
      printf(".\\}\n");
    }
  }
  printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]", uid, p->uid);
  if (sub != 0 && sup != 0)
    printf("+((\\n[" WIDTH_FORMAT "]-\\n[" SUB_KERN_FORMAT "]>?\\n["
	   WIDTH_FORMAT "])+%dM)>?0\n",
	   sub->uid, p->uid, sup->uid, script_space);
  else if (sub != 0)
    printf("+(\\n[" WIDTH_FORMAT "]-\\n[" SUB_KERN_FORMAT "]+%dM)>?0\n",
	   sub->uid, p->uid, script_space);
  else if (sup != 0)
    printf("+(\\n[" WIDTH_FORMAT "]+%dM)>?0\n", sup->uid, script_space);
  else
    printf("\n");
  printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]",
	 uid, p->uid);
  if (sup != 0)
    printf(">?(\\n[" SUP_RAISE_FORMAT "]+\\n[" HEIGHT_FORMAT "])",
	   uid, sup->uid);
  if (sub != 0)
    printf(">?(-\\n[" SUB_LOWER_FORMAT "]+\\n[" HEIGHT_FORMAT "])",
	   uid, sub->uid);
  printf("\n");
  printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]",
	 uid, p->uid);
  if (sub != 0)
    printf(">?(\\n[" SUB_LOWER_FORMAT "]+\\n[" DEPTH_FORMAT "])",
	   uid, sub->uid);
  if (sup != 0)
    printf(">?(-\\n[" SUP_RAISE_FORMAT "]+\\n[" DEPTH_FORMAT "])",
	   uid, sup->uid);
  printf("\n");
  return res;
}