]>
git.cameronkatri.com Git - mandoc.git/blob - term_ps.c
1 /* $Id: term_ps.c,v 1.46 2011/01/25 17:32:04 kristaps Exp $ */
3 * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include <sys/types.h>
37 /* Convert PostScript point "x" to an AFM unit. */
38 #define PNT2AFM(p, x) /* LINTED */ \
39 (size_t)((double)(x) * (1000.0 / (double)(p)->engine.ps.scale))
41 /* Convert an AFM unit "x" to a PostScript points */
42 #define AFM2PNT(p, x) /* LINTED */ \
43 ((double)(x) / (1000.0 / (double)(p)->engine.ps.scale))
46 unsigned short wx
; /* WX in AFM */
50 const char *name
; /* FontName in AFM */
51 #define MAXCHAR 95 /* total characters we can handle */
52 struct glyph gly
[MAXCHAR
]; /* glyph metrics */
56 * We define, for the time being, three fonts: bold, oblique/italic, and
57 * normal (roman). The following table hard-codes the font metrics for
58 * ASCII, i.e., 32--127.
61 static const struct font fonts
[TERMFONT__MAX
] = {
355 /* These work the buffer used by the header and footer. */
356 #define PS_BUFSLOP 128
359 ps_growbuf(struct termp
*p
, size_t sz
)
361 if (p
->engine
.ps
.psmargcur
+ sz
<= p
->engine
.ps
.psmargsz
)
367 p
->engine
.ps
.psmargsz
+= sz
;
369 p
->engine
.ps
.psmarg
= realloc
370 (p
->engine
.ps
.psmarg
,
371 p
->engine
.ps
.psmargsz
);
373 if (NULL
== p
->engine
.ps
.psmarg
) {
375 exit((int)MANDOCLEVEL_SYSERR
);
379 static double ps_hspan(const struct termp
*,
380 const struct roffsu
*);
381 static size_t ps_width(const struct termp
*, char);
382 static void ps_advance(struct termp
*, size_t);
383 static void ps_begin(struct termp
*);
384 static void ps_closepage(struct termp
*);
385 static void ps_end(struct termp
*);
386 static void ps_endline(struct termp
*);
387 static void ps_fclose(struct termp
*);
388 static void ps_letter(struct termp
*, char);
389 static void ps_pclose(struct termp
*);
390 static void ps_pletter(struct termp
*, int);
391 static void ps_printf(struct termp
*, const char *, ...);
392 static void ps_putchar(struct termp
*, char);
393 static void ps_setfont(struct termp
*, enum termfont
);
394 static struct termp
*pspdf_alloc(char *);
395 static void pdf_obj(struct termp
*, size_t);
399 pdf_alloc(char *outopts
)
403 if (NULL
!= (p
= pspdf_alloc(outopts
)))
404 p
->type
= TERMTYPE_PDF
;
411 ps_alloc(char *outopts
)
415 if (NULL
!= (p
= pspdf_alloc(outopts
)))
416 p
->type
= TERMTYPE_PS
;
422 static struct termp
*
423 pspdf_alloc(char *outopts
)
426 size_t pagex
, pagey
, marginx
, marginy
, lineheight
;
431 p
= term_alloc(TERMENC_ASCII
);
433 p
->advance
= ps_advance
;
436 p
->endline
= ps_endline
;
438 p
->letter
= ps_letter
;
446 while (outopts
&& *outopts
)
447 switch (getsubopt(&outopts
, UNCONST(toks
), &v
)) {
455 /* Default to US letter (millimetres). */
461 * The ISO-269 paper sizes can be calculated automatically, but
462 * it would require bringing in -lm for pow() and I'd rather not
463 * do that. So just do it the easy way for now. Since this
464 * only happens once, I'm not terribly concerned.
467 if (pp
&& strcasecmp(pp
, "letter")) {
468 if (0 == strcasecmp(pp
, "a3")) {
471 } else if (0 == strcasecmp(pp
, "a4")) {
474 } else if (0 == strcasecmp(pp
, "a5")) {
477 } else if (0 == strcasecmp(pp
, "legal")) {
480 } else if (2 != sscanf(pp
, "%zux%zu", &pagex
, &pagey
))
481 fprintf(stderr
, "%s: Unknown paper\n", pp
);
482 } else if (NULL
== pp
)
486 * This MUST be defined before any PNT2AFM or AFM2PNT
487 * calculations occur.
490 p
->engine
.ps
.scale
= 11;
492 /* Remember millimetres -> AFM units. */
494 pagex
= PNT2AFM(p
, ((double)pagex
* 2.834));
495 pagey
= PNT2AFM(p
, ((double)pagey
* 2.834));
497 /* Margins are 1/9 the page x and y. */
499 marginx
= /* LINTED */
500 (size_t)((double)pagex
/ 9.0);
501 marginy
= /* LINTED */
502 (size_t)((double)pagey
/ 9.0);
504 /* Line-height is 1.4em. */
506 lineheight
= PNT2AFM(p
, ((double)p
->engine
.ps
.scale
* 1.4));
508 p
->engine
.ps
.width
= pagex
;
509 p
->engine
.ps
.height
= pagey
;
510 p
->engine
.ps
.header
= pagey
- (marginy
/ 2) - (lineheight
/ 2);
511 p
->engine
.ps
.top
= pagey
- marginy
;
512 p
->engine
.ps
.footer
= (marginy
/ 2) - (lineheight
/ 2);
513 p
->engine
.ps
.bottom
= marginy
;
514 p
->engine
.ps
.left
= marginx
;
515 p
->engine
.ps
.lineheight
= lineheight
;
517 p
->defrmargin
= pagex
- (marginx
* 2);
523 pspdf_free(void *arg
)
527 p
= (struct termp
*)arg
;
529 if (p
->engine
.ps
.psmarg
)
530 free(p
->engine
.ps
.psmarg
);
531 if (p
->engine
.ps
.pdfobjs
)
532 free(p
->engine
.ps
.pdfobjs
);
539 ps_printf(struct termp
*p
, const char *fmt
, ...)
547 * If we're running in regular mode, then pipe directly into
548 * vprintf(). If we're processing margins, then push the data
549 * into our growable margin buffer.
552 if ( ! (PS_MARGINS
& p
->engine
.ps
.flags
)) {
553 len
= vprintf(fmt
, ap
);
555 p
->engine
.ps
.pdfbytes
+= /* LINTED */
556 len
< 0 ? 0 : (size_t)len
;
561 * XXX: I assume that the in-margin print won't exceed
562 * PS_BUFSLOP (128 bytes), which is reasonable but still an
563 * assumption that will cause pukeage if it's not the case.
566 ps_growbuf(p
, PS_BUFSLOP
);
568 pos
= (int)p
->engine
.ps
.psmargcur
;
569 len
= vsnprintf(&p
->engine
.ps
.psmarg
[pos
], PS_BUFSLOP
, fmt
, ap
);
573 p
->engine
.ps
.psmargcur
= strlen(p
->engine
.ps
.psmarg
);
578 ps_putchar(struct termp
*p
, char c
)
582 /* See ps_printf(). */
584 if ( ! (PS_MARGINS
& p
->engine
.ps
.flags
)) {
587 p
->engine
.ps
.pdfbytes
++;
593 pos
= (int)p
->engine
.ps
.psmargcur
++;
594 p
->engine
.ps
.psmarg
[pos
++] = c
;
595 p
->engine
.ps
.psmarg
[pos
] = '\0';
600 pdf_obj(struct termp
*p
, size_t obj
)
605 if ((obj
- 1) >= p
->engine
.ps
.pdfobjsz
) {
606 p
->engine
.ps
.pdfobjsz
= obj
+ 128;
607 p
->engine
.ps
.pdfobjs
= realloc
608 (p
->engine
.ps
.pdfobjs
,
609 p
->engine
.ps
.pdfobjsz
* sizeof(size_t));
610 if (NULL
== p
->engine
.ps
.pdfobjs
) {
612 exit((int)MANDOCLEVEL_SYSERR
);
616 p
->engine
.ps
.pdfobjs
[(int)obj
- 1] = p
->engine
.ps
.pdfbytes
;
617 ps_printf(p
, "%zu 0 obj\n", obj
);
622 ps_closepage(struct termp
*p
)
628 * Close out a page that we've already flushed to output. In
629 * PostScript, we simply note that the page must be showed. In
630 * PDF, we must now create the Length, Resource, and Page node
631 * for the page contents.
634 assert(p
->engine
.ps
.psmarg
&& p
->engine
.ps
.psmarg
[0]);
635 ps_printf(p
, "%s", p
->engine
.ps
.psmarg
);
637 if (TERMTYPE_PS
!= p
->type
) {
638 ps_printf(p
, "ET\n");
640 len
= p
->engine
.ps
.pdfbytes
- p
->engine
.ps
.pdflastpg
;
641 base
= p
->engine
.ps
.pages
* 4 + p
->engine
.ps
.pdfbody
;
643 ps_printf(p
, "endstream\nendobj\n");
645 /* Length of content. */
646 pdf_obj(p
, base
+ 1);
647 ps_printf(p
, "%zu\nendobj\n", len
);
649 /* Resource for content. */
650 pdf_obj(p
, base
+ 2);
651 ps_printf(p
, "<<\n/ProcSet [/PDF /Text]\n");
652 ps_printf(p
, "/Font <<\n");
653 for (i
= 0; i
< (int)TERMFONT__MAX
; i
++)
654 ps_printf(p
, "/F%d %d 0 R\n", i
, 3 + i
);
655 ps_printf(p
, ">>\n>>\n");
658 pdf_obj(p
, base
+ 3);
659 ps_printf(p
, "<<\n");
660 ps_printf(p
, "/Type /Page\n");
661 ps_printf(p
, "/Parent 2 0 R\n");
662 ps_printf(p
, "/Resources %zu 0 R\n", base
+ 2);
663 ps_printf(p
, "/Contents %zu 0 R\n", base
);
664 ps_printf(p
, ">>\nendobj\n");
666 ps_printf(p
, "showpage\n");
668 p
->engine
.ps
.pages
++;
669 p
->engine
.ps
.psrow
= p
->engine
.ps
.top
;
670 assert( ! (PS_NEWPAGE
& p
->engine
.ps
.flags
));
671 p
->engine
.ps
.flags
|= PS_NEWPAGE
;
677 ps_end(struct termp
*p
)
679 size_t i
, xref
, base
;
682 * At the end of the file, do one last showpage. This is the
683 * same behaviour as groff(1) and works for multiple pages as
687 if ( ! (PS_NEWPAGE
& p
->engine
.ps
.flags
)) {
688 assert(0 == p
->engine
.ps
.flags
);
689 assert('\0' == p
->engine
.ps
.last
);
693 if (TERMTYPE_PS
== p
->type
) {
694 ps_printf(p
, "%%%%Trailer\n");
695 ps_printf(p
, "%%%%Pages: %zu\n", p
->engine
.ps
.pages
);
696 ps_printf(p
, "%%%%EOF\n");
701 ps_printf(p
, "<<\n/Type /Pages\n");
702 ps_printf(p
, "/MediaBox [0 0 %zu %zu]\n",
703 (size_t)AFM2PNT(p
, p
->engine
.ps
.width
),
704 (size_t)AFM2PNT(p
, p
->engine
.ps
.height
));
706 ps_printf(p
, "/Count %zu\n", p
->engine
.ps
.pages
);
707 ps_printf(p
, "/Kids [");
709 for (i
= 0; i
< p
->engine
.ps
.pages
; i
++)
710 ps_printf(p
, " %zu 0 R", i
* 4 +
711 p
->engine
.ps
.pdfbody
+ 3);
713 base
= (p
->engine
.ps
.pages
- 1) * 4 +
714 p
->engine
.ps
.pdfbody
+ 4;
716 ps_printf(p
, "]\n>>\nendobj\n");
718 ps_printf(p
, "<<\n");
719 ps_printf(p
, "/Type /Catalog\n");
720 ps_printf(p
, "/Pages 2 0 R\n");
721 ps_printf(p
, ">>\n");
722 xref
= p
->engine
.ps
.pdfbytes
;
723 ps_printf(p
, "xref\n");
724 ps_printf(p
, "0 %zu\n", base
+ 1);
725 ps_printf(p
, "0000000000 65535 f \n");
727 for (i
= 0; i
< base
; i
++)
728 ps_printf(p
, "%.10zu 00000 n \n",
729 p
->engine
.ps
.pdfobjs
[(int)i
]);
731 ps_printf(p
, "trailer\n");
732 ps_printf(p
, "<<\n");
733 ps_printf(p
, "/Size %zu\n", base
+ 1);
734 ps_printf(p
, "/Root %zu 0 R\n", base
);
735 ps_printf(p
, "/Info 1 0 R\n");
736 ps_printf(p
, ">>\n");
737 ps_printf(p
, "startxref\n");
738 ps_printf(p
, "%zu\n", xref
);
739 ps_printf(p
, "%%%%EOF\n");
744 ps_begin(struct termp
*p
)
750 * Print margins into margin buffer. Nothing gets output to the
751 * screen yet, so we don't need to initialise the primary state.
754 if (p
->engine
.ps
.psmarg
) {
755 assert(p
->engine
.ps
.psmargsz
);
756 p
->engine
.ps
.psmarg
[0] = '\0';
759 /*p->engine.ps.pdfbytes = 0;*/
760 p
->engine
.ps
.psmargcur
= 0;
761 p
->engine
.ps
.flags
= PS_MARGINS
;
762 p
->engine
.ps
.pscol
= p
->engine
.ps
.left
;
763 p
->engine
.ps
.psrow
= p
->engine
.ps
.header
;
765 ps_setfont(p
, TERMFONT_NONE
);
767 (*p
->headf
)(p
, p
->argf
);
770 p
->engine
.ps
.pscol
= p
->engine
.ps
.left
;
771 p
->engine
.ps
.psrow
= p
->engine
.ps
.footer
;
773 (*p
->footf
)(p
, p
->argf
);
776 p
->engine
.ps
.flags
&= ~PS_MARGINS
;
778 assert(0 == p
->engine
.ps
.flags
);
779 assert(p
->engine
.ps
.psmarg
);
780 assert('\0' != p
->engine
.ps
.psmarg
[0]);
783 * Print header and initialise page state. Following this,
784 * stuff gets printed to the screen, so make sure we're sane.
789 if (TERMTYPE_PS
== p
->type
) {
790 ps_printf(p
, "%%!PS-Adobe-3.0\n");
791 ps_printf(p
, "%%%%Creator: mandoc-%s\n", VERSION
);
792 ps_printf(p
, "%%%%CreationDate: %s", ctime(&t
));
793 ps_printf(p
, "%%%%DocumentData: Clean7Bit\n");
794 ps_printf(p
, "%%%%Orientation: Portrait\n");
795 ps_printf(p
, "%%%%Pages: (atend)\n");
796 ps_printf(p
, "%%%%PageOrder: Ascend\n");
797 ps_printf(p
, "%%%%DocumentMedia: "
798 "Default %zu %zu 0 () ()\n",
799 (size_t)AFM2PNT(p
, p
->engine
.ps
.width
),
800 (size_t)AFM2PNT(p
, p
->engine
.ps
.height
));
801 ps_printf(p
, "%%%%DocumentNeededResources: font");
803 for (i
= 0; i
< (int)TERMFONT__MAX
; i
++)
804 ps_printf(p
, " %s", fonts
[i
].name
);
806 ps_printf(p
, "\n%%%%EndComments\n");
808 ps_printf(p
, "%%PDF-1.1\n");
810 ps_printf(p
, "<<\n");
811 ps_printf(p
, "/Creator mandoc-%s\n", VERSION
);
812 ps_printf(p
, ">>\n");
813 ps_printf(p
, "endobj\n");
815 for (i
= 0; i
< (int)TERMFONT__MAX
; i
++) {
816 pdf_obj(p
, (size_t)i
+ 3);
817 ps_printf(p
, "<<\n");
818 ps_printf(p
, "/Type /Font\n");
819 ps_printf(p
, "/Subtype /Type1\n");
820 ps_printf(p
, "/Name /F%zu\n", i
);
821 ps_printf(p
, "/BaseFont /%s\n", fonts
[i
].name
);
822 ps_printf(p
, ">>\n");
826 p
->engine
.ps
.pdfbody
= (size_t)TERMFONT__MAX
+ 3;
827 p
->engine
.ps
.pscol
= p
->engine
.ps
.left
;
828 p
->engine
.ps
.psrow
= p
->engine
.ps
.top
;
829 p
->engine
.ps
.flags
|= PS_NEWPAGE
;
830 ps_setfont(p
, TERMFONT_NONE
);
835 ps_pletter(struct termp
*p
, int c
)
840 * If we haven't opened a page context, then output that we're
841 * in a new page and make sure the font is correctly set.
844 if (PS_NEWPAGE
& p
->engine
.ps
.flags
) {
845 if (TERMTYPE_PS
== p
->type
) {
846 ps_printf(p
, "%%%%Page: %zu %zu\n",
847 p
->engine
.ps
.pages
+ 1,
848 p
->engine
.ps
.pages
+ 1);
849 ps_printf(p
, "/%s %zu selectfont\n",
850 fonts
[(int)p
->engine
.ps
.lastf
].name
,
853 pdf_obj(p
, p
->engine
.ps
.pdfbody
+
854 p
->engine
.ps
.pages
* 4);
855 ps_printf(p
, "<<\n");
856 ps_printf(p
, "/Length %zu 0 R\n",
857 p
->engine
.ps
.pdfbody
+ 1 +
858 p
->engine
.ps
.pages
* 4);
859 ps_printf(p
, ">>\nstream\n");
861 p
->engine
.ps
.pdflastpg
= p
->engine
.ps
.pdfbytes
;
862 p
->engine
.ps
.flags
&= ~PS_NEWPAGE
;
866 * If we're not in a PostScript "word" context, then open one
867 * now at the current cursor.
870 if ( ! (PS_INLINE
& p
->engine
.ps
.flags
)) {
871 if (TERMTYPE_PS
!= p
->type
) {
872 ps_printf(p
, "BT\n/F%d %zu Tf\n",
873 (int)p
->engine
.ps
.lastf
,
875 ps_printf(p
, "%.3f %.3f Td\n(",
876 AFM2PNT(p
, p
->engine
.ps
.pscol
),
877 AFM2PNT(p
, p
->engine
.ps
.psrow
));
879 ps_printf(p
, "%.3f %.3f moveto\n(",
880 AFM2PNT(p
, p
->engine
.ps
.pscol
),
881 AFM2PNT(p
, p
->engine
.ps
.psrow
));
882 p
->engine
.ps
.flags
|= PS_INLINE
;
885 assert( ! (PS_NEWPAGE
& p
->engine
.ps
.flags
));
888 * We need to escape these characters as per the PostScript
889 * specification. We would also escape non-graphable characters
890 * (like tabs), but none of them would get to this point and
891 * it's superfluous to abort() on them.
906 /* Write the character and adjust where we are on the page. */
908 f
= (int)p
->engine
.ps
.lastf
;
910 if (c
<= 32 || (c
- 32 >= MAXCHAR
)) {
912 p
->engine
.ps
.pscol
+= (size_t)fonts
[f
].gly
[0].wx
;
916 ps_putchar(p
, (char)c
);
918 p
->engine
.ps
.pscol
+= (size_t)fonts
[f
].gly
[c
].wx
;
923 ps_pclose(struct termp
*p
)
927 * Spit out that we're exiting a word context (this is a
928 * "partial close" because we don't check the last-char buffer
932 if ( ! (PS_INLINE
& p
->engine
.ps
.flags
))
935 if (TERMTYPE_PS
!= p
->type
) {
936 ps_printf(p
, ") Tj\nET\n");
938 ps_printf(p
, ") show\n");
940 p
->engine
.ps
.flags
&= ~PS_INLINE
;
945 ps_fclose(struct termp
*p
)
949 * Strong closure: if we have a last-char, spit it out after
950 * checking that we're in the right font mode. This will of
951 * course open a new scope, if applicable.
953 * Following this, close out any scope that's open.
956 if ('\0' != p
->engine
.ps
.last
) {
957 if (p
->engine
.ps
.lastf
!= TERMFONT_NONE
) {
959 ps_setfont(p
, TERMFONT_NONE
);
961 ps_pletter(p
, p
->engine
.ps
.last
);
962 p
->engine
.ps
.last
= '\0';
965 if ( ! (PS_INLINE
& p
->engine
.ps
.flags
))
973 ps_letter(struct termp
*p
, char c
)
978 * State machine dictates whether to buffer the last character
979 * or not. Basically, encoded words are detected by checking if
980 * we're an "8" and switching on the buffer. Then we put "8" in
981 * our buffer, and on the next charater, flush both character
982 * and buffer. Thus, "regular" words are detected by having a
983 * regular character and a regular buffer character.
986 if ('\0' == p
->engine
.ps
.last
) {
988 p
->engine
.ps
.last
= c
;
990 } else if (8 == p
->engine
.ps
.last
) {
992 p
->engine
.ps
.last
= '\0';
994 assert(8 != p
->engine
.ps
.last
);
995 if ('_' == p
->engine
.ps
.last
) {
996 if (p
->engine
.ps
.lastf
!= TERMFONT_UNDER
) {
998 ps_setfont(p
, TERMFONT_UNDER
);
1000 } else if (p
->engine
.ps
.lastf
!= TERMFONT_BOLD
) {
1002 ps_setfont(p
, TERMFONT_BOLD
);
1004 p
->engine
.ps
.last
= c
;
1007 if (p
->engine
.ps
.lastf
!= TERMFONT_NONE
) {
1009 ps_setfont(p
, TERMFONT_NONE
);
1011 cc
= p
->engine
.ps
.last
;
1012 p
->engine
.ps
.last
= c
;
1021 ps_advance(struct termp
*p
, size_t len
)
1025 * Advance some spaces. This can probably be made smarter,
1026 * i.e., to have multiple space-separated words in the same
1027 * scope, but this is easier: just close out the current scope
1028 * and readjust our column settings.
1032 p
->engine
.ps
.pscol
+= len
;
1037 ps_endline(struct termp
*p
)
1040 /* Close out any scopes we have open: we're at eoln. */
1045 * If we're in the margin, don't try to recalculate our current
1046 * row. XXX: if the column tries to be fancy with multiple
1047 * lines, we'll do nasty stuff.
1050 if (PS_MARGINS
& p
->engine
.ps
.flags
)
1055 p
->engine
.ps
.pscol
= p
->engine
.ps
.left
;
1057 /* If we haven't printed anything, return. */
1059 if (PS_NEWPAGE
& p
->engine
.ps
.flags
)
1063 * Put us down a line. If we're at the page bottom, spit out a
1064 * showpage and restart our row.
1067 if (p
->engine
.ps
.psrow
>= p
->engine
.ps
.lineheight
+
1068 p
->engine
.ps
.bottom
) {
1069 p
->engine
.ps
.psrow
-= p
->engine
.ps
.lineheight
;
1078 ps_setfont(struct termp
*p
, enum termfont f
)
1081 assert(f
< TERMFONT__MAX
);
1082 p
->engine
.ps
.lastf
= f
;
1085 * If we're still at the top of the page, let the font-setting
1086 * be delayed until we actually have stuff to print.
1089 if (PS_NEWPAGE
& p
->engine
.ps
.flags
)
1092 if (TERMTYPE_PS
== p
->type
)
1093 ps_printf(p
, "/%s %zu selectfont\n",
1095 p
->engine
.ps
.scale
);
1097 ps_printf(p
, "/F%d %zu Tf\n",
1099 p
->engine
.ps
.scale
);
1105 ps_width(const struct termp
*p
, char c
)
1108 if (c
<= 32 || c
- 32 >= MAXCHAR
)
1109 return((size_t)fonts
[(int)TERMFONT_NONE
].gly
[0].wx
);
1112 return((size_t)fonts
[(int)TERMFONT_NONE
].gly
[(int)c
].wx
);
1117 ps_hspan(const struct termp
*p
, const struct roffsu
*su
)
1122 * All of these measurements are derived by converting from the
1123 * native measurement to AFM units.
1128 r
= PNT2AFM(p
, su
->scale
* 28.34);
1131 r
= PNT2AFM(p
, su
->scale
* 72);
1134 r
= PNT2AFM(p
, su
->scale
* 12);
1137 r
= PNT2AFM(p
, su
->scale
* 100);
1141 fonts
[(int)TERMFONT_NONE
].gly
[109 - 32].wx
;
1144 r
= PNT2AFM(p
, su
->scale
* 2.834);
1148 fonts
[(int)TERMFONT_NONE
].gly
[110 - 32].wx
;
1151 r
= su
->scale
* p
->engine
.ps
.lineheight
;