From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id o5UD00GP016407 for ; Wed, 30 Jun 2010 09:00:00 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id o5UD00IM001140; Wed, 30 Jun 2010 09:00:00 -0400 (EDT) Date: Wed, 30 Jun 2010 09:00:00 -0400 (EDT) Message-Id: <201006301300.o5UD00IM001140@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: PostScript can now handle scaled glyph sizes (see "scale" in X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- PostScript can now handle scaled glyph sizes (see "scale" in struct termp_ps) to arbitrarily scale font. Tested with 10 (default), 12, 14. Modified Files: -------------- mdocml: term.h term_ps.c Revision Data ------------- Index: term.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.h,v retrieving revision 1.71 retrieving revision 1.72 diff -Lterm.h -Lterm.h -u -p -r1.71 -r1.72 --- term.h +++ term.h @@ -52,6 +52,7 @@ struct termp_ps { size_t psmargcur; /* cur index in margin buf */ char last; /* character buffer */ enum termfont lastf; /* last set font */ + size_t scale; /* font scaling factor */ size_t pages; /* number of pages shown */ size_t lineheight; /* line height (AFM units) */ size_t top; /* body top (AFM units) */ Index: term_ps.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v retrieving revision 1.20 retrieving revision 1.21 diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.20 -r1.21 --- term_ps.c +++ term_ps.c @@ -32,6 +32,14 @@ #include "main.h" #include "term.h" +/* Convert PostScript point "x" to an AFM unit. */ +#define PNT2AFM(p, x) \ + (size_t)((double)(x) * (1000.0 / (double)(p)->engine.ps.scale)) + +/* Convert an AFM unit "x" to a PostScript points */ +#define AFM2PNT(p, x) \ + (size_t)((double)(x) / (1000.0 / (double)(p)->engine.ps.scale)) + struct glyph { int wx; /* WX in AFM */ }; @@ -395,6 +403,8 @@ ps_alloc(char *outopts) p->letter = ps_letter; p->type = TERMTYPE_PS; p->width = ps_width; + + p->engine.ps.scale = 10; toks[0] = "paper"; toks[1] = NULL; @@ -410,17 +420,17 @@ ps_alloc(char *outopts) break; } + margin = PNT2AFM(p, 72); + lineheight = PNT2AFM(p, 12); + if (0 == strcasecmp(paper, "a4")) { - pagex = 595 * 100; - pagey = 842 * 100; + pagex = PNT2AFM(p, 595); + pagey = PNT2AFM(p, 842); } else { - pagex = 612 * 100; - pagey = 792 * 100; + pagex = PNT2AFM(p, 612); + pagey = PNT2AFM(p, 792); } - margin = 72 * 100; - lineheight = 12 * 100; - assert(margin * 2 < pagex); assert(margin * 2 < pagey); @@ -615,8 +625,8 @@ ps_pletter(struct termp *p, int c) if ( ! (PS_INLINE & p->engine.ps.psstate)) { ps_printf(p, "%zu %zu moveto\n(", - (size_t)(p->engine.ps.pscol / 100), - (size_t)(p->engine.ps.psrow / 100)); + AFM2PNT(p, p->engine.ps.pscol), + AFM2PNT(p, p->engine.ps.psrow)); p->engine.ps.psstate |= PS_INLINE; } @@ -810,7 +820,8 @@ ps_setfont(struct termp *p, enum termfon { assert(f < TERMFONT__MAX); - ps_printf(p, "/%s 10 selectfont\n", fonts[(int)f].name); + ps_printf(p, "/%s %zu selectfont\n", + fonts[(int)f].name, p->engine.ps.scale); p->engine.ps.lastf = f; } @@ -835,29 +846,28 @@ ps_hspan(const struct termp *p, const st /* * All of these measurements are derived by converting from the - * native measurement to AFM units, which are (scalesize/1000). - * Since scalesize is 10 for us, we can just skip to (x/100). + * native measurement to AFM units. */ switch (su->unit) { case (SCALE_CM): - r = su->scale * 28.34 * 100; + r = PNT2AFM(p, su->scale * 28.34); break; case (SCALE_IN): - r = su->scale * 72 * 100; + r = PNT2AFM(p, su->scale * 72); break; case (SCALE_PC): - r = su->scale * 12 * 100; + r = PNT2AFM(p, su->scale * 12); break; case (SCALE_PT): - r = su->scale * 100; + r = PNT2AFM(p, su->scale * 100); break; case (SCALE_EM): r = su->scale * fonts[(int)TERMFONT_NONE].gly[109 - 32].wx; break; case (SCALE_MM): - r = su->scale * 2.834 * 100; + r = PNT2AFM(p, su->scale * 2.834); break; case (SCALE_EN): r = su->scale * -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv