home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume19 / xvertext / part02 < prev    next >
Encoding:
Text File  |  1993-05-26  |  50.8 KB  |  1,807 lines

  1. Newsgroups: comp.sources.x
  2. From: mppa3@syma.sussex.ac.uk (Alan Richardson)
  3. Subject: v19i112:  xvertext - functions for drawing text at ANY ANGLE in an X window, Part02/02
  4. Message-ID: <1993May19.220403.19692@sparky.imd.sterling.com>
  5. X-Md4-Signature: 71951614561f1035a603000880c31837
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Wed, 19 May 1993 22:04:03 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: mppa3@syma.sussex.ac.uk (Alan Richardson)
  12. Posting-number: Volume 19, Issue 112
  13. Archive-name: xvertext/part02
  14. Environment: X11
  15. Supersedes: xvertext: Volume 19, Issue 85
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  CHANGES INSTALL Imakefile Makefile.std example.c
  22. #   man/Imakefile man/XRotDrawAlignedString.man
  23. #   man/XRotSetMagnification.man man/XRotTextExtents.man
  24. #   man/xvertext.man rotated.h xvertext.tmpl
  25. # Wrapped by chris@sparky on Wed May 19 16:51:54 1993
  26. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  27. echo If this archive is complete, you will see the following message:
  28. echo '          "shar: End of archive 2 (of 2)."'
  29. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'CHANGES'\"
  31. else
  32.   echo shar: Extracting \"'CHANGES'\" \(2986 characters\)
  33.   sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  34. X   Version 5.0 (25/4/92):
  35. X   ----------------------
  36. X
  37. X   Fonts can now be magnified to greater than their normal size.
  38. XObviously since they're bitmap fonts the effect isn't startling, but it's 
  39. Xbetter than you might think.
  40. X
  41. X   --
  42. X
  43. X   Font ID's can be cached, albeit unreliably, if font names aren't
  44. Xavailable. Thanks to Paul "E." Maisano <pem@aaii.oz.au>.
  45. X
  46. X   --
  47. X
  48. X   Bounding boxes can now be deduced and returned in an XPoint list.
  49. XVasco Lopes Paulo (vlp@latina.inesc.pt) suggested this.
  50. X
  51. X   --
  52. X
  53. X   You can set the stipple bitmap,x-y origin and plane on the gc you pass into
  54. Xthe functions (only R4+). Vasco Lopes Paulo (vlp@latina.inesc.pt) worked
  55. Xon this.
  56. X
  57. X   --
  58. X
  59. X   Wrote some more demo screens to illustrate above features.
  60. X
  61. X   --
  62. X   
  63. X   Vasco Lopes Paulo (vlp@latina.inesc.pt) suggested changes to `rotated.h'
  64. Xto make it C++ compliant.
  65. X
  66. X   --
  67. X
  68. X   Corrected minor positional bugs.
  69. X
  70. X   --
  71. X
  72. X   Added an Imakefile, thanks to Nicole Seiffert 
  73. X<seiffert@iti.informatik.th-darmstadt.de> who wrote this. I hacked it a 
  74. Xbit so I hope I haven't broken it :-(
  75. X
  76. X
  77. X-------------------------------------------------------------------------------
  78. X
  79. X
  80. X   Version 4.0 (18/4/92):
  81. X   ----------------------
  82. X
  83. X   Added a cache to store items of rotated text, so that redraws are 
  84. Xmuch faster. See the README for details.
  85. X  
  86. X   --
  87. X
  88. X   Corrected (I hope!) several memory leaks in version 3.1. Many people got
  89. Xin touch about this - thanks to:
  90. X
  91. X      Per-Erik Nordbo <pererik@afrodite.cmr.no>
  92. X      Damian Packer <Damian_Packer@MathWorks.COM>
  93. X      Richard van de Stadt <stadt@cs.utwente.nl>
  94. X
  95. X   --
  96. X
  97. X   Corrected a `segmentation violation' causing bug.
  98. X
  99. X   --
  100. X
  101. X   The AIX c compiler rejected `| =', ie it didn't like the space; thanks to:
  102. X
  103. X      pturner@amb4.ccalmr.ogi.edu (Paul J Turner)
  104. X
  105. X
  106. X-------------------------------------------------------------------------------
  107. X
  108. X
  109. X   Version 3.0 (31/3/92):
  110. X   ----------------------
  111. X
  112. X   The biggest change since version 2.0 is this:
  113. X
  114. X                *****************************************
  115. X
  116. X         xvertext now paints strings at any angle!
  117. X
  118. X                *****************************************
  119. X
  120. X   The way xvertext works now is not to bother pre-rotating a font
  121. Xbefore drawing, just draw the whole string horizontally and rotate it all
  122. Xat once. Is this good or bad news?
  123. X
  124. X    Advantages:
  125. X    -----------
  126. X       o  A single function call will rotate and paint you a string.
  127. X       o  Text looks good at any angle, particularly big fonts.
  128. X       o  Small strings are quick to draw.
  129. X
  130. X    Disadvantages:
  131. X    --------------
  132. X       o  The arguments to the remaining functions (XRotDraw.....) are
  133. X*different* to their counterparts in version 2.0. Thus code using the
  134. Xearlier version will need altering (which will probably mean deleting
  135. Xloads of stuff, and altering a fer arguments).
  136. X       o  Long strings in big fonts take a while.
  137. X       o  Speed seems more dependent now on computing power rather
  138. Xthan X server speed (the maths involved in rotating big bitmaps!)
  139. X
  140. X
  141. X
  142. X
  143. END_OF_FILE
  144.   if test 2986 -ne `wc -c <'CHANGES'`; then
  145.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  146.   fi
  147.   # end of 'CHANGES'
  148. fi
  149. if test -f 'INSTALL' -a "${1}" != "-c" ; then 
  150.   echo shar: Will not clobber existing file \"'INSTALL'\"
  151. else
  152.   echo shar: Extracting \"'INSTALL'\" \(1853 characters\)
  153.   sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
  154. X   How to compile this stuff (version 5.0)
  155. X   ---------------------------------------
  156. X
  157. X   Included in this package is an Imakefile which generates an example
  158. Xprogram and, optionally, makes and installs a linking library, header
  159. Xfile and manual pages. For those people without imake, or who can't get
  160. Xit to work, a Makefile.std is also includes.
  161. X
  162. X   To configure the package, edit `xvertext.tmpl' if you want to use imake,
  163. Xor the `Makefile.std' if not. You may which to change the cache status, and/or
  164. Xthe directories used for any installing. If you have X11R3, indicate this.
  165. X
  166. X   If you have imake, type:
  167. X
  168. X         xmkmf
  169. X         make Makefiles
  170. X
  171. X   to create the Makefiles, else
  172. X
  173. X         cp Makefile.std Makefile
  174. X
  175. X   if you haven't.
  176. X
  177. X   Typing `make example' produces the example program `example'. Run it. 
  178. XDepending on your machine you might be pleasantly :-) or unpleasantly :-(
  179. Xsurprised! (Note that if your server memory is small and limited, such as
  180. Xin an X terminal, the example program may fail with in `insufficient resources'
  181. Xerror. Try turning the cache off in this case, and destroying some other
  182. Xwindows - but not this one!)
  183. X
  184. X   Typing `make libXrot.a' (or just plain `make') calls `ar' to produce an
  185. Xarchive    file libXrot.a. Typing `make install' installs this and the header 
  186. Xfile rotated.h.
  187. X
  188. X   Typing `make install.man' installs the manual pages.
  189. X
  190. X
  191. X   Something gone wrong?
  192. X   ---------------------
  193. X
  194. X   Mail me and I'll do my best.
  195. X
  196. X
  197. X   Successful compilations
  198. X   -----------------------
  199. X
  200. X   The programs in this package have been successfully compiled and
  201. Xrun by myself on:
  202. X
  203. X   o HP 9000s300, 9000s700 and 9000s800 machines
  204. X   o Solbournes running SunOS 4.1.1
  205. X   o A Sequent Symmetry running DYNIX
  206. X
  207. X   and on many other machines by other people. Good luck with anything else :-)
  208. X
  209. X
  210. X   Alan Richardson, 26/4/93 (mppa3@uk.ac.sussex.syma)
  211. END_OF_FILE
  212.   if test 1853 -ne `wc -c <'INSTALL'`; then
  213.     echo shar: \"'INSTALL'\" unpacked with wrong size!
  214.   fi
  215.   # end of 'INSTALL'
  216. fi
  217. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  218.   echo shar: Will not clobber existing file \"'Imakefile'\"
  219. else
  220.   echo shar: Extracting \"'Imakefile'\" \(850 characters\)
  221.   sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  222. X#############################################################################
  223. X
  224. X
  225. X# Imakefile for xvertext version 5.0
  226. X
  227. X# Cache and directory options set in the file `xvertext.tmpl'
  228. X
  229. X# Nicole Seiffert <seiffert@iti.informatik.th-darmstadt.de> wrote most
  230. X#  of this - thanks!
  231. X
  232. X#############################################################################
  233. X
  234. X
  235. X#if XRelease >= 50
  236. X#include <Library.tmpl>
  237. X#endif
  238. X
  239. X#include "xvertext.tmpl"
  240. X
  241. XDEFINES = $(CACHE) $(RELEASE)
  242. X
  243. X#define IHaveSubdirs
  244. X#define PassCDebugFlags
  245. XSUBDIRS = man
  246. XMakeSubdirs($(SUBDIRS))
  247. X
  248. XNormalLibraryTarget(Xrot,rotated.o)
  249. XNormalProgramTarget(example,rotated.o example.o,,$(XLIB),-lm)
  250. X
  251. Xinstall:: rotated.h libXrot.a
  252. X    MakeDir($(THELIBDIR))
  253. X    $(INSTALL) -c $(INSTLIBFLAGS) libXrot.a $(THELIBDIR)/libXrot.a
  254. X    MakeDir($(THEINCDIR))
  255. X    $(INSTALL) -c $(INSTLIBFLAGS) rotated.h $(THEINCDIR)/rotated.h
  256. X
  257. END_OF_FILE
  258.   if test 850 -ne `wc -c <'Imakefile'`; then
  259.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  260.   fi
  261.   # end of 'Imakefile'
  262. fi
  263. if test -f 'Makefile.std' -a "${1}" != "-c" ; then 
  264.   echo shar: Will not clobber existing file \"'Makefile.std'\"
  265. else
  266.   echo shar: Extracting \"'Makefile.std'\" \(2728 characters\)
  267.   sed "s/^X//" >'Makefile.std' <<'END_OF_FILE'
  268. X#############################################################################
  269. X
  270. X
  271. X# Makefile.std for xvertext version 5.0
  272. X
  273. X
  274. X#############################################################################
  275. X
  276. X
  277. X# Cache status:
  278. X# ------------
  279. X#  Add one of `-DCACHE_XIMAGES' or `-DCACHE_BITMAPS' to decide what is
  280. X#   cached.
  281. X#
  282. X#  Add `-DCACHE_SIZE_LIMIT=xxxx' where xxxx is the cache size in kilobytes.
  283. X#   A cache size of zero turns caching off.
  284. X#
  285. X#  Add `-DCACHE_FID' if you want to cache font ID's in those instances
  286. X#   when the font name can't be determined. 
  287. X#
  288. X#  You could also add `-DDEBUG', and watch the cache in operation.
  289. X
  290. X
  291. X              CACHE = -DCACHE_BITMAPS -DCACHE_SIZE_LIMIT=300 -DCACHE_FID
  292. X
  293. X
  294. X#############################################################################
  295. X
  296. X
  297. X#  If your X11 is release 3, add -DX11R3 to this line
  298. X#    (you won't be able to use the stipple feature with rotated text)
  299. X
  300. X
  301. X                RELEASE =
  302. X
  303. X
  304. X#############################################################################
  305. X
  306. X
  307. X# This is where the library, header files and manual pages will go, if
  308. X#  you use the `install' and `install.man' options with make.
  309. X
  310. X
  311. X          THELIBDIR = ./lib
  312. X          THEINCDIR = ./include
  313. X          THEMANDIR = ./man/man3
  314. X
  315. X
  316. X#############################################################################
  317. X
  318. X
  319. X# No user serviceable parts below! 
  320. X
  321. X
  322. X#############################################################################
  323. X
  324. X
  325. X                 CC = cc
  326. X             CFLAGS = $(CACHE) $(RELEASE) 
  327. X               OBJS = rotated.o example.o
  328. X              SHELL = /bin/sh
  329. X
  330. Xall: libXrot.a
  331. X
  332. Xexample: $(OBJS) rotated.h
  333. X    $(CC) $(CFLAGS) -o example $(DEFS) $(OBJS) -lX11 -lm
  334. X
  335. XlibXrot.a: rotated.o rotated.h
  336. X    rm -f libXrot.a
  337. X    ar cq libXrot.a rotated.o 
  338. X    ranlib libXrot.a
  339. X
  340. Xinstall: libXrot.a 
  341. X    @if [ -d $(THELIBDIR) ]; then set +x; \
  342. X    else (set -x; mkdir $(THELIBDIR)); fi
  343. X    cp libXrot.a $(THELIBDIR)
  344. X    @if [ -d $(THEINCDIR) ]; then set +x; \
  345. X    else (set -x; mkdir $(THEINCDIR)); fi
  346. X    cp rotated.h $(THEINCDIR)
  347. X
  348. Xinstall.man:
  349. X    @if [ -d $(THEMANDIR) ]; then set +x; \
  350. X    else (set -x; mkdir $(THEMANDIR)); fi
  351. X    cp man/XRotDrawAlignedString.man $(THEMANDIR)/XRotDrawAlignedImageString.3
  352. X    cp man/XRotDrawAlignedString.man $(THEMANDIR)/XRotDrawAlignedString.3
  353. X    cp man/XRotDrawAlignedString.man $(THEMANDIR)/XRotDrawImageString.3
  354. X    cp man/XRotDrawAlignedString.man $(THEMANDIR)/XRotDrawString.3
  355. X    cp man/XRotVersion.man $(THEMANDIR)/XRotVersion.3
  356. X    cp man/xvertext.man $(THEMANDIR)/xvertext.3
  357. X    cp man/XRotSetMagnification.man $(THEMANDIR)/XRotSetMagnification.3
  358. X    cp man/XRotTextExtents.man $(THEMANDIR)/XRotTextExtents.3
  359. X    cp man/XRotTextExtents.man $(THEMANDIR)/XRotSetBoundingBoxPad.3
  360. X
  361. Xclean:
  362. X    rm -f $(OBJS) example example~ libXrot.a
  363. X
  364. X
  365. X
  366. END_OF_FILE
  367.   if test 2728 -ne `wc -c <'Makefile.std'`; then
  368.     echo shar: \"'Makefile.std'\" unpacked with wrong size!
  369.   fi
  370.   # end of 'Makefile.std'
  371. fi
  372. if test -f 'example.c' -a "${1}" != "-c" ; then 
  373.   echo shar: Will not clobber existing file \"'example.c'\"
  374. else
  375.   echo shar: Extracting \"'example.c'\" \(20069 characters\)
  376.   sed "s/^X//" >'example.c' <<'END_OF_FILE'
  377. X/**************************************************************************/
  378. X/*                                                                        */
  379. X/*                                                                        */
  380. X/* This is an example program designed to utilise and manipulate the      */
  381. X/* `xvertext' routines.                                                   */
  382. X/*                                                                        */
  383. X/* Version 5.0                                                            */
  384. X/*                                                                        */
  385. X/* Copyright (c) 1993 Alan Richardson (mppa3@uk.ac.sussex.syma)           */
  386. X/*                                                                        */
  387. X/*                                                                        */
  388. X/* ********************************************************************** */
  389. X
  390. X
  391. X#include <X11/Xlib.h>
  392. X#include <X11/Xutil.h>
  393. X#include <stdio.h>
  394. X#include <math.h>
  395. X#include "rotated.h"
  396. X
  397. X
  398. X/* ---------------------------------------------------------------------- */
  399. X
  400. X
  401. Xextern char *getenv();
  402. Xunsigned long AllocNamedColor();
  403. XXFontStruct *LoadFont();
  404. Xvoid Draw();
  405. Xvoid DrawRosette1();
  406. Xvoid DrawRosette2();
  407. Xvoid DrawAlignments();
  408. Xvoid DrawMagnify1();
  409. Xvoid DrawMagnify2();
  410. Xvoid DrawRansomString();
  411. Xvoid DrawRansom();
  412. X
  413. X#ifdef X11R3
  414. X#define NDEMOS 6
  415. X#else
  416. Xvoid DrawStipple1();
  417. Xvoid DrawStipple2();
  418. X#define NDEMOS 8
  419. X#endif /*X11R3*/
  420. X
  421. X
  422. X/* ---------------------------------------------------------------------- */
  423. X
  424. X
  425. XGC gc;
  426. XDisplay *dpy;
  427. XWindow window;
  428. Xint depth, screen;
  429. Xunsigned long white, black;
  430. X
  431. X#define NCOLORS 9
  432. X
  433. Xchar *colors[]={
  434. X    "white", "red", "orange", "yellow", "green", "cyan",
  435. X    "gold", "pink", "wheat"
  436. X};
  437. X
  438. Xunsigned long pixels[NCOLORS];
  439. X
  440. X
  441. X/* ---------------------------------------------------------------------- */
  442. X
  443. X
  444. X/**************************************************************************/
  445. X/*  Allocate a colour from the default colour map                         */
  446. X/**************************************************************************/
  447. X
  448. Xunsigned long AllocNamedColor(colname)  
  449. X    char *colname;    
  450. X{
  451. X    XColor scrncol, excol;
  452. X    
  453. X    if(depth==1)
  454. X    return white;
  455. X    
  456. X    if(XAllocNamedColor(dpy, DefaultColormap(dpy, screen), colname,
  457. X            &scrncol, &excol))
  458. X    return scrncol.pixel;
  459. X    
  460. X    else
  461. X    return white;
  462. X}
  463. X
  464. X
  465. X/* ---------------------------------------------------------------------- */
  466. X
  467. X
  468. X/**************************************************************************/
  469. X/*  Load a named font, or `fixed' if it isn't there                       */
  470. X/**************************************************************************/
  471. X
  472. XXFontStruct *LoadFont(fontname)
  473. X    char *fontname;
  474. X{
  475. X    XFontStruct *font;
  476. X
  477. X    font=XLoadQueryFont(dpy, fontname);
  478. X    if(!font) {
  479. X    fprintf(stderr, "no font `%s'\n", fontname);
  480. X    font=XLoadQueryFont(dpy, "fixed");
  481. X    }
  482. X
  483. X    return font;
  484. X}
  485. X
  486. X
  487. X/* ---------------------------------------------------------------------- */
  488. X
  489. X
  490. X/**************************************************************************/
  491. X/*  Main routine                                                          */
  492. X/**************************************************************************/
  493. X
  494. Xmain()
  495. X{
  496. X    XEvent ev;
  497. X    char *host;
  498. X    char buf[1];
  499. X    int mode=0, i;
  500. X    float version;
  501. X    char copyright[100];
  502. X    
  503. X    /* get copyright information */
  504. X    version=XRotVersion(copyright, 100);
  505. X    printf("%s - version %.1f\n", copyright, version);
  506. X    
  507. X    /* establish connection to display */
  508. X    if((host=getenv("DISPLAY"))==NULL) {
  509. X    fprintf(stderr,"can't connect to host\n");
  510. X    exit(1); 
  511. X    }
  512. X    
  513. X    /* open connection to display */
  514. X    if((dpy=XOpenDisplay(host))==NULL) {
  515. X    fprintf(stderr,"can't open display\n");
  516. X    exit(1); 
  517. X    }
  518. X    
  519. X    /* useful macros */
  520. X    screen=DefaultScreen(dpy);
  521. X    depth=DefaultDepth(dpy, screen);
  522. X    
  523. X    /* load the colors */
  524. X    white=WhitePixel(dpy, screen);
  525. X    black=BlackPixel(dpy, screen);
  526. X
  527. X    for(i=0; i<NCOLORS; i++) 
  528. X    pixels[i]=AllocNamedColor(colors[i]);
  529. X
  530. X    /* create a window */
  531. X    window=XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 600, 600,
  532. X             0, depth, InputOutput, DefaultVisual(dpy, screen),
  533. X             0, NULL);
  534. X    
  535. X    XSelectInput(dpy, window, ExposureMask|KeyPressMask);
  536. X    XSetWindowBackground(dpy, window, black);
  537. X    XMapWindow(dpy, window);
  538. X    
  539. X    /* create a GC */
  540. X    gc=XCreateGC(dpy, window, NULL, 0);
  541. X
  542. X    /* simple event loop */
  543. X    for(;;) {
  544. X    XNextEvent(dpy, &ev);
  545. X    
  546. X    /* process each event */
  547. X    switch(ev.type) {
  548. X      case Expose:
  549. X        if(ev.xexpose.count==0) 
  550. X        Draw(mode);
  551. X        break;
  552. X        
  553. X      case KeyPress: 
  554. X        XLookupString(&ev.xkey, buf, 1, NULL, NULL);
  555. X
  556. X        if(buf[0]=='q') 
  557. X        exit(0);
  558. X        else {
  559. X        mode=(++mode)%NDEMOS;
  560. X        Draw(mode);
  561. X        }
  562. X        break;
  563. X    }
  564. X    }
  565. X}
  566. X
  567. X
  568. X/* ---------------------------------------------------------------------- */
  569. X
  570. X
  571. X/**************************************************************************/
  572. X/*   Choose which pic to draw                                             */
  573. X/**************************************************************************/
  574. X
  575. Xvoid Draw(mode)
  576. X    int mode;
  577. X{
  578. X    XClearWindow(dpy, window);
  579. X
  580. X    if(mode==0)
  581. X    DrawRosette1();
  582. X    else if(mode==1)
  583. X    DrawRosette2();
  584. X    else if(mode==2)
  585. X    DrawAlignments();
  586. X    else if(mode==3)
  587. X    DrawMagnify1();
  588. X    else if(mode==4)
  589. X    DrawMagnify2();
  590. X    else if(mode==5)
  591. X    DrawRansom();
  592. X#ifndef X11R3
  593. X    else if(mode==6)
  594. X    DrawStipple1();
  595. X    else
  596. X    DrawStipple2();
  597. X#endif /*X11R3*/
  598. X}
  599. X
  600. X
  601. X/* ---------------------------------------------------------------------- */
  602. X
  603. X
  604. X/**************************************************************************/
  605. X/*  Draw an `Adobe PostScript'-style word rosette                         */
  606. X/**************************************************************************/
  607. X
  608. Xvoid DrawRosette1()
  609. X{
  610. X    int i;
  611. X    char *fontname=
  612. X    "-adobe-helvetica-medium-o-normal--24-240-75-75-p-130-iso8859-1";
  613. X    static XFontStruct *font=NULL;
  614. X
  615. X    /* load font */
  616. X    if(!font) 
  617. X    font=LoadFont(fontname);
  618. X    
  619. X    /* loop through each angle */
  620. X    for(i=0; i<16; i++) {
  621. X    XSetForeground(dpy, gc, pixels[i%NCOLORS]);
  622. X    XRotDrawAlignedString(dpy, font, (float)(360*i/16), window, 
  623. X                  gc, 300, 270, 
  624. X                  "Just like PostScript?",
  625. X                  MLEFT);
  626. X    }    
  627. X
  628. X    XSetForeground(dpy, gc, white);
  629. X    XRotDrawAlignedString(dpy, font, 0., window, gc, 300, 590,
  630. X                   "Press any key to continue...", BCENTRE);
  631. X}
  632. X
  633. X
  634. X/* ---------------------------------------------------------------------- */
  635. X
  636. X
  637. X/**************************************************************************/
  638. X/*  Draw several rosettes (to show the benefits of caching!)              */
  639. X/**************************************************************************/
  640. X
  641. Xvoid DrawRosette2()
  642. X{
  643. X    int i, j;
  644. X    char *fontname=
  645. X    "-adobe-times-bold-r-normal--18-180-75-75-p-99-iso8859-1";
  646. X    static XFontStruct *font=NULL;
  647. X
  648. X    /* load font */
  649. X    if(!font)
  650. X        font=LoadFont(fontname);
  651. X    
  652. X    /* loop through each rosette */
  653. X    for(j=0; j<4; j++) {
  654. X    /* loop through each angle */
  655. X    for(i=0; i<16; i++) {
  656. X        XSetForeground(dpy, gc, pixels[i%NCOLORS]);
  657. X        XRotDrawAlignedString(dpy, font, (float)(360*i/16), window, 
  658. X                  gc, 150+300*(j/2), 150+300*(j%2),
  659. X                  "- - ABCDEfghij",
  660. X                  MLEFT);
  661. X    }    
  662. X    }
  663. X
  664. X    XSetForeground(dpy, gc, white);
  665. X    XRotDrawAlignedString(dpy, font, 0., window, gc, 300, 300,
  666. X              "Press any key to continue...", MCENTRE);
  667. X}
  668. X
  669. X
  670. X/* ---------------------------------------------------------------------- */
  671. X
  672. X
  673. X/**************************************************************************/
  674. X/*  Demonstrate alignment of blocks of text                               */
  675. X/**************************************************************************/
  676. X
  677. Xvoid DrawAlignments()
  678. X{
  679. X    int i;
  680. X    int x, y;
  681. X    char *fontname=
  682. X        "-adobe-times-bold-r-normal--18-180-75-75-p-99-iso8859-1";
  683. X    static XFontStruct *font=NULL;
  684. X
  685. X    static int align[3]={
  686. X    BRIGHT, MCENTRE, TLEFT
  687. X    };
  688. X
  689. X    /* load font */
  690. X    if(!font)
  691. X        font=LoadFont(fontname);
  692. X
  693. X    if(depth==1)
  694. X        XSetBackground(dpy, gc, black);
  695. X    else
  696. X        XSetBackground(dpy, gc, pixels[1]);
  697. X
  698. X    /* loop through nine positions */
  699. X    for(i=0; i<9; i++) {
  700. X    /* position */
  701. X    x=(i%3)*200+100;
  702. X    y=(i/3)*200+100;
  703. X    
  704. X    /* draw some crosshairs */
  705. X    XSetForeground(dpy, gc, pixels[3]);
  706. X    XDrawLine(dpy, window, gc, x-30, y, x+30, y);
  707. X    XDrawLine(dpy, window, gc, x, y+30, x, y-30);
  708. X
  709. X    /* draw the text */
  710. X    XSetForeground(dpy, gc, pixels[5]);
  711. X    XRotDrawAlignedImageString(dpy, font, 120.*(float)(i/3),
  712. X                   window, gc, x, y, 
  713. X                   "Many\nalignments\nare\npossible",
  714. X                   align[i%3]);
  715. X    }
  716. X
  717. X    XSetForeground(dpy, gc, white);
  718. X    XRotDrawAlignedString(dpy, font, 0., window, gc, 300, 590,
  719. X                   "Press any key to continue...",BCENTRE);
  720. X}
  721. X
  722. X
  723. X/* ---------------------------------------------------------------------- */
  724. X
  725. X
  726. X/**************************************************************************/
  727. X/*  Show that some fonts don't look too bad when magnified                */
  728. X/**************************************************************************/
  729. X
  730. Xvoid DrawMagnify1()
  731. X{
  732. X    int i, y=90;
  733. X    XPoint *xp;
  734. X    char *str1="Fonts can be magnified,\nthey might not look TOO bad...";
  735. X    char *str2="Size of an elephant";
  736. X    char *fontname=
  737. X    "-adobe-times-bold-i-normal--24-240-75-75-p-128-iso8859-1";
  738. X    static XFontStruct *font=NULL;
  739. X
  740. X    /* load font */
  741. X    if(!font) 
  742. X        font=LoadFont(fontname);
  743. X    
  744. X    /* draw top string */
  745. X    XSetForeground(dpy, gc, white);
  746. X    XRotDrawAlignedString(dpy, font, 0., window, gc, 300, 3,
  747. X              str1, TCENTRE);
  748. X
  749. X    /* draw its bounding box */
  750. X    XRotSetBoundingBoxPad(2);
  751. X    xp=XRotTextExtents(dpy, font, 0., 300, 3, str1, TCENTRE);
  752. X    if(xp) {
  753. X    XDrawLines(dpy, window, gc, xp, 5, CoordModeOrigin);
  754. X    free((char *)xp);
  755. X    }
  756. X
  757. X    /* loop through ten magnifications */
  758. X    for(i=0; i<10; i++) {
  759. X    XRotSetMagnification((float)i/7.+1.);
  760. X
  761. X    XSetForeground(dpy, gc, pixels[i%NCOLORS]);
  762. X    XRotDrawAlignedString(dpy, font, 0., window, gc,
  763. X                  300, y, str2, MCENTRE);
  764. X
  765. X    y+=30.*((float)i/7.+1.);
  766. X    }    
  767. X
  768. X    /* reset */
  769. X    XRotSetMagnification(1.);
  770. X
  771. X    XSetForeground(dpy, gc, white);
  772. X    XRotDrawAlignedString(dpy, font, 0., window, gc, 300, 590,
  773. X                   "Press any key to continue...", BCENTRE);
  774. X}
  775. X
  776. X
  777. X/* ---------------------------------------------------------------------- */
  778. X
  779. X
  780. X/**************************************************************************/
  781. X/*  Demo of font magnifying at an angle                                   */
  782. X/**************************************************************************/
  783. X
  784. Xvoid DrawMagnify2()
  785. X{
  786. X    int i, d=0;
  787. X    char *str1="Text leaps out";
  788. X    char *fontname=
  789. X        "-adobe-times-bold-r-normal--18-180-75-75-p-99-iso8859-1";
  790. X    static XFontStruct *font=NULL;
  791. X
  792. X    /* load font */
  793. X    if(!font)
  794. X        font=LoadFont(fontname);
  795. X
  796. X    /* loop through ten magnifications */
  797. X    for(i=0; i<10; i++) {
  798. X    /* set magnification */
  799. X    XRotSetMagnification((float)i/5.+1.);
  800. X
  801. X    /* random colour */
  802. X    XSetForeground(dpy, gc, pixels[i%NCOLORS]);
  803. X
  804. X    /* draw strings */
  805. X    XRotDrawAlignedString(dpy, font, 0., window, gc,
  806. X                  300, 20+d, str1, MCENTRE);
  807. X
  808. X    XRotDrawAlignedString(dpy, font, 90., window, gc,
  809. X                  20+d, 300, str1, MCENTRE);
  810. X
  811. X    XRotDrawAlignedString(dpy, font, 180., window, gc,
  812. X                  300, 580-d, str1, MCENTRE);
  813. X
  814. X    XRotDrawAlignedString(dpy, font, -90., window, gc,
  815. X                  580-d, 300, str1, MCENTRE);
  816. X
  817. X    /* increase offset */
  818. X    d+=10;
  819. X    }    
  820. X
  821. X    /* reset */
  822. X    XRotSetMagnification(1.);
  823. X
  824. X    XSetForeground(dpy, gc, white);
  825. X    XRotDrawAlignedString(dpy, font, 0., window, gc, 300, 300,
  826. X                   "Press any\nkey to continue...", MCENTRE);
  827. X}
  828. X
  829. X
  830. X/* ---------------------------------------------------------------------- */
  831. X
  832. X
  833. X/**************************************************************************/
  834. X/*  Draw a ransom note                                                    */
  835. X/**************************************************************************/
  836. X
  837. Xvoid DrawRansom()
  838. X{
  839. X    /* if we don't seed random generator here, redraws will be drawn in new
  840. X       random fashion and so won't use the cache */
  841. X
  842. X    srand(1);
  843. X
  844. X    DrawRansomString("Cops-", 20, 70, 1.);
  845. X    DrawRansomString("This is an example", 20, 150, 1.);
  846. X    DrawRansomString("of manipulating", 20, 230, 1.);
  847. X    DrawRansomString("bounding boxes &", 20, 310, 1.);
  848. X    DrawRansomString("magnification...", 20, 390, 1.);
  849. X    DrawRansomString("Scorpio", 450, 470, 0.5);
  850. X    DrawRansomString("Press any key to continue", 10, 570, 0.5);
  851. X}
  852. X
  853. X
  854. X/* ---------------------------------------------------------------------- */
  855. X
  856. X
  857. X/**************************************************************************/
  858. X/*  Draw a string in `ransom note' fashion -                              */
  859. X/*      inspired by `ransom.ps' released to comp.sources.postscript       */
  860. X/**************************************************************************/
  861. X
  862. Xvoid DrawRansomString(str, x, y, overall_factor)
  863. X    char *str;
  864. X    int x, y;
  865. X    float overall_factor;
  866. X{
  867. X    int i;
  868. X    XPoint *xp;
  869. X    float angle;
  870. X    int x2, y2;
  871. X    int font_num;
  872. X    float magnify;
  873. X    static char letter[2]={' ', '\0'};
  874. X    static char *fontnames[]={
  875. X    "-adobe-courier-bold-o-normal--24-240-75-75-m-150-iso8859-1",
  876. X    "-adobe-courier-bold-r-normal--24-240-75-75-m-150-iso8859-1",
  877. X    "-adobe-helvetica-bold-r-normal--24-240-75-75-p-138-iso8859-1",
  878. X    "-adobe-helvetica-bold-o-normal--24-240-75-75-p-138-iso8859-1",
  879. X    "-adobe-times-bold-i-normal--24-240-75-75-p-128-iso8859-1",
  880. X    "-adobe-times-bold-r-normal--24-240-75-75-p-132-iso8859-1"
  881. X    };
  882. X    static XFontStruct *font[6]={NULL, NULL, NULL, NULL, NULL};
  883. X
  884. X    /* load fonts if not already loaded */
  885. X    if(!font[0]) 
  886. X    for(i=0; i<6; i++) 
  887. X        font[i]=LoadFont(fontnames[i]);
  888. X
  889. X    /* take each letter in turn */
  890. X    for(i=0; i<strlen(str); i++) {
  891. X    letter[0]=str[i];
  892. X
  893. X    /* calculate random angle, offset, font */
  894. X    angle=(3.-(float)(rand()%6))*5;
  895. X    x2=x+rand()%6;
  896. X    y2=y+5-rand()%10;
  897. X    font_num=rand()%6;
  898. X
  899. X    /* maybe change from upper case to lower case */
  900. X    if(letter[0]>='A' && letter[0]<='Z') {
  901. X        if(rand()%1000>500)
  902. X        letter[0]+='a'-'A';
  903. X    }
  904. X    else if(letter[0]>='a' && letter[0]<='z') {
  905. X        if(rand()%1000>500)
  906. X        letter[0]-='a'-'A';
  907. X    }
  908. X        
  909. X    /* any letter that's not a space */
  910. X    if(letter[0]!=' ') {
  911. X        /* random magnification above biggest bitmap font available */
  912. X        magnify=((float)(rand()%100)/200.+1.2)*overall_factor;
  913. X        XRotSetMagnification(magnify);
  914. X
  915. X        /* random bounding box padding */
  916. X        XRotSetBoundingBoxPad(rand()%3+2);
  917. X
  918. X        /* get bounding box */
  919. X        xp=XRotTextExtents(dpy, font[font_num], angle, x2, y2, 
  920. X                   letter, NONE);
  921. X
  922. X        /* if bounding box was obtained */
  923. X        if(xp) {
  924. X        /* blank out box */
  925. X        XSetForeground(dpy, gc, black);
  926. X        XFillPolygon(dpy, window, gc, xp, 5, Convex, CoordModeOrigin);
  927. X
  928. X        /* draw box */
  929. X        XSetForeground(dpy, gc, white);
  930. X        XDrawLines(dpy, window, gc, xp, 5, CoordModeOrigin);
  931. X
  932. X        /* free points */
  933. X        free((char *)xp);
  934. X        }
  935. X
  936. X        /* random colour */
  937. X        XSetForeground(dpy, gc, pixels[rand()%NCOLORS]);
  938. X
  939. X        /* draw the letter */
  940. X        XRotDrawString(dpy, font[font_num], angle, window, gc,
  941. X               x2, y2, letter);
  942. X
  943. X        /* advance a bit */
  944. X        x+=(float)XTextWidth(font[font_num], letter, 1)*magnify+10;
  945. X    }
  946. X    else 
  947. X        /* advance for a space */
  948. X        x+=42.*overall_factor;
  949. X    }
  950. X
  951. X    /* reset */
  952. X    XRotSetMagnification(1.);
  953. X}
  954. X
  955. X
  956. X
  957. X/* ---------------------------------------------------------------------- */
  958. X
  959. X
  960. X/**************************************************************************/
  961. X/*  Demonstrate the use of stipples                                       */
  962. X/**************************************************************************/
  963. X
  964. X/* stipples only available R4+ (XGetGCValues not in R3) */
  965. X
  966. X#ifndef X11R3
  967. X
  968. Xvoid DrawStipple1()
  969. X{
  970. X    int i;
  971. X    GC gc1;
  972. X    Pixmap stipple;
  973. X    XPoint *xp;
  974. X    int size=70, radius=50;
  975. X    char *fontname1=
  976. X    "-adobe-times-bold-r-normal--10-100-75-75-p-57-iso8859-1";
  977. X    char *fontname2=
  978. X    "-adobe-helvetica-bold-o-normal--18-180-75-75-p-104-iso8859-1";
  979. X    static XFontStruct *font1=NULL, *font2=NULL;
  980. X    char *str1="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\
  981. XABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
  982. X    char *str2="This is done using stipples.\n\nPress any key to continue ...";
  983. X
  984. X    /* load fonts */
  985. X    if(!font1) {
  986. X    font1=LoadFont(fontname1);
  987. X    font2=LoadFont(fontname2);
  988. X    }
  989. X    
  990. X    /* create a stipple and depth one GC */
  991. X    stipple=XCreatePixmap(dpy, window, size, size, 1);
  992. X    gc1=XCreateGC(dpy, stipple, NULL, 0);
  993. X
  994. X    /* clear the stipple */
  995. X    XSetForeground(dpy, gc1, 0);
  996. X    XFillRectangle(dpy, stipple, gc1, 0, 0, size, size);
  997. X
  998. X    /* the stipple is just a circle */
  999. X    XSetForeground(dpy, gc1, 1);
  1000. X    XFillArc(dpy, stipple, gc1, (size-radius)/2, (size-radius)/2,
  1001. X         radius, radius, 0, 64*360);
  1002. X
  1003. X    /* there's a circle at the centre of the window */
  1004. X    XSetTSOrigin(dpy, gc, 300-size/2, 300-size/2);
  1005. X
  1006. X    /* stipple is passed in through GC */
  1007. X    XSetFillStyle(dpy, gc, FillStippled);
  1008. X    XSetStipple(dpy, gc, stipple);
  1009. X
  1010. X    /* draw loads of strings */
  1011. X    for(i=0; i<50; i++) {
  1012. X    XSetForeground(dpy, gc, pixels[(i*2)%NCOLORS]);
  1013. X    XRotDrawString(dpy, font1, -90. , window, gc, i*12, 0, str1);
  1014. X    }
  1015. X
  1016. X    /* reset */
  1017. X    XSetFillStyle(dpy, gc, FillSolid);
  1018. X
  1019. X    /* free resources */
  1020. X    XFreePixmap(dpy, stipple);
  1021. X    XFreeGC(dpy, gc1);
  1022. X
  1023. X    /* draw `press any key' bounding box */
  1024. X    XRotSetBoundingBoxPad(10);
  1025. X    xp=XRotTextExtents(dpy, font2, 0., 300, 500, str2, BCENTRE);
  1026. X    if(xp) {
  1027. X    XSetForeground(dpy, gc, black);
  1028. X    XFillPolygon(dpy, window, gc, xp, 5, Convex, CoordModeOrigin);
  1029. X    XSetForeground(dpy, gc, white);
  1030. X        XDrawLines(dpy, window, gc, xp, 5, CoordModeOrigin);
  1031. X        free((char *)xp);
  1032. X    }
  1033. X
  1034. X    XSetForeground(dpy, gc, white);
  1035. X    XRotDrawAlignedString(dpy, font2, 0., window, gc, 300, 500,
  1036. X                               str2, BCENTRE);
  1037. X}
  1038. X
  1039. X#endif /*X11R3*/
  1040. X
  1041. X
  1042. X
  1043. X/* ---------------------------------------------------------------------- */
  1044. X
  1045. X
  1046. X/**************************************************************************/
  1047. X/*  Use magnified letters as a stipple                                    */
  1048. X/**************************************************************************/
  1049. X
  1050. X/* stipples only available R4+ (XGetGCValues not in R3) */
  1051. X
  1052. X#ifndef X11R3
  1053. X
  1054. Xvoid DrawStipple2()
  1055. X{
  1056. X    int i;
  1057. X    GC gc1;
  1058. X    Pixmap stipple;
  1059. X    char *fontname=
  1060. X    "-adobe-courier-bold-r-normal--24-240-75-75-m-150-iso8859-1";
  1061. X    static XFontStruct *font=NULL;
  1062. X    char *str="abcabcabcabcabcabcabcabcabcabcabcabcabcabc";
  1063. X
  1064. X    /* load fonts */
  1065. X    if(!font) 
  1066. X    font=LoadFont(fontname);
  1067. X    
  1068. X    /* the user won't be able to see anything happening! */
  1069. X    XSetForeground(dpy, gc, white);
  1070. X    XRotDrawAlignedString(dpy, font, 0., window, gc, 300, 300,
  1071. X              "Please wait a second or two...", MCENTRE);
  1072. X    XFlush(dpy);
  1073. X
  1074. X    /* create a stipple and depth one GC */
  1075. X    stipple=XCreatePixmap(dpy, window, 600, 600, 1);
  1076. X    gc1=XCreateGC(dpy, stipple, NULL, 0);
  1077. X
  1078. X    /* clear the stipple */
  1079. X    XSetForeground(dpy, gc1, 0);
  1080. X    XFillRectangle(dpy, stipple, gc1, 0, 0, 600, 600);
  1081. X
  1082. X    /* paint a big `abc' on the stipple */
  1083. X    XSetForeground(dpy, gc1, 1);
  1084. X    XRotSetMagnification(12.);
  1085. X    XRotDrawAlignedString(dpy, font, 0., stipple, gc1,
  1086. X              300, 300, "abc", MCENTRE);
  1087. X    XRotSetMagnification(1.);
  1088. X
  1089. X    /* stipple is as big as window */
  1090. X    XSetTSOrigin(dpy, gc, 0, 0);
  1091. X
  1092. X    /* stipple is passed in through GC */
  1093. X    XSetFillStyle(dpy, gc, FillStippled);
  1094. X    XSetStipple(dpy, gc, stipple);
  1095. X    XSetForeground(dpy, gc, pixels[3]);
  1096. X    
  1097. X    XClearWindow(dpy, window);
  1098. X
  1099. X    /* draw loads of small `abc's */
  1100. X    for(i=0; i<16; i++) 
  1101. X        XRotDrawString(dpy, font, 0. , window, gc, 0, 180+i*15, str);
  1102. X
  1103. X    /* reset */
  1104. X    XSetFillStyle(dpy, gc, FillSolid);
  1105. X
  1106. X    /* free resources */
  1107. X    XFreePixmap(dpy, stipple);
  1108. X    XFreeGC(dpy, gc1);
  1109. X
  1110. X    XSetForeground(dpy, gc, white);
  1111. X    XRotDrawAlignedString(dpy, font, 0., window, gc, 300, 590,
  1112. X                               "Press any key to continue...", BCENTRE);
  1113. X}
  1114. X
  1115. X#endif /*X11R3*/
  1116. X
  1117. X
  1118. END_OF_FILE
  1119.   if test 20069 -ne `wc -c <'example.c'`; then
  1120.     echo shar: \"'example.c'\" unpacked with wrong size!
  1121.   fi
  1122.   # end of 'example.c'
  1123. fi
  1124. if test -f 'man/Imakefile' -a "${1}" != "-c" ; then 
  1125.   echo shar: Will not clobber existing file \"'man/Imakefile'\"
  1126. else
  1127.   echo shar: Extracting \"'man/Imakefile'\" \(562 characters\)
  1128.   sed "s/^X//" >'man/Imakefile' <<'END_OF_FILE'
  1129. X#############################################################################
  1130. X
  1131. X
  1132. X# man page-installing Imakefile for xvertext version 5.0
  1133. X
  1134. X
  1135. X#############################################################################
  1136. X
  1137. X
  1138. X#if XRelease >= 50
  1139. X#include <Library.tmpl>
  1140. X#endif
  1141. X
  1142. X#include "../xvertext.tmpl"
  1143. X
  1144. XMANSUFFIX = $(LIBMANSUFFIX)
  1145. X
  1146. Xall::
  1147. X
  1148. XInstallManPage(XRotDrawAlignedString,$(THEMANDIR))
  1149. XInstallManPage(XRotVersion,$(THEMANDIR))
  1150. XInstallManPage(xvertext,$(THEMANDIR))
  1151. XInstallManPage(XRotSetMagnification,$(THEMANDIR))
  1152. XInstallManPage(XRotTextExtents,$(THEMANDIR))
  1153. X
  1154. X
  1155. END_OF_FILE
  1156.   if test 562 -ne `wc -c <'man/Imakefile'`; then
  1157.     echo shar: \"'man/Imakefile'\" unpacked with wrong size!
  1158.   fi
  1159.   # end of 'man/Imakefile'
  1160. fi
  1161. if test -f 'man/XRotDrawAlignedString.man' -a "${1}" != "-c" ; then 
  1162.   echo shar: Will not clobber existing file \"'man/XRotDrawAlignedString.man'\"
  1163. else
  1164.   echo shar: Extracting \"'man/XRotDrawAlignedString.man'\" \(4832 characters\)
  1165.   sed "s/^X//" >'man/XRotDrawAlignedString.man' <<'END_OF_FILE'
  1166. X.\" @(#)XRotDrawAlignedString 5.0 18/4/93; Copyright (c) 1993 Alan Richardson
  1167. X.TH XRotDrawAlignedString 3 "18 Apr 1993" "xvertext routines"
  1168. X.SH NAME
  1169. XXRotDrawString, XRotDrawImageString,
  1170. XXRotDrawAlignedString, XRotDrawAlignedImageString \- draw strings 
  1171. Xat any angle
  1172. X.SH SYNOPSIS
  1173. X.B int XRotDrawString(dpy, font, angle, drawable,
  1174. X.B gc, x, y, text)
  1175. X.br
  1176. X.B Display *dpy;
  1177. X.br
  1178. X.B XFontStruct *font;
  1179. X.br
  1180. X.B float angle;
  1181. X.br
  1182. X.B Drawable drawable;
  1183. X.br
  1184. X.B GC gc;
  1185. X.br
  1186. X.B int x, y;
  1187. X.br
  1188. X.B char *text;
  1189. X.PP
  1190. X.B int XRotDrawImageString(dpy, font, angle, drawable,
  1191. X.B gc, x, y, text)
  1192. X.br
  1193. X.B Display *dpy;
  1194. X.br
  1195. X.B XFontStruct *font;
  1196. X.br
  1197. X.B float angle;
  1198. X.br
  1199. X.B Drawable drawable;
  1200. X.br
  1201. X.B GC gc;
  1202. X.br
  1203. X.B int x, y;
  1204. X.br
  1205. X.B char *text;
  1206. X.PP
  1207. X.B int XRotDrawAlignedString(dpy, font, angle, drawable,
  1208. X.B gc, x, y, text, align)
  1209. X.br
  1210. X.B Display *dpy;
  1211. X.br
  1212. X.B XFontStruct *font;
  1213. X.br
  1214. X.B float angle;
  1215. X.br
  1216. X.B Drawable drawable;
  1217. X.br
  1218. X.B GC gc;
  1219. X.br
  1220. X.B int x, y;
  1221. X.br
  1222. X.B char *text;
  1223. X.br
  1224. X.B int align;
  1225. X.PP
  1226. X.B int XRotDrawAlignedImageString(dpy, font, angle, drawable,
  1227. X.B gc, x, y, text, align)
  1228. X.br
  1229. X.B Display *dpy;
  1230. X.br
  1231. X.B XFontStruct *font;
  1232. X.br
  1233. X.B float angle;
  1234. X.br
  1235. X.B Drawable drawable;
  1236. X.br
  1237. X.B GC gc;
  1238. X.br
  1239. X.B int x, y;
  1240. X.br
  1241. X.B char *text;
  1242. X.br
  1243. X.B int align;
  1244. X.SH ARGUMENTS
  1245. X.IP \fIdisplay\fP 1i     
  1246. XSpecifies the connection to the X server.
  1247. X.IP \fIfont\fP 1i
  1248. XPointer to an XFontStruct structure.
  1249. X.IP \fIangle\fP 1i
  1250. XAngle in degrees between direction of text and horizontal
  1251. X(anticlockwise is positive).
  1252. X.IP \fIdrawable\fP 1i
  1253. XThe window or pixmap in which to paint the text.
  1254. X.IP \fIgc\fP 1i
  1255. XThe graphics context to use when painting text.
  1256. X.IP \fIx\,\ y\fP 1i
  1257. XCoordinates whose relation to the position of the painted text is given
  1258. Xby \fIalign\fP.
  1259. X.IP \fItext\fP 1i
  1260. XA character string.
  1261. X.IP \fIalign\fP 1i
  1262. XDescribes the alignment with which to draw the string.
  1263. X.SH DESCRIPTION
  1264. X.PP
  1265. XThese four functions are used to draw text at any angle in an X window
  1266. Xor pixmap. 
  1267. XAll four have several arguments in common. In particular, 
  1268. X.I font
  1269. Xis an XFontStruct structure describing which font to use.
  1270. XThe foreground and background colours and plane depth of
  1271. X.I gc
  1272. Xare used in all four functions. The stipple bitmap and stipple origin
  1273. Xof
  1274. X.I gc
  1275. Xare used in the none-`Image' functions (not X11R3), providing the
  1276. Xfill style is FillStippled or FillOpaqueStippled.
  1277. XThe coordinate pair
  1278. X.I (x\,\ y)
  1279. Xdescribes the location to place the string on the
  1280. Xdrawable - exactly what `location' means depends on the function
  1281. Xcalled.
  1282. X.PP
  1283. XThe two functions
  1284. X.I XRotDrawString
  1285. Xand
  1286. X.I XRotDrawImageString
  1287. Xpaint a string such that the specified point
  1288. X.I (x\,\ y)
  1289. Xcoincides with the origin of the first character in the string,
  1290. Xafter rotation.
  1291. XNo interpretation is placed on newline characters appearing in the
  1292. Xstring.
  1293. X.PP
  1294. XThe
  1295. X.I XRotDrawAlignedString
  1296. Xand
  1297. X.I XRotDrawAlignedImageString
  1298. Xfunctions interpret newline characters in the string as delimiters of
  1299. Xsmaller strings to appear on seperate lines. These seperate
  1300. Xstrings are aligned with respect to one another according to the value
  1301. Xof
  1302. X.I align,
  1303. Xwhich can take the values
  1304. X.I TLEFT, TCENTRE, TRIGHT, MLEFT, MCENTRE, MRIGHT,
  1305. X.I BLEFT, BCENTRE, BRIGHT.
  1306. XAlignment is done before rotation.
  1307. XThe first character corresponds to the position of the block of text
  1308. Xrelative to
  1309. X.I (x\,\ y):
  1310. X.I T
  1311. Xplaces the top of the block at 
  1312. X.I y,
  1313. X.I M
  1314. Xplaces the middle of the block there and
  1315. X.I B
  1316. Xthe bottom. The remaining word indicates horizontal alignment:
  1317. X.I LEFT
  1318. Xplaces the left of the block at
  1319. X.I x,
  1320. Xand so on.
  1321. XRotation of the whole block is then performed around
  1322. X.I (x\,\ y).
  1323. X.PP
  1324. XThe two functions with `Image' in their names fill in the
  1325. Xtext background with the background colour of
  1326. X.I gc
  1327. Xbefore painting the text. The remaining two functions leave
  1328. Xthe background untouched.
  1329. X.SH ALIGNMENT EXAMPLE
  1330. XSuppose the string "This\\nis\\nno\\nordinary\\ntest" were passed to
  1331. X.I XRotDrawAlignedString()
  1332. Xwith an alignment of
  1333. X.I MLEFT
  1334. Xand no rotation;
  1335. Xthe result would be:
  1336. X.PP
  1337. X                              |This
  1338. X                              |is
  1339. X                     ---------+no-------
  1340. X                              |ordinary
  1341. X                              |test
  1342. X.PP
  1343. Xwhere the cross hairs indicate the position of
  1344. X.I (x\,\ y).
  1345. XAlignments of MCENTER and MRIGHT would result in:
  1346. X.PP
  1347. X                 |                                   |
  1348. X                This                         This    |
  1349. X                 is                          is      |
  1350. X         --------no--------                 -no------+---------
  1351. X              ordinary                       ordinary|
  1352. X                test                         test    |
  1353. X                 |                                   |
  1354. X
  1355. X.SH RETURN VALUE
  1356. XAll four functions return 0 on success, 1 on failure. Failure is
  1357. Xprobably due to an unsuccessful call to malloc().
  1358. X.SH SEE ALSO
  1359. Xxvertext,
  1360. XXRotSetMagnification,
  1361. XXRotSetBoundingBoxPad,
  1362. XXRotTextExtents.
  1363. END_OF_FILE
  1364.   if test 4832 -ne `wc -c <'man/XRotDrawAlignedString.man'`; then
  1365.     echo shar: \"'man/XRotDrawAlignedString.man'\" unpacked with wrong size!
  1366.   fi
  1367.   # end of 'man/XRotDrawAlignedString.man'
  1368. fi
  1369. if test -f 'man/XRotSetMagnification.man' -a "${1}" != "-c" ; then 
  1370.   echo shar: Will not clobber existing file \"'man/XRotSetMagnification.man'\"
  1371. else
  1372.   echo shar: Extracting \"'man/XRotSetMagnification.man'\" \(1328 characters\)
  1373.   sed "s/^X//" >'man/XRotSetMagnification.man' <<'END_OF_FILE'
  1374. X.\" @(#)XRotSetMagnification 5.0 25/4/93; Copyright (c) 1993 Alan Richardson
  1375. X.TH XRotSetMagnification 3 "25 Apr 1993" "xvertext routines"
  1376. X.SH NAME
  1377. XXRotSetMagnification \- set font magnification factor
  1378. X.SH SYNOPSIS
  1379. X.B void XRotSetMagnification(m)
  1380. X.br
  1381. X.B float m;
  1382. X.SH ARGUMENTS
  1383. X.IP \fIm\fP 1i     
  1384. XThe magnification factor. Must be greater than zero. Values greater 
  1385. Xthan 1 give magnification, less than 1 give reduction.
  1386. X.SH DESCRIPTION
  1387. X.PP
  1388. XAs of version 5.0, the xvertext package allows you to 
  1389. Xmagnify
  1390. Xexisting fonts. Since X11 fonts are bitmap fonts, 
  1391. X.I the quality of magnified fonts
  1392. X.I may be poor.
  1393. XHaving said that, magnification is done using
  1394. Xbilinear interpolation
  1395. Xand some fonts don't look half bad at say twice their
  1396. Xnormal size. In particular, roman fonts are better than italic
  1397. Xfonts since they have more vertical and horizontal bits to them.
  1398. X.PP
  1399. XThe function
  1400. X.I XRotSetMagnification()
  1401. Xsets the level of magnification. Always use the biggest bitmap font
  1402. Xavailable to get large text. Values of
  1403. X.I m
  1404. Xgreater than 1 produce magnification. Values of
  1405. X.I m
  1406. Xless than 1 produce a reduced font, but you would be better advised
  1407. Xto use a smaller pre-defined bitmap font.
  1408. X.PP
  1409. XThe default value is 1 (no magnification/reduction).
  1410. X.PP
  1411. XNote that magnifying fonts will result in a speed penalty. Say no more!
  1412. X.SH SEE ALSO
  1413. Xxvertext
  1414. END_OF_FILE
  1415.   if test 1328 -ne `wc -c <'man/XRotSetMagnification.man'`; then
  1416.     echo shar: \"'man/XRotSetMagnification.man'\" unpacked with wrong size!
  1417.   fi
  1418.   # end of 'man/XRotSetMagnification.man'
  1419. fi
  1420. if test -f 'man/XRotTextExtents.man' -a "${1}" != "-c" ; then 
  1421.   echo shar: Will not clobber existing file \"'man/XRotTextExtents.man'\"
  1422. else
  1423.   echo shar: Extracting \"'man/XRotTextExtents.man'\" \(2194 characters\)
  1424.   sed "s/^X//" >'man/XRotTextExtents.man' <<'END_OF_FILE'
  1425. X.\" @(#)XRotTextExtents 5.0 25/4/93; Copyright (c) 1993 Alan Richardson
  1426. X.TH XRotDrawAlignedString 3 "25 Apr 1993" "xvertext routines"
  1427. X.SH NAME
  1428. XXRotTextExtents, XRotSetBoundingBoxPad \- obtain and
  1429. Xmanipulate text bounding boxes
  1430. X.SH SYNOPSIS
  1431. X.B XPoint *XRotTextExtents(dpy, font, angle, 
  1432. X.B x, y, text, align)
  1433. X.br
  1434. X.B Display *dpy;
  1435. X.br
  1436. X.B XFontStruct *font;
  1437. X.br
  1438. X.B float angle;
  1439. X.br
  1440. X.B int x, y;
  1441. X.br
  1442. X.B char *text;
  1443. X.br
  1444. X.B int align;
  1445. X.PP
  1446. X.B void XRotSetBoundingBoxPad(pad)
  1447. X.br
  1448. X.B int pad;
  1449. X.SH ARGUMENTS
  1450. X.IP \fIdisplay\fP 1i     
  1451. XSpecifies the connection to the X server.
  1452. X.IP \fIfont\fP 1i
  1453. XPointer to an XFontStruct structure.
  1454. X.IP \fIangle\fP 1i
  1455. XAngle in degrees between direction of text and horizontal
  1456. X(anticlockwise is positive).
  1457. X.IP \fIx\,\ y\fP 1i
  1458. XCoordinates whose relation to the position of the painted text is given
  1459. Xby \fIalign\fP.
  1460. X.IP \fItext\fP 1i
  1461. XA character string.
  1462. X.IP \fIalign\fP 1i
  1463. XDescribes the alignment with which the string would be drawn.
  1464. X.IP \fIpad\fP 1i
  1465. XPad out subsequent bounding boxes out by this number of pixels.
  1466. X.I Pad
  1467. Xmust be greater than or equal to zero.
  1468. X.SH DESCRIPTION
  1469. X.PP
  1470. XThe function
  1471. X.I XRotTextExtents
  1472. Xcomputes the bounding box which would surround a line or block of
  1473. Xtext if one of the drawing functions, such as
  1474. X.I XRotDrawAlignedText,
  1475. Xwere used to paint it.
  1476. XThe arguments
  1477. X.I dpy,
  1478. X.I font,
  1479. X.I angle,
  1480. X.I x, y,
  1481. X.I text and
  1482. X.I align
  1483. Xhave the same meanings as when passed to
  1484. Xthe drawing functions. 
  1485. X.PP
  1486. XThe bounding box is returned as a
  1487. X.I XPoint
  1488. Xarray with five members. The first four specify the coordinates of
  1489. Xthe four bounding box corners, in a clockwise sense. The last member
  1490. Xduplicates the first to produce a closed figure. This list can then 
  1491. Xbe sent to 
  1492. X.I XDrawLines
  1493. Xstraight away to draw the bounding box.
  1494. XWhen the XPoint array is no longer required, the user should free
  1495. Xit with a call to
  1496. X.I free.
  1497. X.PP
  1498. XThe function
  1499. X.I XRotSetBoundingBoxPad
  1500. Xcauses all subsequent bounding boxes to be padded out by 
  1501. X.I pad
  1502. Xpixels. This often produces more pleasing boxes around text.
  1503. X.SH RETURN VALUE
  1504. X.I XRotTextExtents
  1505. Xreturns a null pointer if something went wrong.
  1506. X.SH SEE ALSO
  1507. XXRotDrawString,
  1508. XXRotDrawImageString,
  1509. XXRotDrawAlignedString,
  1510. XXRotDrawAlignedImageString.
  1511. X
  1512. END_OF_FILE
  1513.   if test 2194 -ne `wc -c <'man/XRotTextExtents.man'`; then
  1514.     echo shar: \"'man/XRotTextExtents.man'\" unpacked with wrong size!
  1515.   fi
  1516.   # end of 'man/XRotTextExtents.man'
  1517. fi
  1518. if test -f 'man/xvertext.man' -a "${1}" != "-c" ; then 
  1519.   echo shar: Will not clobber existing file \"'man/xvertext.man'\"
  1520. else
  1521.   echo shar: Extracting \"'man/xvertext.man'\" \(2500 characters\)
  1522.   sed "s/^X//" >'man/xvertext.man' <<'END_OF_FILE'
  1523. X.\" @(#)xvertext 5.0 18/4/93; Copyright (c) 1993 Alan Richardson
  1524. X.TH xvertext 3 "19 Apr 1993" "xvertext routines"
  1525. X.SH NAME
  1526. Xxvertext - a collection of functions for rendering rotated text in an
  1527. XX window
  1528. X.SH GENERAL
  1529. XAs of version 5.0 there are 8 functions in the xvertext package 
  1530. Xintended for general use. These are
  1531. X.I XRotVersion,
  1532. X.I XRotSetMagnification,
  1533. X.I XRotSetBoundingBoxPad,
  1534. X.I XRotTextExtents,
  1535. X.I XRotDrawString,
  1536. X.I XRotDrawImageString,
  1537. X.I XRotDrawAlignedString
  1538. Xand
  1539. X.I XRotDrawAlignedImageString.
  1540. X.SH REMARK
  1541. XRotation at any angle is an improvement over the vertical text
  1542. Xavailable in version 2.0. Some functions have been deleted from that
  1543. Xversion, and some remaining functions
  1544. X.I have had their arguments changed.
  1545. X.PP
  1546. XAs of version 4.0, a cache has been added to speed up redraws. This 
  1547. Xfeature is enabled at compile time.
  1548. X.SH USAGE
  1549. X.I XRotVersion 
  1550. Xis used to obtain the current release number and a copyright string.
  1551. X.PP
  1552. X.I XRotSetMagnification
  1553. Xis used to indicate with what factor all subsequent fonts should be 
  1554. Xmagnified.
  1555. X.PP
  1556. X.I XRotTextExtents
  1557. Xis used to obtain the bounding box a string will have when painted in
  1558. Xa particular font at a given angle/position.
  1559. X.I XRotSetBoundingBoxPad
  1560. Xis used to indicate by how many pixels the bounding box should be
  1561. Xpadded out.
  1562. X.PP
  1563. XUsing the painting routines typically involves three steps: creating 
  1564. Xa GC, loading a font and calling the painting function.
  1565. XFor example:
  1566. X
  1567. X|
  1568. X.br
  1569. X|
  1570. X.br
  1571. XGC gc;
  1572. X.br
  1573. XXFontStruct *font;
  1574. X.br
  1575. Xchar *fontname=
  1576. X"lucidasans-bold-18";
  1577. X.br
  1578. X.PP
  1579. Xfont=XLoadQueryFont(dpy, fontname);
  1580. X.br
  1581. X    if(font==NULL) {
  1582. X        fprintf(stderr, "no font `%s'\\n", fontname);
  1583. X        font=XLoadQueryFont(dpy, "fixed");
  1584. X    }
  1585. X.PP
  1586. Xgc=XCreateGC(dpy, window, NULL, 0);
  1587. X.br
  1588. XXSetForeground(dpy, gc, WhitePixel(dpy, DefaultScreen(dpy)));
  1589. X.br
  1590. XXSetBackground(dpy, gc, BlackPixel(dpy, DefaultScreen(dpy)));
  1591. X.PP
  1592. XXRotDrawAlignedImageString(dpy, font, 45., 
  1593. Xwindow, gc, 300, 300, "hello", BLEFT);
  1594. X.br
  1595. X|
  1596. X.br
  1597. X|
  1598. X.PP
  1599. XNote that dpy and window are a display connection and a window,
  1600. Xalready assumed created.
  1601. XThis code segment obtains an XFontStruct for the font 
  1602. X"lucidasans-bolditalic-10" if it exists, or "fixed" if not.
  1603. XA graphics context is created with white foreground and black
  1604. Xbackground. The string "hello" is then painted at 45 degrees with
  1605. Xbottom left hand corner at (300, 300).
  1606. X.SH SEE ALSO
  1607. XXRotVersion,
  1608. XXRotSetMagnification,
  1609. XXRotSetBoundingBoxPad,
  1610. XXRotTextExtents,
  1611. XXRotDrawString,
  1612. XXRotDrawImageString,
  1613. XXRotDrawAlignedString,
  1614. XXRotDrawAlignedImageString.
  1615. X
  1616. X
  1617. END_OF_FILE
  1618.   if test 2500 -ne `wc -c <'man/xvertext.man'`; then
  1619.     echo shar: \"'man/xvertext.man'\" unpacked with wrong size!
  1620.   fi
  1621.   # end of 'man/xvertext.man'
  1622. fi
  1623. if test -f 'rotated.h' -a "${1}" != "-c" ; then 
  1624.   echo shar: Will not clobber existing file \"'rotated.h'\"
  1625. else
  1626.   echo shar: Extracting \"'rotated.h'\" \(2190 characters\)
  1627.   sed "s/^X//" >'rotated.h' <<'END_OF_FILE'
  1628. X/* ************************************************************************ */
  1629. X
  1630. X
  1631. X/* Header file for the `xvertext 5.0' routines.
  1632. X
  1633. X   Copyright (c) 1993 Alan Richardson (mppa3@uk.ac.sussex.syma) */
  1634. X
  1635. X
  1636. X/* ************************************************************************ */
  1637. X
  1638. X#ifndef _XVERTEXT_INCLUDED_ 
  1639. X#define _XVERTEXT_INCLUDED_
  1640. X
  1641. X
  1642. X#define XV_VERSION      5.0
  1643. X#define XV_COPYRIGHT \
  1644. X      "xvertext routines Copyright (c) 1993 Alan Richardson"
  1645. X
  1646. X
  1647. X/* ---------------------------------------------------------------------- */
  1648. X
  1649. X
  1650. X/* text alignment */
  1651. X
  1652. X#define NONE             0
  1653. X#define TLEFT            1
  1654. X#define TCENTRE          2
  1655. X#define TRIGHT           3
  1656. X#define MLEFT            4
  1657. X#define MCENTRE          5
  1658. X#define MRIGHT           6
  1659. X#define BLEFT            7
  1660. X#define BCENTRE          8
  1661. X#define BRIGHT           9
  1662. X
  1663. X
  1664. X/* ---------------------------------------------------------------------- */
  1665. X
  1666. X/* this shoulf be C++ compliant, thanks to 
  1667. X     vlp@latina.inesc.pt (Vasco Lopes Paulo) */
  1668. X
  1669. X#if defined(__cplusplus) || defined(c_plusplus)
  1670. X
  1671. Xextern "C" {
  1672. Xfloat   XRotVersion(char*, int);
  1673. Xvoid    XRotSetMagnification(float);
  1674. Xvoid    XRotSetBoundingBoxPad(int);
  1675. Xint     XRotDrawString(Display*, XFontStruct*, float,
  1676. X                       Drawable, GC, int, int, char*);
  1677. Xint     XRotDrawImageString(Display*, XFontStruct*, float,
  1678. X                            Drawable, GC, int, int, char*);
  1679. Xint     XRotDrawAlignedString(Display*, XFontStruct*, float,
  1680. X                              Drawable, GC, int, int, char*, int);
  1681. Xint     XRotDrawAlignedImageString(Display*, XFontStruct*, float,
  1682. X                                   Drawable, GC, int, int, char*, int);
  1683. XXPoint *XRotTextExtents(Display*, XFontStruct*, float,
  1684. X            int, int, char*, int);
  1685. X}
  1686. X
  1687. X#else
  1688. X
  1689. Xextern float   XRotVersion();
  1690. Xextern void    XRotSetMagnification();
  1691. Xextern void    XRotSetBoundingBoxPad();
  1692. Xextern int     XRotDrawString();
  1693. Xextern int     XRotDrawImageString();
  1694. Xextern int     XRotDrawAlignedString();
  1695. Xextern int     XRotDrawAlignedImageString();
  1696. Xextern XPoint *XRotTextExtents();
  1697. X
  1698. X#endif /* __cplusplus */
  1699. X
  1700. X/* ---------------------------------------------------------------------- */
  1701. X
  1702. X
  1703. X#endif /* _XVERTEXT_INCLUDED_ */
  1704. X
  1705. X
  1706. X
  1707. END_OF_FILE
  1708.   if test 2190 -ne `wc -c <'rotated.h'`; then
  1709.     echo shar: \"'rotated.h'\" unpacked with wrong size!
  1710.   fi
  1711.   # end of 'rotated.h'
  1712. fi
  1713. if test -f 'xvertext.tmpl' -a "${1}" != "-c" ; then 
  1714.   echo shar: Will not clobber existing file \"'xvertext.tmpl'\"
  1715. else
  1716.   echo shar: Extracting \"'xvertext.tmpl'\" \(1579 characters\)
  1717.   sed "s/^X//" >'xvertext.tmpl' <<'END_OF_FILE'
  1718. X#ifndef XCOMM
  1719. X#ifdef GNUCPP
  1720. X#define XCOMM \#
  1721. X#else
  1722. X#define XCOMM #
  1723. X#endif
  1724. X#endif
  1725. X
  1726. XXCOMM #######################################################################
  1727. X
  1728. X
  1729. XXCOMM Imakefile template for xvertext version 5.0
  1730. X
  1731. X
  1732. XXCOMM #######################################################################
  1733. X
  1734. X
  1735. XXCOMM Cache status:
  1736. XXCOMM ------------
  1737. XXCOMM  Add one of `-DCACHE_XIMAGES' or `-DCACHE_BITMAPS' to decide what is
  1738. XXCOMM   cached.
  1739. XXCOMM
  1740. XXCOMM  Add `-DCACHE_SIZE_LIMIT=xxxx' where xxxx is the cache size in kilobytes.
  1741. XXCOMM   A cache size of zero turns caching off.
  1742. XXCOMM
  1743. XXCOMM  Add `-DCACHE_FID' if you want to cache font ID's in those instances
  1744. XXCOMM   when the font name can't be determined.
  1745. XXCOMM
  1746. XXCOMM  You could also add `-DDEBUG', and watch the cache in operation.
  1747. X
  1748. X
  1749. X                  CACHE = -DCACHE_BITMAPS -DCACHE_SIZE_LIMIT=300 -DCACHE_FID
  1750. X
  1751. X
  1752. XXCOMM #######################################################################
  1753. X
  1754. X
  1755. XXCOMM  If your X11 is release 3, add -DX11R3 to this line
  1756. XXCOMM    (you won't be able to use the stipple feature with rotated text)
  1757. X
  1758. X
  1759. X                RELEASE = 
  1760. X
  1761. X
  1762. XXCOMM #######################################################################
  1763. X
  1764. X
  1765. XXCOMM  This is where the library, header files and manual pages will go, if
  1766. XXCOMM   you use the `install' and `install.man' options with make.
  1767. X
  1768. XXCOMM  Specify full pathnames if you don't want to use these defaults.
  1769. X
  1770. X
  1771. XXCOMM #######################################################################
  1772. X
  1773. X
  1774. X              THELIBDIR = $(USRLIBDIR)
  1775. X              THEINCDIR = $(INCROOT)
  1776. X              THEMANDIR = $(MANDIR)
  1777. X
  1778. X
  1779. END_OF_FILE
  1780.   if test 1579 -ne `wc -c <'xvertext.tmpl'`; then
  1781.     echo shar: \"'xvertext.tmpl'\" unpacked with wrong size!
  1782.   fi
  1783.   # end of 'xvertext.tmpl'
  1784. fi
  1785. echo shar: End of archive 2 \(of 2\).
  1786. cp /dev/null ark2isdone
  1787. MISSING=""
  1788. for I in 1 2 ; do
  1789.     if test ! -f ark${I}isdone ; then
  1790.     MISSING="${MISSING} ${I}"
  1791.     fi
  1792. done
  1793. if test "${MISSING}" = "" ; then
  1794.     echo You have unpacked both archives.
  1795.     rm -f ark[1-9]isdone
  1796. else
  1797.     echo You still must unpack the following archives:
  1798.     echo "        " ${MISSING}
  1799. fi
  1800. exit 0
  1801. exit 0 # Just in case...
  1802. -- 
  1803.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  1804. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  1805.  "It's intuitively obvious to the |
  1806.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1807.