diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:21 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:21 +0000 |
commit | 84735728ed5f6a07d87254860e2776775c54b85b (patch) | |
tree | 3b8bd2195fd61ff50279b2bcfaaf41af01b0279f |
Initial revisionXORG-STABLE
-rw-r--r-- | Dvi.c | 554 | ||||
-rw-r--r-- | Dvi.h | 51 | ||||
-rw-r--r-- | DviChar.c | 678 | ||||
-rw-r--r-- | DviChar.h | 49 | ||||
-rw-r--r-- | DviP.h | 293 | ||||
-rw-r--r-- | Menu.h | 46 | ||||
-rw-r--r-- | XFontName.c | 262 | ||||
-rw-r--r-- | XFontName.h | 55 | ||||
-rw-r--r-- | Xditview-chrtr.ad | 25 | ||||
-rw-r--r-- | Xditview.ad | 96 | ||||
-rw-r--r-- | draw.c | 546 | ||||
-rw-r--r-- | font.c | 486 | ||||
-rw-r--r-- | ldblarrow | 5 | ||||
-rw-r--r-- | lex.c | 92 | ||||
-rw-r--r-- | page.c | 90 | ||||
-rw-r--r-- | parse.c | 479 | ||||
-rw-r--r-- | rdblarrow | 5 | ||||
-rw-r--r-- | xdit.bm | 14 | ||||
-rw-r--r-- | xdit_mask.bm | 14 | ||||
-rw-r--r-- | xditview.c | 655 | ||||
-rw-r--r-- | xditview.man | 177 |
21 files changed, 4672 insertions, 0 deletions
@@ -0,0 +1,554 @@ +/* $XConsortium: Dvi.c,v 1.21 94/04/17 20:43:34 keith Exp $ */ +/* + +Copyright (c) 1991 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ +/* $XFree86: xc/programs/xditview/Dvi.c,v 1.4 2001/08/27 23:35:12 dawes Exp $ */ + + +/* + * Dvi.c - Dvi display widget + */ + +#define XtStrlen(s) ((s) ? strlen(s) : 0) + + /* The following are defined for the reader's convenience. Any + Xt..Field macro in this code just refers to some field in + one of the substructures of the WidgetRec. */ + +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <X11/Xmu/Converters.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <ctype.h> +#include "DviP.h" + +/**************************************************************** + * + * Full class record constant + * + ****************************************************************/ + +/* Private Data */ +/* Note: default_font_map was too long a token for some machines... + * therefor it has been split in to and assigned to resources + * in the ClassInitialize routine. + */ +static char default_font_map_1[] = "\ +R -*-times-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +I -*-times-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\ +B -*-times-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +F -*-times-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\ +TR -*-times-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +TI -*-times-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\ +TB -*-times-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +TF -*-times-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\ +BI -*-times-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\ +C -*-courier-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +CO -*-courier-medium-o-normal--*-*-*-*-*-*-iso8859-1\n\ +CB -*-courier-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +CF -*-courier-bold-o-normal--*-*-*-*-*-*-iso8859-1\n\ +H -*-helvetica-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +HO -*-helvetica-medium-o-normal--*-*-*-*-*-*-iso8859-1\n\ +HB -*-helvetica-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +HF -*-helvetica-bold-o-normal--*-*-*-*-*-*-iso8859-1\n\ +"; +static char default_font_map_2[] = "\ +N -*-new century schoolbook-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +NI -*-new century schoolbook-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\ +NB -*-new century schoolbook-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +NF -*-new century schoolbook-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\ +A -*-charter-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +AI -*-charter-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\ +AB -*-charter-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +AF -*-charter-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\ +S -*-symbol-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific\n\ +S2 -*-symbol-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific\n\ +"; + +#define offset(field) XtOffsetOf(DviRec, field) + +static XtResource resources[] = { + {XtNfontMap, XtCFontMap, XtRString, sizeof (char *), + offset(dvi.font_map_string), XtRString, NULL /* set in code */}, + {XtNforeground, XtCForeground, XtRPixel, sizeof (unsigned long), + offset(dvi.foreground), XtRString, XtDefaultForeground}, + {XtNpageNumber, XtCPageNumber, XtRInt, sizeof (int), + offset(dvi.requested_page), XtRImmediate, (XtPointer) 1}, + {XtNlastPageNumber, XtCLastPageNumber, XtRInt, sizeof (int), + offset (dvi.last_page), XtRImmediate, (XtPointer) 0}, + {XtNfile, XtCFile, XtRFile, sizeof (FILE *), + offset (dvi.file), XtRFile, (char *) 0}, + {XtNseek, XtCSeek, XtRBoolean, sizeof (Boolean), + offset(dvi.seek), XtRImmediate, (XtPointer) False}, + {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *), + offset(dvi.default_font), XtRString, XtDefaultFont}, + {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int), + offset(dvi.backing_store), XtRString, "default"}, + {XtNnoPolyText, XtCNoPolyText, XtRBoolean, sizeof (Boolean), + offset(dvi.noPolyText), XtRImmediate, (XtPointer) False}, + {XtNscreenResolution, XtCScreenResolution, XtRInt, sizeof (int), + offset(dvi.screen_resolution), XtRImmediate, (XtPointer) 75}, + {XtNpageWidth, XtCPageWidth, XtRFloat, sizeof (float), + offset(dvi.page_width), XtRString, "8.5"}, + {XtNpageHeight, XtCPageHeight, XtRFloat, sizeof (float), + offset(dvi.page_height), XtRString, "11"}, + {XtNsizeScale, XtCSizeScale, XtRInt, sizeof (int), + offset(dvi.size_scale_set), XtRImmediate, (XtPointer) 0}, +}; + +#undef offset + +static void ClassInitialize(void); +static void Initialize(Widget, Widget, ArgList, Cardinal *); +static void Realize(Widget, XtValueMask *, XSetWindowAttributes *); +static void Destroy(Widget); +static void Redisplay(Widget, XEvent *, Region); +static Boolean SetValues(Widget, Widget, Widget, ArgList , Cardinal *); +static Boolean SetValuesHook(Widget, ArgList, Cardinal *); +static XtGeometryResult QueryGeometry(Widget, + XtWidgetGeometry *, XtWidgetGeometry *); +static void RequestDesiredSize(DviWidget); +static void ShowDvi(DviWidget); +static void CloseFile(DviWidget); +static void OpenFile(DviWidget); + +#define SuperClass ((SimpleWidgetClass)&simpleClassRec) + +DviClassRec dviClassRec = { +{ + (WidgetClass) SuperClass, /* superclass */ + "Dvi", /* class_name */ + sizeof(DviRec), /* size */ + ClassInitialize, /* class_initialize */ + NULL, /* class_part_initialize */ + FALSE, /* class_inited */ + Initialize, /* initialize */ + NULL, /* initialize_hook */ + Realize, /* realize */ + NULL, /* actions */ + 0, /* num_actions */ + resources, /* resources */ + XtNumber(resources), /* resource_count */ + NULLQUARK, /* xrm_class */ + FALSE, /* compress_motion */ + XtExposeCompressMaximal, /* compress_exposure */ + TRUE, /* compress_enterleave */ + FALSE, /* visible_interest */ + Destroy, /* destroy */ + NULL, /* resize */ + Redisplay, /* expose */ + SetValues, /* set_values */ + SetValuesHook, /* set_values_hook */ + XtInheritSetValuesAlmost, /* set_values_almost */ + NULL, /* get_values_hook */ + NULL, /* accept_focus */ + XtVersion, /* version */ + NULL, /* callback_private */ + 0, /* tm_table */ + QueryGeometry, /* query_geometry */ + XtInheritDisplayAccelerator, /* display_accelerator */ + NULL, /* extension */ +}, /* CoreClass fields initialization */ +{ + XtInheritChangeSensitive /* change_sensitive */ +}, /* SimpleClass fields initialization */ +{ + 0, /* field not used */ +}, /* DviClass fields initialization */ +}; + +WidgetClass dviWidgetClass = (WidgetClass) &dviClassRec; + +static void +ClassInitialize (void) +{ + int len1 = strlen(default_font_map_1); + int len2 = strlen(default_font_map_2); + char *dfm = XtMalloc(len1 + len2 + 1); + char *ptr = dfm; + strcpy(ptr, default_font_map_1); ptr += len1; + strcpy(ptr, default_font_map_2); + resources[0].default_addr = dfm; + + XtAddConverter( XtRString, XtRBackingStore, XmuCvtStringToBackingStore, + NULL, 0 ); +} + +/**************************************************************** + * + * Private Procedures + * + ****************************************************************/ + +/* ARGSUSED */ +static void +Initialize(request, new, args, num_args) + Widget request, new; + ArgList args; + Cardinal *num_args; +{ + DviWidget dw = (DviWidget) new; + + dw->dvi.tmpFile = 0; + dw->dvi.readingTmp = 0; + dw->dvi.ungot = 0; + dw->dvi.normal_GC = 0; + dw->dvi.file_map = 0; + dw->dvi.fonts = 0; + dw->dvi.font_map = 0; + dw->dvi.current_page = 0; + dw->dvi.font_size = 0; + dw->dvi.font_number = 0; + dw->dvi.device_resolution = 0; + dw->dvi.line_width = 0; + dw->dvi.line_style = 0; + dw->dvi.font = 0; + dw->dvi.display_enable = 0; + dw->dvi.scale = 0.0; + dw->dvi.state = 0; + dw->dvi.cache.index = 0; + dw->dvi.cache.font = 0; + dw->dvi.size_scale = 0; + dw->dvi.size_scale_set = 0; + RequestDesiredSize (dw); +} + +static void +Realize(w, valueMask, attrs) + Widget w; + XtValueMask *valueMask; + XSetWindowAttributes *attrs; +{ + DviWidget dw = (DviWidget) w; + XGCValues values; + + if (dw->dvi.backing_store != Always + WhenMapped + NotUseful) { + attrs->backing_store = dw->dvi.backing_store; + *valueMask |= CWBackingStore; + } + XtCreateWindow (w, (unsigned)InputOutput, (Visual *) CopyFromParent, + *valueMask, attrs); + values.foreground = dw->dvi.foreground; + dw->dvi.normal_GC = XCreateGC (XtDisplay (w), XtWindow (w), + GCForeground, &values); +#ifdef USE_XFT + { + int scr; + Visual *visual; + Colormap cmap; + XRenderColor black; + + scr = XScreenNumberOfScreen (dw->core.screen); + visual = DefaultVisual (XtDisplay (w), scr); + cmap = DefaultColormap (XtDisplay (w), scr); + dw->dvi.draw = XftDrawCreate (XtDisplay (w), XtWindow (w), + visual, cmap); + + black.red = black.green = black.blue = 0; + black.alpha = 0xffff; + XftColorAllocValue (XtDisplay (w), visual, cmap, + &black, &dw->dvi.black); + dw->dvi.default_font = XftFontOpenName (XtDisplay (w), + scr, + "serif-12"); + } +#endif + if (dw->dvi.file) + OpenFile (dw); + ParseFontMap (dw); +} + +static void +Destroy(w) + Widget w; +{ + DviWidget dw = (DviWidget) w; + + XFreeGC (XtDisplay (w), dw->dvi.normal_GC); + DestroyFontMap (dw->dvi.font_map); + DestroyFileMap (dw->dvi.file_map); +} + +/* + * Repaint the widget window + */ + +/* ARGSUSED */ +static void +Redisplay(w, event, region) + Widget w; + XEvent *event; + Region region; +{ + DviWidget dw = (DviWidget) w; +#ifndef USE_XFT + XRectangle extents; +#endif + +#ifdef USE_XFT + XClearArea (XtDisplay (dw), + XtWindow (dw), + 0, 0, 0, 0, False); + dw->dvi.extents.x1 = 0; + dw->dvi.extents.y1 = 0; + dw->dvi.extents.x2 = dw->core.width; + dw->dvi.extents.y2 = dw->core.height; +#else + XClipBox (region, &extents); + dw->dvi.extents.x1 = extents.x; + dw->dvi.extents.y1 = extents.y; + dw->dvi.extents.x2 = extents.x + extents.width; + dw->dvi.extents.y2 = extents.y + extents.height; +#endif + ShowDvi (dw); +} + +static void +RequestDesiredSize (dw) + DviWidget dw; +{ + XtWidgetGeometry req, rep; + + dw->dvi.desired_width = dw->dvi.page_width * + dw->dvi.screen_resolution; + dw->dvi.desired_height = dw->dvi.page_height * + dw->dvi.screen_resolution; + req.request_mode = CWWidth|CWHeight; + req.width = dw->dvi.desired_width; + req.height = dw->dvi.desired_height; + XtMakeGeometryRequest ((Widget) dw, &req, &rep); +} + +/* + * Set specified arguments into widget + */ +/* ARGSUSED */ +static Boolean +SetValues (wcurrent, wrequest, wnew, args, num_args) + Widget wcurrent, wrequest, wnew; + ArgList args; + Cardinal *num_args; +{ + DviWidget current = (DviWidget) wcurrent; + DviWidget request = (DviWidget) wrequest; + DviWidget new = (DviWidget) wnew; + Boolean redisplay = FALSE; + char *new_map; + int cur, req; + + req = request->dvi.requested_page; + cur = current->dvi.requested_page; + if (cur != req) { + if (req < 1) + req = 1; + if (request->dvi.file) + { + if (current->dvi.last_page != 0 && + req > current->dvi.last_page) + req = current->dvi.last_page; + } + if (cur != req) + redisplay = TRUE; + new->dvi.requested_page = req; + } + + if (current->dvi.font_map_string != request->dvi.font_map_string) { + new_map = XtMalloc (strlen (request->dvi.font_map_string) + 1); + if (new_map) { + redisplay = TRUE; + strcpy (new_map, request->dvi.font_map_string); + new->dvi.font_map_string = new_map; + if (current->dvi.font_map_string) + XtFree (current->dvi.font_map_string); + current->dvi.font_map_string = 0; + ParseFontMap (new); + } + } + if (current->dvi.screen_resolution != request->dvi.screen_resolution) + { + ResetFonts (new); + new->dvi.line_width = -1; + } + if (request->dvi.device_resolution) + new->dvi.scale = ((double) request->dvi.screen_resolution) / + ((double) request->dvi.device_resolution); + if (current->dvi.page_width != request->dvi.page_width || + current->dvi.page_height != request->dvi.page_height || + current->dvi.screen_resolution != request->dvi.screen_resolution) + { + RequestDesiredSize (new); + redisplay = TRUE; + } + return redisplay; +} + +/* + * use the set_values_hook entry to check when + * the file is set + */ + +static Boolean +SetValuesHook (widget, args, num_argsp) + Widget widget; + ArgList args; + Cardinal *num_argsp; +{ + DviWidget dw = (DviWidget) widget; + Cardinal i; + + for (i = 0; i < *num_argsp; i++) { + if (!strcmp (args[i].name, XtNfile)) { + CloseFile (dw); + OpenFile (dw); + return TRUE; + } + } + return FALSE; +} + +static void +CloseFile (dw) + DviWidget dw; +{ + if (dw->dvi.tmpFile) + fclose (dw->dvi.tmpFile); + ForgetPagePositions (dw); +} + +static void +OpenFile (dw) + DviWidget dw; +{ + char tmpName[sizeof ("/tmp/dviXXXXXX")]; +#ifdef HAS_MKSTEMP + int fd; +#endif + + dw->dvi.tmpFile = 0; + if (!dw->dvi.seek) { + strcpy (tmpName, "/tmp/dviXXXXXX"); +#ifndef HAS_MKSTEMP + mktemp (tmpName); + dw->dvi.tmpFile = fopen (tmpName, "w+"); +#else + fd = mkstemp(tmpName); + dw->dvi.tmpFile = fdopen(fd, "w+"); +#endif + unlink (tmpName); + } + if (dw->dvi.requested_page < 1) + dw->dvi.requested_page = 1; + dw->dvi.last_page = 0; +} + +static XtGeometryResult +QueryGeometry (w, request, geometry_return) + Widget w; + XtWidgetGeometry *request, *geometry_return; +{ + XtGeometryResult ret; + DviWidget dw = (DviWidget) w; + + ret = XtGeometryYes; + if ((int)request->width < dw->dvi.desired_width + || (int)request->height < dw->dvi.desired_height) + ret = XtGeometryAlmost; + geometry_return->width = dw->dvi.desired_width; + geometry_return->height = dw->dvi.desired_height; + geometry_return->request_mode = CWWidth|CWHeight; + return ret; +} + +void +SetDeviceResolution (dw, resolution) + DviWidget dw; + int resolution; +{ + if (resolution != dw->dvi.device_resolution) { + dw->dvi.device_resolution = resolution; + dw->dvi.scale = ((double) dw->dvi.screen_resolution) / + ((double) resolution); + } +} + +static void +ShowDvi (dw) + DviWidget dw; +{ + int i; + long file_position; + + if (!dw->dvi.file) + return; + + if (dw->dvi.requested_page < 1) + dw->dvi.requested_page = 1; + + if (dw->dvi.last_page != 0 && dw->dvi.requested_page > dw->dvi.last_page) + dw->dvi.requested_page = dw->dvi.last_page; + + file_position = SearchPagePosition (dw, dw->dvi.requested_page); + if (file_position != -1) { + FileSeek(dw, file_position); + dw->dvi.current_page = dw->dvi.requested_page; + } else { + for (i=dw->dvi.requested_page; i > 0; i--) { + file_position = SearchPagePosition (dw, i); + if (file_position != -1) + break; + } + if (file_position == -1) + file_position = 0; + FileSeek (dw, file_position); + + dw->dvi.current_page = i; + + dw->dvi.display_enable = 0; + while (dw->dvi.current_page != dw->dvi.requested_page) { + dw->dvi.current_page = ParseInput (dw); + /* + * at EOF, seek back to the begining of this page. + */ + if (feof (dw->dvi.file)) { + file_position = SearchPagePosition (dw, + dw->dvi.current_page); + if (file_position != -1) + FileSeek (dw, file_position); + break; + } + } + } + + dw->dvi.display_enable = 1; + ParseInput (dw); + if (dw->dvi.last_page && dw->dvi.requested_page > dw->dvi.last_page) + dw->dvi.requested_page = dw->dvi.last_page; +} @@ -0,0 +1,51 @@ +/* +* $XConsortium: Dvi.h,v 1.5 91/07/25 21:33:53 keith Exp $ +*/ +/* $XFree86: xc/programs/xditview/Dvi.h,v 1.3 2000/12/04 21:01:01 dawes Exp $ */ + +#ifndef _XtDvi_h +#define _XtDvi_h + +/*********************************************************************** + * + * Dvi Widget + * + ***********************************************************************/ + +/* Parameters: + + Name Class RepType Default Value + ---- ----- ------- ------------- + background Background pixel White + foreground Foreground Pixel Black + fontMap FontMap char * ... + pageNumber PageNumber int 1 +*/ + +#define XtNfontMap "fontMap" +#define XtNpageNumber "pageNumber" +#define XtNlastPageNumber "lastPageNumber" +#define XtNnoPolyText "noPolyText" +#define XtNseek "seek" +#define XtNscreenResolution "screenResolution" +#define XtNpageWidth "pageWidth" +#define XtNpageHeight "pageHeight" +#define XtNsizeScale "sizeScale" + +#define XtCFontMap "FontMap" +#define XtCPageNumber "PageNumber" +#define XtCLastPageNumber "LastPageNumber" +#define XtCNoPolyText "NoPolyText" +#define XtCSeek "Seek" +#define XtCScreenResolution "ScreenResolution" +#define XtCPageWidth "PageWidth" +#define XtCPageHeight "PageHeight" +#define XtCSizeScale "SizeScale" + +typedef struct _DviRec *DviWidget; /* completely defined in DviPrivate.h */ +typedef struct _DviClassRec *DviWidgetClass; /* completely defined in DviPrivate.h */ + +extern WidgetClass dviWidgetClass; + +#endif /* _XtDvi_h */ +/* DON'T ADD STUFF AFTER THIS #endif */ diff --git a/DviChar.c b/DviChar.c new file mode 100644 index 0000000..ebef6a8 --- /dev/null +++ b/DviChar.c @@ -0,0 +1,678 @@ +/* $XConsortium: DviChar.c,v 1.7 91/07/31 00:39:31 keith Exp $ */ + +/* + * DviChar.c + * + * Map DVI (ditrof output) character names to + * font indexes and back + */ +/* $XFree86: xc/programs/xditview/DviChar.c,v 1.3 2001/08/28 16:48:09 tsi Exp $ */ + +# include <X11/Intrinsic.h> +# include "DviChar.h" + +# define allocHash() ((DviCharNameHash *) XtMalloc (sizeof (DviCharNameHash))) + +struct map_list { + struct map_list *next; + DviCharNameMap *map; +}; + +static struct map_list *world; + +static int standard_maps_loaded = 0; +static void load_standard_maps (void); +static int hash_name (char *name); +static void dispose_hash(DviCharNameMap *map); +static void compute_hash(DviCharNameMap *map); + +DviCharNameMap * +DviFindMap (encoding) + char *encoding; +{ + struct map_list *m; + + if (!standard_maps_loaded) + load_standard_maps (); + for (m = world; m; m=m->next) + if (!strcmp (m->map->encoding, encoding)) + return m->map; + return 0; +} + +void +DviRegisterMap (map) + DviCharNameMap *map; +{ + struct map_list *m; + + if (!standard_maps_loaded) + load_standard_maps (); + for (m = world; m; m = m->next) + if (!strcmp (m->map->encoding, map->encoding)) + break; + if (!m) { + m = (struct map_list *) XtMalloc (sizeof *m); + m->next = world; + world = m; + } + dispose_hash (map); + m->map = map; + compute_hash (map); +} + +static void +dispose_hash (map) + DviCharNameMap *map; +{ + DviCharNameHash **buckets; + DviCharNameHash *h, *next; + int i; + + buckets = map->buckets; + for (i = 0; i < DVI_HASH_SIZE; i++) { + for (h = buckets[i]; h; h=next) { + next = h->next; + XtFree ((char *) h); + } + } +} + +static int +hash_name (name) + char *name; +{ + int i = 0; + + while (*name) + i = (i << 1) ^ *name++; + if (i < 0) + i = -i; + return i; +} + +static void +compute_hash (map) + DviCharNameMap *map; +{ + DviCharNameHash **buckets; + int c, s, i; + DviCharNameHash *h; + + buckets = map->buckets; + for (i = 0; i < DVI_HASH_SIZE; i++) + buckets[i] = 0; + for (c = 0; c < DVI_MAP_SIZE; c++) + for (s = 0; s < DVI_MAX_SYNONYMS; s++) { + if (!map->dvi_names[c][s]) + break; + i = hash_name (map->dvi_names[c][s]) % DVI_HASH_SIZE; + h = allocHash (); + h->next = buckets[i]; + buckets[i] = h; + h->name = map->dvi_names[c][s]; + h->position = c; + } + +} + +int +DviCharIndex (map, name) + DviCharNameMap *map; + char *name; +{ + int i; + DviCharNameHash *h; + + i = hash_name (name) % DVI_HASH_SIZE; + for (h = map->buckets[i]; h; h=h->next) + if (!strcmp (h->name, name)) + return h->position; + return -1; +} + +static DviCharNameMap ISO8859_1_map = { + "iso8859-1", + 0, +{ +{ 0, /* 0 */}, +{ 0, /* 1 */}, +{ 0, /* 2 */}, +{ 0, /* 3 */}, +{ 0, /* 4 */}, +{ 0, /* 5 */}, +{ 0, /* 6 */}, +{ 0, /* 7 */}, +{ 0, /* 8 */}, +{ 0, /* 9 */}, +{ 0, /* 10 */}, +{ 0, /* 11 */}, +{ 0, /* 12 */}, +{ 0, /* 13 */}, +{ 0, /* 14 */}, +{ 0, /* 15 */}, +{ 0, /* 16 */}, +{ 0, /* 17 */}, +{ 0, /* 18 */}, +{ 0, /* 19 */}, +{ 0, /* 20 */}, +{ 0, /* 21 */}, +{ 0, /* 22 */}, +{ 0, /* 23 */}, +{ 0, /* 24 */}, +{ 0, /* 25 */}, +{ 0, /* 26 */}, +{ 0, /* 27 */}, +{ 0, /* 28 */}, +{ 0, /* 29 */}, +{ 0, /* 30 */}, +{ 0, /* 31 */}, +{ 0, /* 32 */}, +{ "!", /* 33 */}, +{ "\"", /* 34 */}, +{ "#", /* 35 */}, +{ "$", /* 36 */}, +{ "%", /* 37 */}, +{ "&", /* 38 */}, +{ "'", /* 39 */}, +{ "(", /* 40 */}, +{ ")", /* 41 */}, +{ "*", /* 42 */}, +{ "+", /* 43 */}, +{ ",", /* 44 */}, +{ "-","\\-", /* 45 */}, +{ ".", /* 46 */}, +{ "/","sl", /* 47 */}, +{ "0", /* 48 */}, +{ "1", /* 49 */}, +{ "2", /* 50 */}, +{ "3", /* 51 */}, +{ "4", /* 52 */}, +{ "5", /* 53 */}, +{ "6", /* 54 */}, +{ "7", /* 55 */}, +{ "8", /* 56 */}, +{ "9", /* 57 */}, +{ ":", /* 58 */}, +{ ";", /* 59 */}, +{ "<", /* 60 */}, +{ "=","eq", /* 61 */}, +{ ">", /* 62 */}, +{ "?", /* 63 */}, +{ "@", /* 64 */}, +{ "A", /* 65 */}, +{ "B", /* 66 */}, +{ "C", /* 67 */}, +{ "D", /* 68 */}, +{ "E", /* 69 */}, +{ "F", /* 70 */}, +{ "G", /* 71 */}, +{ "H", /* 72 */}, +{ "I", /* 73 */}, +{ "J", /* 74 */}, +{ "K", /* 75 */}, +{ "L", /* 76 */}, +{ "M", /* 77 */}, +{ "N", /* 78 */}, +{ "O", /* 79 */}, +{ "P", /* 80 */}, +{ "Q", /* 81 */}, +{ "R", /* 82 */}, +{ "S", /* 83 */}, +{ "T", /* 84 */}, +{ "U", /* 85 */}, +{ "V", /* 86 */}, +{ "W", /* 87 */}, +{ "X", /* 88 */}, +{ "Y", /* 89 */}, +{ "Z", /* 90 */}, +{ "[", /* 91 */}, +{ "\\", /* 92 */}, +{ "]", /* 93 */}, +{ "a^", /* 94 */}, +{ "_","ru","ul", /* 95 */}, +{ "`", /* 96 */}, +{ "a", /* 97 */}, +{ "b", /* 98 */}, +{ "c", /* 99 */}, +{ "d", /* 100 */}, +{ "e", /* 101 */}, +{ "f", /* 102 */}, +{ "g", /* 103 */}, +{ "h", /* 104 */}, +{ "i", /* 105 */}, +{ "j", /* 106 */}, +{ "k", /* 107 */}, +{ "l", /* 108 */}, +{ "m", /* 109 */}, +{ "n", /* 110 */}, +{ "o", /* 111 */}, +{ "p", /* 112 */}, +{ "q", /* 113 */}, +{ "r", /* 114 */}, +{ "s", /* 115 */}, +{ "t", /* 116 */}, +{ "u", /* 117 */}, +{ "v", /* 118 */}, +{ "w", /* 119 */}, +{ "x", /* 120 */}, +{ "y", /* 121 */}, +{ "z", /* 122 */}, +{ "{", /* 123 */}, +{ "|","or" /* 124 */}, +{ "}", /* 125 */}, +{ "a~","ap" /* 126 */}, +{ 0, /* 127 */}, +{ 0, /* 128 */}, +{ 0, /* 129 */}, +{ 0, /* 130 */}, +{ 0, /* 131 */}, +{ 0, /* 132 */}, +{ 0, /* 133 */}, +{ 0, /* 134 */}, +{ 0, /* 135 */}, +{ 0, /* 136 */}, +{ 0, /* 137 */}, +{ 0, /* 138 */}, +{ 0, /* 139 */}, +{ 0, /* 140 */}, +{ 0, /* 141 */}, +{ 0, /* 142 */}, +{ 0, /* 143 */}, +{ 0, /* 144 */}, +{ 0, /* 145 */}, +{ 0, /* 146 */}, +{ 0, /* 147 */}, +{ 0, /* 148 */}, +{ 0, /* 149 */}, +{ 0, /* 150 */}, +{ 0, /* 151 */}, +{ 0, /* 152 */}, +{ 0, /* 153 */}, +{ 0, /* 154 */}, +{ 0, /* 155 */}, +{ 0, /* 156 */}, +{ 0, /* 157 */}, +{ 0, /* 158 */}, +{ 0, /* 159 */}, +{ 0, /* 160 */}, +{ "I!", /* 161 */}, +{ "ct", /* 162 */}, +{ "po", /* 163 */}, +{ "cu", /* 164 */}, +{ "$J", /* 165 */}, +{ 0, /* 166 */}, +{ "sc", /* 167 */}, +{ 0, /* 168 */}, +{ "co", /* 169 */}, +{ 0, /* 170 */}, +{ "d<", /* 171 */}, +{ "no", /* 172 */}, +{ "hy", /* 173 */}, +{ "rg", /* 174 */}, +{ "ma", /* 175 */}, +{ "de", /* 176 */}, +{ "+-", /* 177 */}, +{ 0, /* 178 */}, +{ 0, /* 179 */}, +{ "aa", /* 180 */}, +{ "*m", /* 181 */}, +{ "pp", /* 182 */}, +{ 0, /* 183 */}, +{ "cd", /* 184 */}, +{ 0, /* 185 */}, +{ 0, /* 186 */}, +{ "d>", /* 187 */}, +{ "14", /* 188 */}, +{ "12", /* 189 */}, +{ "34", /* 190 */}, +{ "I?", /* 191 */}, +{ 0, /* 192 */}, +{ 0, /* 193 */}, +{ 0, /* 194 */}, +{ 0, /* 195 */}, +{ 0, /* 196 */}, +{ 0, /* 197 */}, +{ "AE", /* 198 */}, +{ 0, /* 199 */}, +{ 0, /* 200 */}, +{ 0, /* 201 */}, +{ 0, /* 202 */}, +{ 0, /* 203 */}, +{ 0, /* 204 */}, +{ 0, /* 205 */}, +{ 0, /* 206 */}, +{ 0, /* 207 */}, +{ 0, /* 208 */}, +{ 0, /* 209 */}, +{ 0, /* 210 */}, +{ 0, /* 211 */}, +{ 0, /* 212 */}, +{ 0, /* 213 */}, +{ 0, /* 214 */}, +{ "mu", /* 215 */}, +{ "O/", /* 216 */}, +{ 0, /* 217 */}, +{ 0, /* 218 */}, +{ 0, /* 219 */}, +{ 0, /* 220 */}, +{ 0, /* 221 */}, +{ 0, /* 222 */}, +{ "ss", /* 223 */}, +{ 0, /* 224 */}, +{ 0, /* 225 */}, +{ 0, /* 226 */}, +{ 0, /* 227 */}, +{ 0, /* 228 */}, +{ 0, /* 229 */}, +{ "ae", /* 230 */}, +{ 0, /* 231 */}, +{ 0, /* 232 */}, +{ 0, /* 233 */}, +{ 0, /* 234 */}, +{ 0, /* 235 */}, +{ 0, /* 236 */}, +{ 0, /* 237 */}, +{ 0, /* 238 */}, +{ 0, /* 239 */}, +{ 0, /* 240 */}, +{ 0, /* 241 */}, +{ 0, /* 242 */}, +{ 0, /* 243 */}, +{ 0, /* 244 */}, +{ 0, /* 245 */}, +{ 0, /* 246 */}, +{ 0, /* 247 */}, +{ 0, /* 248 */}, +{ 0, /* 249 */}, +{ 0, /* 250 */}, +{ 0, /* 251 */}, +{ 0, /* 252 */}, +{ 0, /* 253 */}, +{ 0, /* 254 */}, +{ 0, /* 255 */}, +}, +{ +{ "fi", "fi", }, +{ "fl", "fl", }, +{ "ff", "ff", }, +{ "Fi", "ffi", }, +{ "Fl", "ffl", }, +{ 0, 0, }, +} +}; + +static DviCharNameMap Adobe_Symbol_map = { + "adobe-fontspecific", + 1, +{ +{ 0, /* 0 */}, +{ 0, /* 1 */}, +{ 0, /* 2 */}, +{ 0, /* 3 */}, +{ 0, /* 4 */}, +{ 0, /* 5 */}, +{ 0, /* 6 */}, +{ 0, /* 7 */}, +{ 0, /* 8 */}, +{ 0, /* 9 */}, +{ 0, /* 10 */}, +{ 0, /* 11 */}, +{ 0, /* 12 */}, +{ 0, /* 13 */}, +{ 0, /* 14 */}, +{ 0, /* 15 */}, +{ 0, /* 16 */}, +{ 0, /* 17 */}, +{ 0, /* 18 */}, +{ 0, /* 19 */}, +{ 0, /* 20 */}, +{ 0, /* 21 */}, +{ 0, /* 22 */}, +{ 0, /* 23 */}, +{ 0, /* 24 */}, +{ 0, /* 25 */}, +{ 0, /* 26 */}, +{ 0, /* 27 */}, +{ 0, /* 28 */}, +{ 0, /* 29 */}, +{ 0, /* 30 */}, +{ 0, /* 31 */}, +{ 0, /* 32 */}, +{ "!", /* 33 */}, +{ "fa", /* 34 */}, +{ "#", /* 35 */}, +{ "te", /* 36 */}, +{ "%", /* 37 */}, +{ "&", /* 38 */}, +{ "cm", /* 39 */}, +{ "(", /* 40 */}, +{ ")", /* 41 */}, +{ "**", /* 42 */}, +{ "+","pl", /* 43 */}, +{ ",", /* 44 */}, +{ "-","mi","\\-", /* 45 */}, +{ ".", /* 46 */}, +{ "/","sl", /* 47 */}, +{ "0", /* 48 */}, +{ "1", /* 49 */}, +{ "2", /* 50 */}, +{ "3", /* 51 */}, +{ "4", /* 52 */}, +{ "5", /* 53 */}, +{ "6", /* 54 */}, +{ "7", /* 55 */}, +{ "8", /* 56 */}, +{ "9", /* 57 */}, +{ ":", /* 58 */}, +{ ";", /* 59 */}, +{ "<", /* 60 */}, +{ "=","eq", /* 61 */}, +{ ">", /* 62 */}, +{ "?", /* 63 */}, +{ "=~", /* 64 */}, +{ "*A", /* 65 */}, +{ "*B", /* 66 */}, +{ "*C", /* 67 */}, +{ "*D", /* 68 */}, +{ "*E", /* 69 */}, +{ "*F", /* 70 */}, +{ "*G", /* 71 */}, +{ "*Y", /* 72 */}, +{ "*I", /* 73 */}, +{ 0, /* 74 */}, +{ "*K", /* 75 */}, +{ "*L", /* 76 */}, +{ "*M", /* 77 */}, +{ "*N", /* 78 */}, +{ "*O", /* 79 */}, +{ "*P", /* 80 */}, +{ "*H", /* 81 */}, +{ "*R", /* 82 */}, +{ "*S", /* 83 */}, +{ "*T", /* 84 */}, +{ "*U", /* 85 */}, +{ "ts", /* 86 */}, +{ "*W", /* 87 */}, +{ "*C", /* 88 */}, +{ "*Q", /* 89 */}, +{ "*Z", /* 90 */}, +{ "[", /* 91 */}, +{ "tf", /* 92 */}, +{ "]", /* 93 */}, +{ "bt", /* 94 */}, +{ "ul", /* 95 */}, +{ "rn", /* 96 */}, +{ "*a", /* 97 */}, +{ "*b", /* 98 */}, +{ "*x", /* 99 */}, +{ "*d", /* 100 */}, +{ "*e", /* 101 */}, +{ "*f", /* 102 */}, +{ "*g", /* 103 */}, +{ "*y", /* 104 */}, +{ "*i", /* 105 */}, +{ 0, /* 106 */}, +{ "*k", /* 107 */}, +{ "*l", /* 108 */}, +{ "*m", /* 109 */}, +{ "*n", /* 110 */}, +{ "*o", /* 111 */}, +{ "*p", /* 112 */}, +{ "*h", /* 113 */}, +{ "*r", /* 114 */}, +{ "*s", /* 115 */}, +{ "*t", /* 116 */}, +{ "*u", /* 117 */}, +{ 0, /* 118 */}, +{ "*w", /* 119 */}, +{ "*c", /* 120 */}, +{ "*q", /* 121 */}, +{ "*z", /* 122 */}, +{ "{", /* 123 */}, +{ "|", /* 124 */}, +{ "}", /* 125 */}, +{ "a~","ap", /* 126 */}, +{ 0, /* 127 */}, +{ 0, /* 128 */}, +{ 0, /* 129 */}, +{ 0, /* 130 */}, +{ 0, /* 131 */}, +{ 0, /* 132 */}, +{ 0, /* 133 */}, +{ 0, /* 134 */}, +{ 0, /* 135 */}, +{ 0, /* 136 */}, +{ 0, /* 137 */}, +{ 0, /* 138 */}, +{ 0, /* 139 */}, +{ 0, /* 140 */}, +{ 0, /* 141 */}, +{ 0, /* 142 */}, +{ 0, /* 143 */}, +{ 0, /* 144 */}, +{ 0, /* 145 */}, +{ 0, /* 146 */}, +{ 0, /* 147 */}, +{ 0, /* 148 */}, +{ 0, /* 149 */}, +{ 0, /* 150 */}, +{ 0, /* 151 */}, +{ 0, /* 152 */}, +{ 0, /* 153 */}, +{ 0, /* 154 */}, +{ 0, /* 155 */}, +{ 0, /* 156 */}, +{ 0, /* 157 */}, +{ 0, /* 158 */}, +{ 0, /* 159 */}, +{ 0, /* 160 */}, +{ 0, /* 161 */}, +{ "fm","mt", /* 162 */}, +{ "<=", /* 163 */}, +{ "/","sl" /* 164 */}, +{ "if", /* 165 */}, +{ 0, /* 166 */}, +{ "Cc", /* 167 */}, +{ "Cd", /* 168 */}, +{ "Ch", /* 169 */}, +{ "Cs", /* 170 */}, +{ "<>", /* 171 */}, +{ "<-", /* 172 */}, +{ "ua", /* 173 */}, +{ "->", /* 174 */}, +{ "da", /* 175 */}, +{ "de", /* 176 */}, +{ "+-", /* 177 */}, +{ "sd", /* 178 */}, +{ ">=", /* 179 */}, +{ "mu", /* 180 */}, +{ "pt", /* 181 */}, +{ "pd", /* 182 */}, +{ "bu", /* 183 */}, +{ "di", /* 184 */}, +{ "!=", /* 185 */}, +{ "==", /* 186 */}, +{ "~=", /* 187 */}, +{ "..", /* 188 */}, +{ "br", /* 189 */}, +{ "em", /* 190 */}, +{ "cr", /* 191 */}, +{ "al", /* 192 */}, +{ 0, /* 193 */}, +{ 0, /* 194 */}, +{ 0, /* 195 */}, +{ "ax", /* 196 */}, +{ "a+", /* 197 */}, +{ "es", /* 198 */}, +{ "ca", /* 199 */}, +{ "cu", /* 200 */}, +{ "sp", /* 201 */}, +{ "ip", /* 202 */}, +{ "!s", /* 203 */}, +{ "sb", /* 204 */}, +{ "ib", /* 205 */}, +{ "mo", /* 206 */}, +{ "!m", /* 207 */}, +{ "ag", /* 208 */}, +{ "gr", /* 209 */}, +{ 0, /* 210 */}, +{ 0, /* 211 */}, +{ 0, /* 212 */}, +{ 0, /* 213 */}, +{ "sr", /* 214 */}, +{ "m.", /* 215 */}, +{ "no", /* 216 */}, +{ "an", /* 217 */}, +{ "lo", /* 218 */}, +{ "io", /* 219 */}, +{ "<:", /* 220 */}, +{ "u=", /* 221 */}, +{ ":>", /* 222 */}, +{ "d=", /* 223 */}, +{ "dm", /* 224 */}, +{ "L<", /* 225 */}, +{ "rg", /* 226 */}, +{ "co", /* 227 */}, +{ "tm", /* 228 */}, +{ 0, /* 229 */}, +{ 0, /* 230 */}, +{ 0, /* 231 */}, +{ 0, /* 232 */}, +{ "lc", /* 233 */}, +{ 0, /* 234 */}, +{ "lf", /* 235 */}, +{ "lt", /* 236 */}, +{ "lk", /* 237 */}, +{ "lb", /* 238 */}, +{ "bv", /* 239 */}, +{ "AL", /* 240 */}, +{ "R>", /* 241 */}, +{ "is", /* 242 */}, +{ 0, /* 243 */}, +{ 0, /* 244 */}, +{ 0, /* 245 */}, +{ 0, /* 246 */}, +{ 0, /* 247 */}, +{ 0, /* 248 */}, +{ "rc", /* 249 */}, +{ 0, /* 250 */}, +{ "rf", /* 251 */}, +{ "rt", /* 252 */}, +{ "rk", /* 253 */}, +{ "rb", /* 254 */}, +{ 0, /* 255 */}, +}, +{ +{ 0, 0 }, +} +}; + +static void +load_standard_maps () +{ + standard_maps_loaded = 1; + DviRegisterMap (&ISO8859_1_map); + DviRegisterMap (&Adobe_Symbol_map); +} + diff --git a/DviChar.h b/DviChar.h new file mode 100644 index 0000000..b5187b4 --- /dev/null +++ b/DviChar.h @@ -0,0 +1,49 @@ +/* + * DviChar.h + * + * descriptions for mapping dvi names to + * font indexes and back. Dvi fonts are all + * 256 elements (actually only 256-32 are usable). + * + * The encoding names are taken from X - + * case insensitive, a dash seperating the + * CharSetRegistry from the CharSetEncoding + */ +/* $XFree86: xc/programs/xditview/DviChar.h,v 1.2 2001/08/01 00:45:03 tsi Exp $ */ + +#ifndef _DVICHAR_H_ +#define _DVICHAR_H_ + +#include "Dvi.h" + +# define DVI_MAX_SYNONYMS 10 +# define DVI_MAP_SIZE 256 +# define DVI_HASH_SIZE 256 +# define DVI_MAX_LIGATURES 16 + +typedef struct _dviCharNameHash { + struct _dviCharNameHash *next; + char *name; + int position; +} DviCharNameHash; + +typedef struct _dviCharNameMap { + char *encoding; + int special; + char *dvi_names[DVI_MAP_SIZE][DVI_MAX_SYNONYMS]; + char *ligatures[DVI_MAX_LIGATURES][2]; + DviCharNameHash *buckets[DVI_HASH_SIZE]; +} DviCharNameMap; + +extern DviCharNameMap *DviFindMap (char *); +extern void DviRegisterMap (DviCharNameMap *); +#ifdef NOTDEF +extern char *DviCharName (DviCharNameMap *, int, int); +#else +#define DviCharName(map,index,synonym) ((map)->dvi_names[index][synonym]) +#endif +extern int DviCharIndex (DviCharNameMap *, char *); +extern unsigned char *DviCharIsLigature (DviCharNameMap *, char *); +extern void ResetFonts (DviWidget); + +#endif @@ -0,0 +1,293 @@ +/* + * $XConsortium: DviP.h,v 1.10 92/02/11 01:27:15 keith Exp $ + */ +/* $XFree86: xc/programs/xditview/DviP.h,v 1.5 2002/06/20 17:40:44 keithp Exp $ */ + +/* + * DviP.h - Private definitions for Dvi widget + */ + +#ifndef _XtDviP_h +#define _XtDviP_h + +#ifdef USE_XFT +#include <X11/Xft/Xft.h> +#endif + +#include "Dvi.h" +#include <X11/Xaw/SimpleP.h> +#include "DviChar.h" + +/*********************************************************************** + * + * Dvi Widget Private Data + * + ***********************************************************************/ + +/************************************ + * + * Class structure + * + ***********************************/ + +/* + * New fields for the Dvi widget class record + */ + +typedef struct _DviClass { + int makes_compiler_happy; /* not used */ +} DviClassPart; + +/* + * Full class record declaration + */ + +typedef struct _DviClassRec { + CoreClassPart core_class; + SimpleClassPart simple_class; + DviClassPart command_class; +} DviClassRec; + +extern DviClassRec dviClassRec; + +/*************************************** + * + * Instance (widget) structure + * + **************************************/ + +/* + * a list of fonts we've used for this widget + */ + +typedef struct _dviFontSizeList { + struct _dviFontSizeList *next; + int size; + char *x_name; +#ifdef USE_XFT + XftFont *font; + Bool core; +#else + XFontStruct *font; +#endif + int doesnt_exist; +} DviFontSizeList; + +typedef struct _dviFontList { + struct _dviFontList *next; + char *dvi_name; + char *x_name; + int dvi_number; + Boolean initialized; + Boolean scalable; + DviFontSizeList *sizes; + DviCharNameMap *char_map; +} DviFontList; + +typedef struct _dviFontMap { + struct _dviFontMap *next; + char *dvi_name; + char *x_name; +} DviFontMap; + +#define DVI_TEXT_CACHE_SIZE 256 +#define DVI_CHAR_CACHE_SIZE 1024 + +#ifdef USE_XFT +typedef struct _dviTextItem { + char *chars; + int nchars; + int x; + XftFont *font; +} DviTextItem; +#endif + +typedef struct _dviCharCache { +#ifdef USE_XFT + DviTextItem cache[DVI_TEXT_CACHE_SIZE]; +#else + XTextItem cache[DVI_TEXT_CACHE_SIZE]; +#endif + char char_cache[DVI_CHAR_CACHE_SIZE]; + int index; + int max; + int char_index; + int font_size; + int font_number; +#ifdef USE_XFT + XftFont *font; +#else + XFontStruct *font; +#endif + int start_x, start_y; + int x, y; +} DviCharCache; + +typedef struct _dviState { + struct _dviState *next; + int font_size; + int font_bound; + int font_number; + int line_style; + int line_width; + int x; + int y; +} DviState; + +typedef struct _dviFileMap { + struct _dviFileMap *next; + long position; + int page_number; +} DviFileMap; + +/* + * New fields for the Dvi widget record + */ + +typedef struct { + /* + * resource specifiable items + */ + char *font_map_string; + unsigned long foreground; + int requested_page; + int last_page; + FILE *file; + Boolean seek; /* file is "seekable" */ +#ifdef USE_XFT + XftFont *default_font; +#else + XFontStruct *default_font; +#endif + int backing_store; + Boolean noPolyText; + int screen_resolution; + float page_width; + float page_height; + int size_scale_set; + /* + * private state + */ + FILE *tmpFile; /* used when reading stdin */ + char readingTmp; /* reading now from tmp */ + char ungot; /* have ungetc'd a char */ + GC normal_GC; +#ifdef USE_XFT + XftDraw *draw; + XftColor black; +#endif + DviFileMap *file_map; + DviFontList *fonts; + DviFontMap *font_map; + int current_page; + int font_size; + int font_number; + int device_resolution; + int line_width; + int line_style; + int desired_width; + int desired_height; + int size_scale; /* font size scale */ +#ifdef USE_XFT + XftFont *font; +#else + XFontStruct *font; +#endif + int display_enable; + double scale; /* device coordinates to pixels */ + struct ExposedExtents { + int x1, y1, x2, y2; + } extents; + DviState *state; + DviCharCache cache; +} DviPart; + +extern int DviGetAndPut(DviWidget, int *); + +#define DviGetIn(dw,cp)\ + (dw->dvi.tmpFile ? (\ + DviGetAndPut (dw, cp) \ + ) :\ + (*cp = getc (dw->dvi.file))\ +) + +#define DviGetC(dw, cp)\ + (dw->dvi.readingTmp ? (\ + ((*cp = getc (dw->dvi.tmpFile)) == EOF) ? (\ + fseek (dw->dvi.tmpFile, 0l, 2),\ + (dw->dvi.readingTmp = 0),\ + DviGetIn (dw,cp)\ + ) : (\ + *cp\ + )\ + ) : (\ + DviGetIn(dw,cp)\ + )\ +) + +#define DviUngetC(dw, c)\ + (dw->dvi.readingTmp ? (\ + ungetc (c, dw->dvi.tmpFile)\ + ) : ( \ + (dw->dvi.ungot = 1),\ + ungetc (c, dw->dvi.file))) + +#define ToX(dw,device) ((int) ((device) * (dw)->dvi.scale + 0.5)) +#define ToDevice(dw,x) ((int) ((x) / (dw)->dvi.scale + 0.5)) +#define SizeScale(dw) ((dw)->dvi.size_scale ? (dw)->dvi.size_scale : 4) +#define FontSizeInPixels(dw,size) ((int) ((size) * (dw)->dvi.screen_resolution / (SizeScale(dw) * 72))) +#define FontSizeInDevice(dw,size) ((int) ((size) * (dw)->dvi.device_resolution / (SizeScale(dw) * 72))) + +/* + * Full widget declaration + */ + +typedef struct _DviRec { + CorePart core; + SimplePart simple; + DviPart dvi; +} DviRec; + +/* draw.c */ +extern void HorizontalMove(DviWidget, int); +extern void HorizontalGoto(DviWidget, int); +extern void VerticalMove(DviWidget, int); +extern void VerticalGoto(DviWidget, int); +extern void FlushCharCache(DviWidget); +extern void SetGCForDraw(DviWidget); +extern void DrawLine(DviWidget, int, int); +extern void DrawCircle(DviWidget, int); +extern void DrawEllipse(DviWidget, int, int); +extern void DrawArc(DviWidget, int, int, int, int); +extern void DrawSpline(DviWidget, char *, int); + +/* font.c */ +extern void ParseFontMap(DviWidget); +extern void DestroyFontMap(DviFontMap *); +extern void SetFontPosition(DviWidget, int, char *, char *); +#ifdef USE_XFT +extern XftFont * QueryFont(DviWidget, int, int); +#else +extern XFontStruct * QueryFont(DviWidget, int, int); +#endif +extern DviCharNameMap * QueryFontMap(DviWidget, int); + +/* lex.c */ +extern char * GetLine(DviWidget, char *, int); +extern char * GetWord(DviWidget, char *, int); +extern int GetNumber(DviWidget); + +/* page.c */ +extern void DestroyFileMap(DviFileMap *); +extern void ForgetPagePositions(DviWidget); +extern void RememberPagePosition(DviWidget, int); +extern long SearchPagePosition(DviWidget, int); +extern void FileSeek(DviWidget, long); + +/* parse.c */ +extern int ParseInput(DviWidget); + +/* Dvi.c */ +extern void SetDeviceResolution(DviWidget, int); + +#endif /* _XtDviP_h */ @@ -0,0 +1,46 @@ +/* + * $XConsortium: Menu.h,v 1.2 89/07/21 14:22:10 jim Exp $ + */ + +#ifndef _XtMenu_h +#define _XtMenu_h + +/*********************************************************************** + * + * Menu Widget + * + ***********************************************************************/ + +/* Parameters: + + Name Class RepType Default Value + ---- ----- ------- ------------- + background Background pixel White + border BorderColor pixel Black + borderWidth BorderWidth int 1 + height Height int 120 + mappedWhenManaged MappedWhenManaged Boolean True + reverseVideo ReverseVideo Boolean False + width Width int 120 + x Position int 0 + y Position int 0 + +*/ + +#define XtNmenuEntries "menuEntries" +#define XtNhorizontalPadding "horizontalPadding" +#define XtNverticalPadding "verticalPadding" +#define XtNselection "Selection" + +#define XtCMenuEntries "MenuEntries" +#define XtCPadding "Padding" +#define XtCSelection "Selection" + +typedef struct _MenuRec *MenuWidget; /* completely defined in MenuPrivate.h */ +typedef struct _MenuClassRec *MenuWidgetClass; /* completely defined in MenuPrivate.h */ + +extern WidgetClass menuWidgetClass; + +extern Widget XawMenuCreate (); +#endif /* _XtMenu_h */ +/* DON'T ADD STUFF AFTER THIS #endif */ diff --git a/XFontName.c b/XFontName.c new file mode 100644 index 0000000..2bbe118 --- /dev/null +++ b/XFontName.c @@ -0,0 +1,262 @@ +/* $XFree86: xc/programs/xditview/XFontName.c,v 1.3 2001/08/27 23:35:12 dawes Exp $ */ +/* + * XFontName.c + * + * build/parse X Font name strings + */ + +# include <X11/Xlib.h> +# include <X11/Intrinsic.h> +# include "XFontName.h" +#include <ctype.h> + +static char * +extractStringField ( + char *name, + char *buffer, + int size, + unsigned int *attrp, + unsigned int bit) +{ + char *buf = buffer; + + if (!*name) + return 0; + while (*name && *name != '-' && size > 0) { + *buf++ = *name++; + --size; + } + if (size <= 0) + return 0; + *buf = '\0'; + if (buffer[0] != '*' || buffer[1] != '\0') + *attrp |= bit; + if (*name == '-') + return name+1; + return name; +} + +static char * +extractUnsignedField ( + char *name, + unsigned int *result, + unsigned int *attrp, + unsigned int bit) +{ + char buf[256]; + char *c; + unsigned int i; + + name = extractStringField (name, buf, sizeof (buf), attrp, bit); + if (!name) + return 0; + if (!(*attrp & bit)) + return name; + i = 0; + for (c = buf; *c; c++) { + if (!isdigit (*c)) + return 0; + i = i * 10 + (*c - '0'); + } + *result = i; + return name; +} + +Bool +XParseFontName (fontNameString, fontName, fontNameAttributes) + XFontNameString fontNameString; + XFontName *fontName; + unsigned int *fontNameAttributes; +{ + char *name = fontNameString; + XFontName temp; + unsigned int attributes = 0; + +#define GetString(field,bit)\ + if (!(name = extractStringField \ + (name, temp.field, sizeof (temp.field),\ + &attributes, bit))) \ + return False; + +#define GetUnsigned(field,bit)\ + if (!(name = extractUnsignedField \ + (name, &temp.field, \ + &attributes, bit))) \ + return False; + + GetString (Registry, FontNameRegistry) + GetString (Foundry, FontNameFoundry) + GetString (FamilyName, FontNameFamilyName) + GetString (WeightName, FontNameWeightName) + GetString (Slant, FontNameSlant) + GetString (SetwidthName, FontNameSetwidthName) + GetString (AddStyleName, FontNameAddStyleName) + GetUnsigned (PixelSize, FontNamePixelSize) + GetUnsigned (PointSize, FontNamePointSize) + GetUnsigned (ResolutionX, FontNameResolutionX) + GetUnsigned (ResolutionY, FontNameResolutionY) + GetString (Spacing, FontNameSpacing) + GetUnsigned (AverageWidth, FontNameAverageWidth) + GetString (CharSetRegistry, FontNameCharSetRegistry) + if (!*name) { + temp.CharSetEncoding[0] = '\0'; + attributes |= FontNameCharSetEncoding; + } else { + GetString (CharSetEncoding, FontNameCharSetEncoding) + } + *fontName = temp; + *fontNameAttributes = attributes; + return True; +} + +static char * +utoa ( + unsigned int u, + char *s, + int size) +{ + char *t; + + t = s + size; + *--t = '\0'; + do + *--t = (u % 10) + '0'; + while (u /= 10); + return t; +} + +Bool +XFormatFontName (fontName, fontNameAttributes, fontNameString) + XFontName *fontName; + unsigned int fontNameAttributes; + XFontNameString fontNameString; +{ + XFontNameString tmp; + char *name = tmp, *f; + int left = sizeof (tmp) - 1; + char number[32]; + +#define PutString(field, bit)\ + f = (fontNameAttributes & bit) ? \ + fontName->field \ + : "*"; \ + if ((left -= strlen (f)) < 0) \ + return False; \ + while (*f) \ + if ((*name++ = *f++) == '-') \ + return False; +#define PutHyphen()\ + if (--left < 0) \ + return False; \ + *name++ = '-'; + +#define PutUnsigned(field, bit) \ + f = (fontNameAttributes & bit) ? \ + utoa (fontName->field, number, sizeof (number)) \ + : "*"; \ + if ((left -= strlen (f)) < 0) \ + return False; \ + while (*f) \ + *name++ = *f++; + + PutString (Registry, FontNameRegistry) + PutHyphen (); + PutString (Foundry, FontNameFoundry) + PutHyphen (); + PutString (FamilyName, FontNameFamilyName) + PutHyphen (); + PutString (WeightName, FontNameWeightName) + PutHyphen (); + PutString (Slant, FontNameSlant) + PutHyphen (); + PutString (SetwidthName, FontNameSetwidthName) + PutHyphen (); + PutString (AddStyleName, FontNameAddStyleName) + PutHyphen (); + PutUnsigned (PixelSize, FontNamePixelSize) + PutHyphen (); + PutUnsigned (PointSize, FontNamePointSize) + PutHyphen (); + PutUnsigned (ResolutionX, FontNameResolutionX) + PutHyphen (); + PutUnsigned (ResolutionY, FontNameResolutionY) + PutHyphen (); + PutString (Spacing, FontNameSpacing) + PutHyphen (); + PutUnsigned (AverageWidth, FontNameAverageWidth) + PutHyphen (); + PutString (CharSetRegistry, FontNameCharSetRegistry) + PutHyphen (); + PutString (CharSetEncoding, FontNameCharSetEncoding) + *name = '\0'; + strcpy (fontNameString, tmp); + return True; +} + +#if 0 +Bool +XCompareFontName ( + XFontName *name1, + XFontName *name2, + unsigned int fontNameAttributes) +{ +#define CompareString(field,bit) \ + if (fontNameAttributes & bit) \ + if (strcmp (name1->field, name2->field)) \ + return False; + +#define CompareUnsigned(field,bit) \ + if (fontNameAttributes & bit) \ + if (name1->field != name2->field) \ + return False; + + CompareString (Registry, FontNameRegistry) + CompareString (Foundry, FontNameFoundry) + CompareString (FamilyName, FontNameFamilyName) + CompareString (WeightName, FontNameWeightName) + CompareString (Slant, FontNameSlant) + CompareString (SetwidthName, FontNameSetwidthName) + CompareString (AddStyleName, FontNameAddStyleName) + CompareUnsigned (PixelSize, FontNamePixelSize) + CompareUnsigned (PointSize, FontNamePointSize) + CompareUnsigned (ResolutionX, FontNameResolutionX) + CompareUnsigned (ResolutionY, FontNameResolutionY) + CompareString (Spacing, FontNameSpacing) + CompareUnsigned (AverageWidth, FontNameAverageWidth) + CompareString (CharSetRegistry, FontNameCharSetRegistry) + CompareString (CharSetEncoding, FontNameCharSetEncoding) + return True; +} + +Bool +XCopyFontName ( + XFontName *name1, + XFontName *name2, + unsigned int fontNameAttributes) +{ +#define CopyString(field,bit) \ + if (fontNameAttributes & bit) \ + strcpy (name2->field, name1->field); + +#define CopyUnsigned(field,bit) \ + if (fontNameAttributes & bit) \ + name2->field = name1->field; + + CopyString (Registry, FontNameRegistry) + CopyString (Foundry, FontNameFoundry) + CopyString (FamilyName, FontNameFamilyName) + CopyString (WeightName, FontNameWeightName) + CopyString (Slant, FontNameSlant) + CopyString (SetwidthName, FontNameSetwidthName) + CopyString (AddStyleName, FontNameAddStyleName) + CopyUnsigned (PixelSize, FontNamePixelSize) + CopyUnsigned (PointSize, FontNamePointSize) + CopyUnsigned (ResolutionX, FontNameResolutionX) + CopyUnsigned (ResolutionY, FontNameResolutionY) + CopyString (Spacing, FontNameSpacing) + CopyUnsigned (AverageWidth, FontNameAverageWidth) + CopyString (CharSetRegistry, FontNameCharSetRegistry) + CopyString (CharSetEncoding, FontNameCharSetEncoding) + return True; +} +#endif diff --git a/XFontName.h b/XFontName.h new file mode 100644 index 0000000..f28c046 --- /dev/null +++ b/XFontName.h @@ -0,0 +1,55 @@ +/* $XFree86: xc/programs/xditview/XFontName.h,v 1.2 2001/08/01 00:45:03 tsi Exp $ */ + +#ifndef _XFONTNAME_H_ +#define _XFONTNAME_H_ + +typedef struct _xFontName { + char Registry[256]; + char Foundry[256]; + char FamilyName[256]; + char WeightName[256]; + char Slant[3]; + char SetwidthName[256]; + char AddStyleName[256]; + unsigned int PixelSize; + unsigned int PointSize; + unsigned int ResolutionX; + unsigned int ResolutionY; + char Spacing[2]; + unsigned int AverageWidth; + char CharSetRegistry[256]; + char CharSetEncoding[256]; +} XFontName; + +#define FontNameRegistry (1<<0) +#define FontNameFoundry (1<<1) +#define FontNameFamilyName (1<<2) +#define FontNameWeightName (1<<3) +#define FontNameSlant (1<<4) +#define FontNameSetwidthName (1<<5) +#define FontNameAddStyleName (1<<6) +#define FontNamePixelSize (1<<7) +#define FontNamePointSize (1<<8) +#define FontNameResolutionX (1<<9) +#define FontNameResolutionY (1<<10) +#define FontNameSpacing (1<<11) +#define FontNameAverageWidth (1<<12) +#define FontNameCharSetRegistry (1<<13) +#define FontNameCharSetEncoding (1<<14) + +#define SlantRoman "R" +#define SlantItalic "I" +#define SlantOblique "O" +#define SlantReverseItalic "RI" +#define SlantReverseOblique "RO" + +#define SpacingMonoSpaced "M" +#define SpacingProportional "P" +#define SpacingCharacterCell "C" + +typedef char XFontNameString[256]; + +extern Bool XParseFontName(XFontNameString, XFontName *, unsigned int *); +extern Bool XFormatFontName(XFontName *, unsigned int, XFontNameString); + +#endif diff --git a/Xditview-chrtr.ad b/Xditview-chrtr.ad new file mode 100644 index 0000000..345c190 --- /dev/null +++ b/Xditview-chrtr.ad @@ -0,0 +1,25 @@ +#include "Xditview" +*Dvi.fontMap:\ +R -*-charter-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +I -*-charter-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\ +B -*-charter-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +F -*-charter-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\ +BI -*-charter-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\ +C -*-courier-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +CO -*-courier-medium-o-normal--*-*-*-*-*-*-iso8859-1\n\ +CB -*-courier-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +CF -*-courier-bold-o-normal--*-*-*-*-*-*-iso8859-1\n\ +H -*-helvetica-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +HO -*-helvetica-medium-o-normal--*-*-*-*-*-*-iso8859-1\n\ +HB -*-helvetica-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +HF -*-helvetica-bold-o-normal--*-*-*-*-*-*-iso8859-1\n\ +N -*-new century schoolbook-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +NI -*-new century schoolbook-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\ +NB -*-new century schoolbook-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +NF -*-new century schoolbook-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\ +A -*-charter-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ +AI -*-charter-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\ +AB -*-charter-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ +AF -*-charter-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\ +S -*-symbol-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific\n\ +S2 -*-symbol-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific\n diff --git a/Xditview.ad b/Xditview.ad new file mode 100644 index 0000000..e20734d --- /dev/null +++ b/Xditview.ad @@ -0,0 +1,96 @@ +Xditview.geometry: 600x800 +*MenuButton*Font: -*-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-1 +*SimpleMenu*Font: -*-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-1 +*Text*Font: -*-courier-medium-r-normal--*-120-*-*-*-*-iso8859-1 + +*paned.allowResize: true +*paned.?.showGrip: false +*paned.?.skipAdjust: false +*paned.form.porthole.width: 600 +*paned.form.porthole.height: 800 +*paned.label.skipAdjust: true + +*MenuButton.shapeStyle: oval +*Command.shapeStyle: oval + +*fileMenuButton.label: File +*fileMenuButton.leftBitmap: menu12 +*fileMenuButton.menuName: fileMenu + +*fileMenu.openFile.label: Open File +*fileMenu.revisitFile.label: Reopen File +*fileMenu.setResolution.label: Set Screen Resolution +*fileMenu.quit.label: Quit + +*prevButton.bitmap: ldblarrow +*prevButton.internalHeight: 0 +*prevButton.Translations: #override <BtnUp>: PreviousPage() unset() + +*pageNumber.translations: #override\ + Ctrl<Key>J: SetPageNumber()\n\ + Ctrl<Key>M: SetPageNumber()\n\ + <Key>Linefeed: SetPageNumber()\n\ + <Key>Return: SetPageNumber()\n\ + Ctrl<Key>O: Noop()\n\ + Meta<Key>I: Noop()\n\ + Ctrl<Key>N: Noop()\n\ + Ctrl<Key>P: Noop()\n\ + Ctrl<Key>Z: Noop()\n\ + Meta<Key>Z: Noop()\n\ + <Key>space: NextPage()\n\ + Ctrl<Key>v: NextPage()\n\ + Meta<Key>v: PreviousPage()\n\ + <Key>Next: NextPage()\n\ + <Key>Prior: PreviousPage()\n\ + <Key>Find: OpenFile() +*pageNumber*editType: edit + +*nextButton.bitmap: rdblarrow +*nextButton.internalHeight: 0 +*nextButton.translations: #override <BtnUp>: NextPage() unset() + +*viewport.allowResize: false +*viewport.forceBars: true +*viewport.allowHoriz: true +*viewport.allowVert: true + +*dvi.translations: #augment \ + <Btn1Down>: XawPositionSimpleMenu(popupMenu) MenuPopup(popupMenu)\n\ + Ctrl<Key>v: NextPage()\n\ + Meta<Key>v: PreviousPage()\n\ + <Key>space: NextPage()\n\ + <Key>Next: NextPage()\n\ + <Key>Prior: PreviousPage()\n\ + <Key>Find: OpenFile() +*dvi.baseTranslations: #augment \ + <Btn1Down>: XawPositionSimpleMenu(popupMenu) MenuPopup(popupMenu)\n\ + <Key>space: NextPage()\n\ + Ctrl<Key>v: NextPage()\n\ + Meta<Key>v: PreviousPage()\n\ + <Key>Next: NextPage()\n\ + <Key>Prior: PreviousPage()\n\ + <Key>Find: OpenFile() +*popupMenu.nextPage.label: Next Page +*popupMenu.previousPage.label: Previous Page +*popupMenu.setResolution.label: Set Screen Resolution +*popupMenu.openFile.label: Open File +*popupMenu.revisitFile.label: Reopen File +*popupMenu.quit.label: Quit + +*promptShell.allowShellResize: true +*promptShell.promptDialog.value.translations: #override\ + <Key>Return: Accept() +*promptShell.promptDialog.value.baseTranslations: #override\ + <Key>Return: Accept() + +*promptShell.promptDialog.accept.label: Accept +*promptShell.promptDialog.accept.translations: #override\ + <BtnUp>: Accept() unset() +*promptShell.promptDialog.accept.baseTranslations: #override \ + <BtnUp>: Accept() unset() + +*promptShell.promptDialog.cancel.label: Cancel +*promptShell.promptDialog.cancel.translations: #override \ + <BtnUp>: Cancel() unset() +*promptShell.promptDialog.cancel.baseTranslations: #override \ + <BtnUp>: Cancel() unset() @@ -0,0 +1,546 @@ +/* + * $XConsortium: draw.c,v 1.8 94/04/17 20:43:35 gildea Exp $ + * $XFree86: xc/programs/xditview/draw.c,v 1.5 2001/08/27 23:35:12 dawes Exp $ + * +Copyright (c) 1991 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + * + */ + +/* + * draw.c + * + * accept dvi function calls and translate to X + */ + +/* + Support for ditroff drawing commands added: lines, circles, ellipses, + arcs and splines. Splines are approximated as short lines by iterating + a simple approximation algorithm. This seems good enough for previewing. + + David Evans <dre@cs.nott.ac.uk>, 14th March, 1990 +*/ + +#include <X11/Xos.h> +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <stdio.h> +#include <ctype.h> +#include <math.h> +#include "DviP.h" +#include <stdlib.h> + +#ifndef M_PI +#define M_PI 3.14159265358979323846264338327950 +#endif + +/* the following are for use in the spline approximation algorithm */ + +typedef struct Point { + double x; + double y; + struct Point *next; +} Point; + +#define ITERATIONS 10 /* iterations to approximate spline */ + +#define midx(p,q) ((p->x + q->x) / 2) /* mid x point on pq */ +#define midy(p,q) ((p->y + q->y) / 2) /* mid y point on pq */ + +#define length(p,q) sqrt(((q->x - p->x)*(q->x - p->x)) \ + + ((q->y - p->y)*(q->y - p->y))) /* length of pq */ + +Point *spline = (Point *)NULL; /* head of spline linked list */ + +static void ApproxSpline(int n); +static void DeletePoint(Point *p); +static void DrawSplineSegments(DviWidget dw); +static int GetSpline(char *s); +static void InsertPoint(Point *p, Point *q); +static void LineApprox(Point *p1, Point *p2, Point *p3); +static Point * MakePoint(double x, double y); + +void +HorizontalMove(dw, delta) + DviWidget dw; + int delta; +{ + dw->dvi.state->x += delta; +} + +void +HorizontalGoto(dw, NewPosition) + DviWidget dw; + int NewPosition; +{ + dw->dvi.state->x = NewPosition; +} + +void +VerticalMove(dw, delta) + DviWidget dw; + int delta; +{ + dw->dvi.state->y += delta; +} + +void +VerticalGoto(dw, NewPosition) + DviWidget dw; + int NewPosition; +{ + dw->dvi.state->y = NewPosition; +} + +#ifdef USE_XFT +static void +DrawText (DviWidget dw) +{ + int i; + XftFont *font; + + font = dw->dvi.cache.font; + for (i = 0; i <= dw->dvi.cache.index; i++) + { + if (dw->dvi.cache.cache[i].font) + font = dw->dvi.cache.cache[i].font; + XftDrawString8 (dw->dvi.draw, &dw->dvi.black, + font, + dw->dvi.cache.cache[i].x, + dw->dvi.cache.start_y, + (unsigned char *) dw->dvi.cache.cache[i].chars, + dw->dvi.cache.cache[i].nchars); + } +} +#endif + +void +FlushCharCache (dw) + DviWidget dw; +{ + int xx, yx; + + xx = ToX(dw, dw->dvi.state->x); + yx = ToX(dw, dw->dvi.state->y); + if (dw->dvi.cache.char_index != 0) + { +#ifdef USE_XFT + DrawText (dw); +#else + XDrawText (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, + dw->dvi.cache.start_x, dw->dvi.cache.start_y, + dw->dvi.cache.cache, dw->dvi.cache.index + 1); +#endif + } + dw->dvi.cache.index = 0; + dw->dvi.cache.max = DVI_TEXT_CACHE_SIZE; + if (dw->dvi.noPolyText) + dw->dvi.cache.max = 1; + dw->dvi.cache.char_index = 0; + dw->dvi.cache.cache[0].nchars = 0; + dw->dvi.cache.start_x = dw->dvi.cache.x = xx; + dw->dvi.cache.start_y = dw->dvi.cache.y = yx; +} + +#if 0 +void +ClearPage (DviWidget dw) +{ + if (dw->dvi.display_enable) + XClearWindow (XtDisplay (dw), XtWindow (dw)); +} +#endif + +void +SetGCForDraw (dw) + DviWidget dw; +{ + int lw; + if (dw->dvi.state->line_style != dw->dvi.line_style || + dw->dvi.state->line_width != dw->dvi.line_width) + { + lw = ToX(dw, dw->dvi.state->line_width); + if (lw <= 1) + lw = 0; + XSetLineAttributes (XtDisplay (dw), dw->dvi.normal_GC, + lw, LineSolid, CapButt, JoinMiter); + dw->dvi.line_style = dw->dvi.state->line_style; + dw->dvi.line_width = dw->dvi.state->line_width; + } +} + +void +DrawLine (dw, x, y) + DviWidget dw; + int x, y; +{ + if (dw->dvi.display_enable) + XDrawLine (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, + ToX(dw, dw->dvi.state->x), ToX(dw, dw->dvi.state->y), + ToX(dw, dw->dvi.state->x + x), ToX(dw,dw->dvi.state->y + y)); + dw->dvi.state->x += x; + dw->dvi.state->y += y; +} + +void +DrawCircle (dw, diameter) + DviWidget dw; + int diameter; +{ + if (dw->dvi.display_enable) + XDrawArc (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, + ToX(dw, dw->dvi.state->x), + ToX(dw, dw->dvi.state->y - (diameter / 2)), + ToX(dw, diameter), ToX(dw, diameter), 0, 360 * 64); + dw->dvi.state->x += diameter; +} + +void +DrawEllipse (dw, a, b) + DviWidget dw; + int a, b; +{ + if (dw->dvi.display_enable) + XDrawArc (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, + ToX(dw, dw->dvi.state->x), ToX(dw, dw->dvi.state->y - (b / 2)), + ToX(dw,a), ToX(dw,b), 0, 360 * 64); + dw->dvi.state->x += a; +} + + +/* Convert angle in degrees to 64ths of a degree */ + +static int +ConvertAngle(int theta) +{ + return(theta * 64); +} + +void +DrawArc (dw, x0, y0, x1, y1) + DviWidget dw; + int x0, y0, x1, y1; +{ + int xc, yc, x2, y2, r; + int angle1, angle2; + + /* centre */ + xc = dw->dvi.state->x + x0; + yc = dw->dvi.state->y + y0; + + /* to */ + x2 = xc + x1; + y2 = yc + y1; + + dw->dvi.state->x = x2; + dw->dvi.state->y = y2; + + if (dw->dvi.display_enable) { + + /* radius */ + r = (int)sqrt((float) x1 * x1 + (float) y1 * y1); + + /* start and finish angles */ + if (x0 == 0) { + if (y0 >= 0) + angle1 = 90; + else + angle1 = 270; + } + else { + angle1 = (int) (atan((double)(y0) / (double)(x0)) * 180 / M_PI); + if (x0 > 0) + angle1 = 180 - angle1; + else + angle1 = -angle1; + } + + if (x1 == 0) { + if (y1 <= 0) + angle2 = 90; + else + angle2 = 270; + } + else { + angle2 = (int) (atan((double)(y1) / (double)(x1)) * 180 / M_PI); + if (x1 < 0) + angle2 = 180 - angle2; + else + angle2 = -angle2; + } + + if (angle1 < 0) + angle1 += 360; + if (angle2 < 0) + angle2 += 360; + + if (angle2 < angle1) + angle1 -= 360; + angle2 = angle2 - angle1; + + angle1 = ConvertAngle(angle1); + angle2 = ConvertAngle(angle2); + + XDrawArc (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, + ToX(dw, xc - r), ToX(dw, yc - r), + ToX(dw, 2 * r), ToX(dw, 2 * r), + angle1, angle2); + } +} + +/* copy next non-blank string from p to temp, update p */ + +static char * +getstr(char *p, char *temp) +{ + while (*p == ' ' || *p == '\t' || *p == '\n') + p++; + if (*p == '\0') { + temp[0] = 0; + return((char *)NULL); + } + while (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\0') + *temp++ = *p++; + *temp = '\0'; + return(p); +} + + +/* Draw a spline by approximating with short lines. */ + +/*ARGSUSED*/ +void +DrawSpline (dw, s, len) + DviWidget dw; + char *s; + int len; +{ + int n; + + /* get coordinate pairs into spline linked list */ + if ((n = GetSpline(s)) <= 0) + return; + + ApproxSpline(n); + + DrawSplineSegments(dw); +} + + +/* Parse string s to create a linked list of Point's with spline */ +/* as its head. Return the number of coordinate pairs found. */ + +static int +GetSpline(s) + char *s; +{ + double x, y, x1, y1; + int n = 0; + Point *pt; + char *p = s, d[10]; + + if (!*p) + return(n); + + pt = spline = MakePoint(0.0, 0.0); + n = 1; + x = y = 0.0; + p = s; + while (p && *p) { + if ((p = getstr(p, d)) == (char *)NULL) + break; + x1 = x + atof(d); + if ((p = getstr(p, d)) == (char *)NULL) + break; + y1 = y + atof(d); + pt->next = MakePoint(x1, y1); + pt = pt->next; + x = pt->x; + y = pt->y; + n++; + } + + /* number of pairs of points */ + + return(n); +} + +/* Approximate a spline by lines generated by iterations of the */ +/* approximation algorithm from the original n points in the spline. */ + +static void +ApproxSpline(n) +int n; +{ + int mid, j; + Point *p1, *p2, *p3, *p; + + if (n < 3) + return; + + /* number of mid-points to calculate */ + mid = n - 3; + + /* remember original points are stored as an array of n points */ + /* so I can index it directly to calculate mid-points only. */ + if (mid > 0) { + p = spline->next; + j = 1; + while (j < n-2) { + p1 = p; + p = p->next; + p2 = p; + InsertPoint(p1, MakePoint(midx(p1, p2), midy(p1, p2))); + j++; + } + } + + /* Now approximate curve by line segments. */ + /* There *should* be the correct number of points now! */ + + p = spline; + while (p != (Point *)NULL) { + p1 = p; + if ((p = p->next) == (Point *)NULL) + break; + p2 = p; + if ((p = p->next) == (Point *)NULL) + break; + p3 = p; /* This point becomes first point of next curve */ + + LineApprox(p1, p2, p3); + } +} + + +/* p1, p2, and p3 are initially 3 *consecutive* points on the curve. */ +/* For each adjacent pair of points find the mid-point, insert this */ +/* in the linked list, delete the first of the two used (unless it */ +/* is the first for this curve). Repeat this ITERATIONS times. */ + +/*ARGSUSED*/ +static void +LineApprox(p1, p2, p3) +Point *p1, *p2, *p3; +{ + Point *p4, *p; + int reps = ITERATIONS; + + while (reps) { + for (p = p1; p != (Point *)NULL && p != p3; ) { + InsertPoint(p, p4 = MakePoint( midx(p,p->next), midy(p,p->next) )); + if (p != p1) + DeletePoint(p); + p = p4->next; /* skip inserted point! */ + } + reps--; + } +} + + +/* Traverse the linked list, calling DrawLine to approximate the */ +/* spline curve. Rounding errors are taken into account so that */ +/* the "curve" is continuous, and ends up where expected. */ + +static void +DrawSplineSegments(dw) +DviWidget dw; +{ + Point *p, *q; + double x1, y1; + int dx, dy; + double xpos, ypos; + + p = spline; + dx = dy = 0; + + /* save the start position */ + + xpos = dw->dvi.state->x; + ypos = dw->dvi.state->y; + + x1 = y1 = 0.0; + + while (p != (Point *)NULL) { + dx = p->x - x1 + 0.5; + dy = p->y - y1 + 0.5; + DrawLine (dw, dx, dy); + + x1 = p->x; + y1 = p->y; + dw->dvi.state->x = xpos + x1; + dw->dvi.state->y = ypos + y1; + + q = p; + p = p->next; + XtFree((char *)q); + } + spline = (Point *)NULL; +} + + +/* Malloc memory for a Point, and initialise the elements to x, y, NULL */ +/* Return a pointer to the new Point. */ + +static Point * +MakePoint(x, y) +double x, y; +{ + Point *p; + + p = (Point *) XtMalloc (sizeof (Point)); + p->x = x; + p->y = y; + p->next = (Point *)NULL; + + return(p); +} + + +/* Insert point q in linked list after point p. */ + +static void +InsertPoint(p, q) +Point *p, *q; +{ + /* point q to the next point */ + q->next = p->next; + + /* point p to new inserted one */ + p->next = q; +} + +/* Delete point p from the linked list. */ + +static void +DeletePoint(p) +Point *p; +{ + Point *tmp; + + tmp = p->next; + p->x = p->next->x; + p->y = p->next->y; + p->next = p->next->next; + XtFree((char *)tmp); +} @@ -0,0 +1,486 @@ +/* + * font.c + * + * map dvi fonts to X fonts + */ +/* $XFree86: xc/programs/xditview/font.c,v 1.6 2002/06/19 20:09:19 keithp Exp $ */ + +#include <X11/Xos.h> +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> +#include "DviP.h" +#include "XFontName.h" + +static char * +savestr (char *s) +{ + char *n; + + if (!s) + return 0; + n = XtMalloc (strlen (s) + 1); + if (n) + strcpy (n, s); + return n; +} + +static DviFontList * +LookupFontByPosition (DviWidget dw, int position) +{ + DviFontList *f; + + for (f = dw->dvi.fonts; f; f=f->next) + if (f->dvi_number == position) + break; + return f; +} + +static DviFontSizeList * +LookupFontSizeBySize (DviWidget dw, DviFontList *f, int size) +{ + DviFontSizeList *fs, *best = 0; + int bestdist; + char fontNameString[2048]; + XFontName fontName; + unsigned int fontNameAttributes; + int dist; + + if (f->scalable) + { + for (best = f->sizes; best; best = best->next) + if (best->size == size) + return best; + best = (DviFontSizeList *) XtMalloc (sizeof *best); + best->next = f->sizes; + best->size = size; + XParseFontName (f->x_name, &fontName, &fontNameAttributes); + fontNameAttributes &= ~(FontNamePixelSize|FontNameAverageWidth); + fontNameAttributes |= FontNameResolutionX; + fontNameAttributes |= FontNameResolutionY; + fontNameAttributes |= FontNamePointSize; + fontName.ResolutionX = dw->dvi.screen_resolution; + fontName.ResolutionY = dw->dvi.screen_resolution; + fontName.PointSize = size * 10 / dw->dvi.size_scale; + XFormatFontName (&fontName, fontNameAttributes, fontNameString); + best->x_name = savestr (fontNameString); +#ifdef USE_XFT + /* + * Force a match of a core font for adobe-fontspecific + * encodings; we dont have a scalable font in + * the right encoding + */ + best->core = False; + if (!strcmp (fontName.CharSetRegistry, "adobe") && + !strcmp (fontName.CharSetEncoding, "fontspecific")) + { + best->core = True; + } +#endif + best->doesnt_exist = 0; + best->font = 0; + f->sizes = best; + } + else + { + bestdist = 65536; + for (fs = f->sizes; fs; fs=fs->next) { + dist = size - fs->size; + if (dist < 0) + dist = -dist * 16; + if (dist < bestdist) + { + best = fs; + bestdist = dist; + } + } + } + return best; +} + +static char * +SkipFontNameElement (char *n) +{ + while (*n != '-') + if (!*++n) + return 0; + return n+1; +} + +# define SizePosition 8 +# define EncodingPosition 13 + +#ifndef USE_XFT +static int +ConvertFontNameToSize (char *n) +{ + int i, size; + + for (i = 0; i < SizePosition; i++) { + n = SkipFontNameElement (n); + if (!n) + return -1; + } + size = atoi (n); + return size/10; +} +#endif + +static char * +ConvertFontNameToEncoding (char *n) +{ + int i; + for (i = 0; i < EncodingPosition; i++) { + n = SkipFontNameElement (n); + if (!n) + return 0; + } + return n; +} + +static void +DisposeFontSizes (DviWidget dw, DviFontSizeList *fs) +{ + DviFontSizeList *next; + + for (; fs; fs=next) { + next = fs->next; + if (fs->x_name) + XtFree (fs->x_name); + if (fs->font) + { +#ifdef USE_XFT + XftFontClose (XtDisplay (dw), fs->font); +#else + XUnloadFont (XtDisplay (dw), fs->font->fid); + XFree ((char *)fs->font); +#endif + } + XtFree ((char *) fs); + } +} + +void +ResetFonts (DviWidget dw) +{ + DviFontList *f; + + for (f = dw->dvi.fonts; f; f = f->next) + { + if (f->initialized) + { + DisposeFontSizes (dw, f->sizes); + f->sizes = 0; + f->initialized = FALSE; + f->scalable = FALSE; + } + } + /* + * force requery of fonts + */ + dw->dvi.font = 0; + dw->dvi.font_number = -1; + dw->dvi.cache.font = 0; + dw->dvi.cache.font_number = -1; +} + +static DviFontSizeList * +InstallFontSizes (DviWidget dw, char *x_name, Boolean *scalablep) +{ +#ifndef USE_XFT + char fontNameString[2048]; + char **fonts; + int i, count; + int size; + DviFontSizeList *new; + XFontName fontName; + unsigned int fontNameAttributes; +#endif + DviFontSizeList *sizes; + + sizes = 0; +#ifdef USE_XFT + *scalablep = TRUE; +#else + *scalablep = FALSE; + if (!XParseFontName (x_name, &fontName, &fontNameAttributes)) + return 0; + + fontNameAttributes &= ~(FontNamePixelSize|FontNamePointSize); + fontNameAttributes |= FontNameResolutionX; + fontNameAttributes |= FontNameResolutionY; + fontName.ResolutionX = dw->dvi.screen_resolution; + fontName.ResolutionY = dw->dvi.screen_resolution; + XFormatFontName (&fontName, fontNameAttributes, fontNameString); + fonts = XListFonts (XtDisplay (dw), fontNameString, 10000000, &count); + for (i = 0; i < count; i++) { + size = ConvertFontNameToSize (fonts[i]); + if (size == 0) + { + DisposeFontSizes (dw, sizes); + *scalablep = TRUE; + sizes = 0; + break; + } + if (size != -1) { + new = (DviFontSizeList *) XtMalloc (sizeof *new); + new->next = sizes; + new->size = size; + new->x_name = savestr (fonts[i]); + new->doesnt_exist = 0; + new->font = 0; + sizes = new; + } + } + XFreeFontNames (fonts); +#endif + return sizes; +} + +static DviFontList * +InstallFont (DviWidget dw, int position, char *dvi_name, char *x_name) +{ + DviFontList *f; + char *encoding; + + f = LookupFontByPosition (dw, position); + if (f) { + /* + * ignore gratuitous font loading + */ + if (!strcmp (f->dvi_name, dvi_name) && !strcmp (f->x_name, x_name)) + return f; + + DisposeFontSizes (dw, f->sizes); + if (f->dvi_name) + XtFree (f->dvi_name); + if (f->x_name) + XtFree (f->x_name); + } else { + f = (DviFontList *) XtMalloc (sizeof (*f)); + f->next = dw->dvi.fonts; + dw->dvi.fonts = f; + } + f->initialized = FALSE; + f->dvi_name = savestr (dvi_name); + f->x_name = savestr (x_name); + f->dvi_number = position; + f->sizes = 0; + f->scalable = FALSE; + if (f->x_name) { + encoding = ConvertFontNameToEncoding (f->x_name); + f->char_map = DviFindMap (encoding); + } else + f->char_map = 0; + /* + * force requery of fonts + */ + dw->dvi.font = 0; + dw->dvi.font_number = -1; + dw->dvi.cache.font = 0; + dw->dvi.cache.font_number = -1; + return f; +} + +static char * +MapDviNameToXName (DviWidget dw, char *dvi_name) +{ + DviFontMap *fm; + + for (fm = dw->dvi.font_map; fm; fm=fm->next) + if (!strcmp (fm->dvi_name, dvi_name)) + return fm->x_name; + ++dvi_name; + for (fm = dw->dvi.font_map; fm; fm=fm->next) + if (!strcmp (fm->dvi_name, "R")) + return fm->x_name; + if (dw->dvi.font_map->x_name) + return dw->dvi.font_map->x_name; + return "-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-1"; +} + +#ifdef NOTUSED +static char * +MapXNameToDviName (dw, x_name) + DviWidget dw; + char *x_name; +{ + DviFontMap *fm; + + for (fm = dw->dvi.font_map; fm; fm=fm->next) + if (!strcmp (fm->x_name, x_name)) + return fm->dvi_name; + return 0; +} +#endif + +void +ParseFontMap (dw) + DviWidget dw; +{ + char dvi_name[1024]; + char x_name[2048]; + char *m, *s; + DviFontMap *fm, *new; + + if (dw->dvi.font_map) + DestroyFontMap (dw->dvi.font_map); + fm = 0; + m = dw->dvi.font_map_string; + while (*m) { + s = m; + while (*m && !isspace (*m)) + ++m; + strncpy (dvi_name, s, m-s); + dvi_name[m-s] = '\0'; + while (isspace (*m)) + ++m; + s = m; + while (*m && *m != '\n') + ++m; + strncpy (x_name, s, m-s); + x_name[m-s] = '\0'; + new = (DviFontMap *) XtMalloc (sizeof *new); + new->x_name = savestr (x_name); + new->dvi_name = savestr (dvi_name); + new->next = fm; + fm = new; + ++m; + } + dw->dvi.font_map = fm; +} + +void +DestroyFontMap (font_map) + DviFontMap *font_map; +{ + DviFontMap *next; + + for (; font_map; font_map = next) { + next = font_map->next; + if (font_map->x_name) + XtFree (font_map->x_name); + if (font_map->dvi_name) + XtFree (font_map->dvi_name); + XtFree ((char *) font_map); + } +} + +/*ARGSUSED*/ +void +SetFontPosition (dw, position, dvi_name, extra) + DviWidget dw; + int position; + char *dvi_name; + char *extra; /* unused */ +{ + char *x_name; + + x_name = MapDviNameToXName (dw, dvi_name); + (void) InstallFont (dw, position, dvi_name, x_name); +} + +#ifdef USE_XFT +XftFont * +#else +XFontStruct * +#endif +QueryFont (dw, position, size) + DviWidget dw; + int position; + int size; +{ + DviFontList *f; + DviFontSizeList *fs; + + f = LookupFontByPosition (dw, position); + if (!f) + return dw->dvi.default_font; + if (!f->initialized) { + f->sizes = InstallFontSizes (dw, f->x_name, &f->scalable); + f->initialized = TRUE; + } + fs = LookupFontSizeBySize (dw, f, size); + if (!fs) + return dw->dvi.default_font; + if (!fs->font) { + if (fs->x_name) + { +#ifdef USE_XFT + XftPattern *pat; + XftPattern *match; + XftResult result; + + pat = XftXlfdParse (fs->x_name, False, False); + XftPatternAddBool (pat, XFT_CORE, fs->core); + match = XftFontMatch (XtDisplay (dw), + XScreenNumberOfScreen(dw->core.screen), + pat, &result); + XftPatternDestroy (pat); + if (match) + { + fs->font = XftFontOpenPattern (XtDisplay (dw), + match); + if (!fs->font) + XftPatternDestroy (match); + } + else + fs->font = 0; +#else + fs->font = XLoadQueryFont (XtDisplay (dw), fs->x_name); +#endif + } + if (!fs->font) + fs->font = dw->dvi.default_font; + } + return fs->font; +} + +DviCharNameMap * +QueryFontMap (dw, position) + DviWidget dw; + int position; +{ + DviFontList *f; + + f = LookupFontByPosition (dw, position); + if (f) + return f->char_map; + else + return 0; +} + +unsigned char * +DviCharIsLigature (map, name) + DviCharNameMap *map; + char *name; +{ + int i; + + for (i = 0; i < DVI_MAX_LIGATURES; i++) { + if (!map->ligatures[i][0]) + break; + if (!strcmp (name, map->ligatures[i][0])) + return (unsigned char *) map->ligatures[i][1]; + } + return 0; +} + +#if 0 +LoadFont (dw, position, size) + DviWidget dw; + int position; + int size; +{ + XFontStruct *font; + + font = QueryFont (dw, position, size); + dw->dvi.font_number = position; + dw->dvi.font_size = size; + dw->dvi.font = font; + XSetFont (XtDisplay (dw), dw->dvi.normal_GC, font->fid); + return; +} +#endif diff --git a/ldblarrow b/ldblarrow new file mode 100644 index 0000000..48bbeb0 --- /dev/null +++ b/ldblarrow @@ -0,0 +1,5 @@ +#define previous_width 11 +#define previous_height 11 +static char previous_bits[] = { + 0x20, 0x04, 0x10, 0x02, 0x08, 0x01, 0x84, 0x00, 0x42, 0x00, 0x21, 0x00, + 0x42, 0x00, 0x84, 0x00, 0x08, 0x01, 0x10, 0x02, 0x20, 0x04}; @@ -0,0 +1,92 @@ +/* $XFree86: xc/programs/xditview/lex.c,v 1.4 2001/08/01 00:45:03 tsi Exp $ */ + +#include <X11/Xos.h> +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <stdio.h> +#include <ctype.h> +#include "DviP.h" + +int +DviGetAndPut(dw, cp) + DviWidget dw; + int *cp; +{ + if (dw->dvi.ungot) + { + dw->dvi.ungot = 0; + *cp = getc (dw->dvi.file); + } + else + { + *cp = getc (dw->dvi.file); + putc (*cp, dw->dvi.tmpFile); + } + return *cp; +} + +char * +GetLine(dw, Buffer, Length) + DviWidget dw; + char *Buffer; + int Length; +{ + int i = 0, c; + char *p = Buffer; + + Length--; /* Save room for final NULL */ + + while ((!p || i < Length) && DviGetC (dw, &c) != EOF && c != '\n') + if (p) + *p++ = c; +#if 0 + if (c == '\n' && p) /* Retain the newline like fgets */ + *p++ = c; +#endif + if (c == '\n') + DviUngetC(dw, c); + if (p) + *p = '\0'; + return (Buffer); +} + +char * +GetWord(dw, Buffer, Length) + DviWidget dw; + char *Buffer; + int Length; +{ + int i = 0, c; + char *p = Buffer; + + Length--; /* Save room for final NULL */ + while (DviGetC(dw, &c) != EOF && isspace(c)) + ; + if (c != EOF) + DviUngetC(dw, c); + while (i < Length && DviGetC(dw, &c) != EOF && !isspace(c)) + if (p) + *p++ = c; + if (c != EOF) + DviUngetC(dw, c); + if (p) + *p = '\0'; + return (Buffer); +} + +int +GetNumber(dw) + DviWidget dw; +{ + int i = 0, c; + + while (DviGetC(dw, &c) != EOF && isspace(c)) + ; + if (c != EOF) + DviUngetC(dw, c); + while (DviGetC(dw, &c) != EOF && isdigit(c)) + i = i*10 + c - '0'; + if (c != EOF) + DviUngetC(dw, c); + return (i); +} @@ -0,0 +1,90 @@ +/* $XConsortium: page.c,v 1.5 91/07/26 00:40:20 keith Exp $ */ +/* $XFree86: xc/programs/xditview/page.c,v 1.4 2001/08/27 23:35:12 dawes Exp $ */ + +/* + * page.c + * + * map page numbers to file position + */ + +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <X11/Xos.h> +#include <stdio.h> +#include <ctype.h> +#include "DviP.h" + +static DviFileMap * +MapPageNumberToFileMap (DviWidget dw, int number) +{ + DviFileMap *m; + + for (m = dw->dvi.file_map; m; m=m->next) + if (m->page_number == number) + break; + return m; +} + +void +DestroyFileMap (m) + DviFileMap *m; +{ + DviFileMap *next; + + for (; m; m = next) { + next = m->next; + XtFree ((char *) m); + } +} + +void +ForgetPagePositions (dw) + DviWidget dw; +{ + DestroyFileMap (dw->dvi.file_map); + dw->dvi.file_map = 0; +} + +void +RememberPagePosition(dw, number) + DviWidget dw; + int number; +{ + DviFileMap *m; + + if (!(m = MapPageNumberToFileMap (dw, number))) { + m = (DviFileMap *) XtMalloc (sizeof *m); + m->page_number = number; + m->next = dw->dvi.file_map; + dw->dvi.file_map = m; + } + if (dw->dvi.tmpFile) + m->position = ftell (dw->dvi.tmpFile); + else + m->position = ftell (dw->dvi.file); +} + +long +SearchPagePosition (dw, number) + DviWidget dw; + int number; +{ + DviFileMap *m; + + if (!(m = MapPageNumberToFileMap (dw, number))) + return -1; + return m->position; +} + +void +FileSeek(dw, position) +DviWidget dw; +long position; +{ + if (dw->dvi.tmpFile) { + dw->dvi.readingTmp = 1; + fseek (dw->dvi.tmpFile, position, 0); + } else + fseek (dw->dvi.file, position, 0); +} + @@ -0,0 +1,479 @@ +/* $XConsortium: parse.c,v 1.13 94/04/17 20:43:36 keith Exp $ */ +/* + +Copyright (c) 1991 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ +/* $XFree86: xc/programs/xditview/parse.c,v 1.5 2001/08/27 23:35:12 dawes Exp $ */ + +/* + * parse.c + * + * parse dvi input + */ + +#include <X11/Xos.h> +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <stdio.h> +#include <ctype.h> +#include "DviP.h" + +static int StopSeen = 0; +static void ParseDrawFunction(DviWidget dw, char *buf); +static void ParseDeviceControl(DviWidget dw); +static void PutCharacters(DviWidget dw, unsigned char *src, int len); +static void push_env(DviWidget dw); +static void pop_env(DviWidget dw); + +#define HorizontalMove(dw, delta) ((dw)->dvi.state->x += (delta)) + +#ifdef USE_XFT +static int +charWidth (DviWidget dw, XftFont *font, char c) +{ + XGlyphInfo extents; + + XftTextExtents8 (XtDisplay (dw), font, + (unsigned char *) &c, 1, &extents); + return extents.xOff; +} +#else +#define charWidth(dw,fi,c) (\ + (fi)->per_char ?\ + (fi)->per_char[(c) - (fi)->min_char_or_byte2].width\ + :\ + (fi)->max_bounds.width\ +) +#endif + +int +ParseInput(dw) + DviWidget dw; +{ + int n, k; + int c; + char Buffer[BUFSIZ]; + int NextPage; + int prevFont; + int otherc; + unsigned char tc; + + StopSeen = 0; + + /* + * make sure some state exists + */ + + if (!dw->dvi.state) + push_env (dw); + for (;;) { + switch (DviGetC(dw, &c)) { + case '\n': + break; + case ' ': /* when input is text */ + case 0: /* occasional noise creeps in */ + break; + case '{': /* push down current environment */ + push_env(dw); + break; + case '}': + pop_env(dw); + break; + /* + * two motion digits plus a character + */ + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + HorizontalMove(dw, (c-'0')*10 + + DviGetC(dw,&otherc)-'0'); + /* fall through */ + case 'c': /* single ascii character */ + (void) DviGetC(dw,&c); + if (c == ' ') + break; + tc = c; + PutCharacters (dw, &tc, 1); + break; + case 'C': + GetWord(dw, Buffer, BUFSIZ); + { + DviCharNameMap *map; + int i; + unsigned char *ligature; + + c = -1; + map = QueryFontMap (dw, dw->dvi.state->font_number); + if (map) + { + c = DviCharIndex (map, Buffer); + if (c == -1) + { + ligature = DviCharIsLigature (map, Buffer); + if (ligature) { + i = strlen ((char *) ligature); + PutCharacters (dw, ligature, i); + break; + } + } + } + prevFont = -1; + if (c == -1) { + for (i = 1; (map = QueryFontMap (dw, i)); i++) + if (map->special) + if ((c = DviCharIndex (map, Buffer)) != -1) { + prevFont = dw->dvi.state->font_number; + dw->dvi.state->font_number = i; + break; + } + } + if (c != -1) + { + tc = c; + PutCharacters (dw, &tc, 1); + } + if (prevFont != -1) + dw->dvi.state->font_number = prevFont; + } + break; + case 'D': /* draw function */ + GetLine(dw, Buffer, BUFSIZ); + ParseDrawFunction(dw, Buffer); + break; + case 's': /* ignore fractional sizes */ + n = GetNumber(dw); + if (!dw->dvi.size_scale) + { + static int guesses[] = { 1, 4, 100, 1000, 1 }; + int i; + + for (i = 0; i < 4; i++) + if (8 <= n/guesses[i] && n/guesses[i] <= 24) + { + break; + } + dw->dvi.size_scale = guesses[i]; + } + dw->dvi.state->font_size = n; + dw->dvi.state->line_width = n * (dw->dvi.device_resolution / + (720 * dw->dvi.size_scale)); + break; + case 'f': + n = GetNumber(dw); + dw->dvi.state->font_number = n; + break; + case 'H': /* absolute horizontal motion */ + k = GetNumber(dw); + HorizontalGoto(dw, k); + break; + case 'h': /* relative horizontal motion */ + k = GetNumber(dw); + HorizontalMove(dw, k); + break; + case 'w': /* word space */ + break; + case 'V': + n = GetNumber(dw); + VerticalGoto(dw, n); + break; + case 'v': + n = GetNumber(dw); + VerticalMove(dw, n); + break; + case 'P': /* new spread */ + break; + case 'p': /* new page */ + (void) GetNumber(dw); + NextPage = dw->dvi.current_page + 1; + RememberPagePosition(dw, NextPage); + FlushCharCache (dw); + return(NextPage); + case 'n': /* end of line */ + GetNumber(dw); + GetNumber(dw); + HorizontalGoto(dw, 0); + break; + case '#': /* comment */ + case 'F': /* file info */ + GetLine(dw, NULL, 0); + break; + case 't': /* text */ + GetLine(dw, Buffer, BUFSIZ); + PutCharacters (dw, (unsigned char *)Buffer, + strlen (Buffer)); + dw->dvi.state->x = ToDevice (dw, dw->dvi.cache.x); + break; + case 'x': /* device control */ + ParseDeviceControl(dw); + break; + case EOF: + dw->dvi.last_page = dw->dvi.current_page; + FlushCharCache (dw); + return dw->dvi.current_page; + default: + GetLine (dw, Buffer, BUFSIZ); + fprintf (stderr, "Unknown command %s\n", Buffer); + break; + } + } +} + +static void +push_env(dw) + DviWidget dw; +{ + DviState *new; + + new = (DviState *) XtMalloc (sizeof (*new)); + if (dw->dvi.state) + *new = *(dw->dvi.state); + else { + new->font_size = 10 * dw->dvi.size_scale; + new->font_number = 1; + new->line_style = 0; + new->line_width = 10; + new->x = 0; + new->y = 0; + } + new->next = dw->dvi.state; + dw->dvi.state = new; +} + +static void +pop_env(dw) + DviWidget dw; +{ + DviState *old; + + old = dw->dvi.state; + dw->dvi.state = old->next; + XtFree ((char *) old); +} + +static void +InitTypesetter (DviWidget dw) +{ + while (dw->dvi.state) + pop_env (dw); + dw->dvi.size_scale = dw->dvi.size_scale_set; + push_env (dw); + FlushCharCache (dw); +} + +static void +SetFont (DviWidget dw) +{ + dw->dvi.cache.font_size = dw->dvi.state->font_size; + dw->dvi.cache.font_number = dw->dvi.state->font_number; + dw->dvi.cache.font = QueryFont (dw, + dw->dvi.cache.font_number, + dw->dvi.cache.font_size); +} + +static void +PutCharacters (dw, src, len) + DviWidget dw; + unsigned char *src; + int len; +{ + int xx, yx; + int fx, fy; + char *dst; + int c; + + xx = ToX(dw, dw->dvi.state->x); + yx = ToX(dw, dw->dvi.state->y); + fy = FontSizeInPixels (dw, dw->dvi.state->font_size); + fx = fy * len; + /* + * quick and dirty extents calculation: + */ + if (yx + fy >= dw->dvi.extents.y1 && + yx - fy <= dw->dvi.extents.y2 && + xx + fx >= dw->dvi.extents.x1 && + xx - fx <= dw->dvi.extents.x2) + { +#ifdef USE_XFT + XftFont *font; + DviTextItem *text; +#else + register XFontStruct *font; + register XTextItem *text; +#endif + + if (!dw->dvi.display_enable) + return; + + if (yx != dw->dvi.cache.y || + dw->dvi.cache.char_index + len > DVI_CHAR_CACHE_SIZE) + FlushCharCache (dw); + /* + * load a new font, if the current block is not empty, + * step to the next. + */ + if (dw->dvi.cache.font_size != dw->dvi.state->font_size || + dw->dvi.cache.font_number != dw->dvi.state->font_number) + { + SetFont (dw); + if (dw->dvi.cache.cache[dw->dvi.cache.index].nchars != 0) { + ++dw->dvi.cache.index; + if (dw->dvi.cache.index >= dw->dvi.cache.max) + FlushCharCache (dw); + dw->dvi.cache.cache[dw->dvi.cache.index].nchars = 0; + } + } + if (xx != dw->dvi.cache.x) { + if (dw->dvi.cache.cache[dw->dvi.cache.index].nchars != 0) { + ++dw->dvi.cache.index; + if (dw->dvi.cache.index >= dw->dvi.cache.max) + FlushCharCache (dw); + dw->dvi.cache.cache[dw->dvi.cache.index].nchars = 0; + } + } + if (!dw->dvi.cache.font) + SetFont (dw); + text = &dw->dvi.cache.cache[dw->dvi.cache.index]; + font = dw->dvi.cache.font; + dst = &dw->dvi.cache.char_cache[dw->dvi.cache.char_index]; + if (text->nchars == 0) { + text->chars = dst; +#ifdef USE_XFT + text->x = xx; +#else + text->delta = xx - dw->dvi.cache.x; +#endif +#ifdef USE_XFT + text->font = font; +#endif + if (font != dw->dvi.font) { +#ifndef USE_XFT + text->font = font->fid; +#endif + dw->dvi.font = font; + } +#ifndef USE_XFT + else + text->font = None; +#endif + dw->dvi.cache.x = xx; + } + dw->dvi.cache.char_index += len; + text->nchars += len; + while (len--) + { + c = *src++; + *dst++ = c; + if (font) + dw->dvi.cache.x += charWidth(dw,font,c); + } + } +} + +static void +ParseDrawFunction(dw, buf) + DviWidget dw; + char *buf; +{ + int n, m, n1, m1; + + SetGCForDraw (dw); + switch (buf[0]) { + case 'l': /* draw a line */ + sscanf(buf+1, "%d %d", &n, &m); + DrawLine(dw, n, m); + break; + case 'c': /* circle */ + sscanf(buf+1, "%d", &n); + DrawCircle(dw, n); + break; + case 'e': /* ellipse */ + sscanf(buf+1, "%d %d", &m, &n); + DrawEllipse(dw, m, n); + break; + case 'a': /* arc */ + sscanf(buf+1, "%d %d %d %d", &n, &m, &n1, &m1); + DrawArc(dw, n, m, n1, m1); + break; + case '~': /* wiggly line */ + DrawSpline(dw, buf+1,1); + break; + case 't': /* line width */ + sscanf(buf+1, "%d", &n); + dw->dvi.state->line_width = n; + break; + case 's': /* line style */ + sscanf(buf+1, "%d", &n); + /* XXX */ + break; + default: + /* warning("unknown drawing function %s", buf); */ + break; + } +} + +extern int LastPage, CurrentPage; + +static void +ParseDeviceControl(dw) /* Parse the x commands */ + DviWidget dw; +{ + char str[20], str1[50]; + int c, n; + + GetWord (dw, str, 20); + switch (str[0]) { /* crude for now */ + case 'T': /* output device */ + GetWord(dw, str, 20); + break; + case 'i': /* initialize */ + InitTypesetter (dw); + break; + case 't': /* trailer */ + break; + case 'p': /* pause -- can restart */ + break; + case 's': /* stop */ + StopSeen = 1; + return; + case 'r': /* resolution when prepared */ + SetDeviceResolution (dw, GetNumber (dw)); + break; + case 'f': /* font used */ + n = GetNumber(dw); + GetWord(dw, str, 20); + GetLine(dw, str1, 50); + SetFontPosition(dw, n, str, str1); + break; + case 'H': /* char height */ + break; + case 'S': /* slant */ + break; + } + while (DviGetC(dw,&c) != '\n') /* skip rest of input line */ + if (c == EOF) + return; +} diff --git a/rdblarrow b/rdblarrow new file mode 100644 index 0000000..19140c7 --- /dev/null +++ b/rdblarrow @@ -0,0 +1,5 @@ +#define next_width 11 +#define next_height 11 +static char next_bits[] = { + 0x21, 0x00, 0x42, 0x00, 0x84, 0x00, 0x08, 0x01, 0x10, 0x02, 0x20, 0x04, + 0x10, 0x02, 0x08, 0x01, 0x84, 0x00, 0x42, 0x00, 0x21, 0x00}; @@ -0,0 +1,14 @@ +#define xdit_width 32 +#define xdit_height 32 +static unsigned char xdit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x03, 0x02, 0x00, 0x00, 0x02, + 0x8a, 0xa2, 0xfc, 0x03, 0x52, 0x14, 0x03, 0x04, 0x02, 0x80, 0x00, 0x08, + 0x52, 0x54, 0x00, 0x10, 0x8a, 0x22, 0x8f, 0x23, 0x02, 0x20, 0x06, 0x21, + 0x8a, 0x12, 0x8c, 0x40, 0x52, 0x14, 0x8c, 0x40, 0x02, 0x10, 0x58, 0x40, + 0x52, 0x14, 0x30, 0x40, 0x8a, 0x12, 0x30, 0x40, 0x02, 0x10, 0x70, 0x40, + 0x8a, 0x12, 0xc8, 0x40, 0x52, 0x24, 0xc4, 0xe0, 0x02, 0x20, 0x84, 0xe1, + 0x52, 0x54, 0xce, 0xf3, 0x8a, 0xa2, 0x00, 0xf8, 0x02, 0x00, 0x03, 0xfc, + 0x8a, 0x22, 0xfc, 0xf3, 0x52, 0x14, 0x00, 0xc2, 0x02, 0x00, 0x00, 0x02, + 0x52, 0x14, 0x45, 0x02, 0x8a, 0xa2, 0x28, 0x02, 0x02, 0x00, 0x00, 0x02, + 0x02, 0x00, 0x00, 0x02, 0xfe, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/xdit_mask.bm b/xdit_mask.bm new file mode 100644 index 0000000..a584629 --- /dev/null +++ b/xdit_mask.bm @@ -0,0 +1,14 @@ +#define xdit_mask_width 32 +#define xdit_mask_height 32 +static unsigned char xdit_mask_bits[] = { + 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, + 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0x1f, + 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xc7, + 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, + 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/xditview.c b/xditview.c new file mode 100644 index 0000000..6060c8f --- /dev/null +++ b/xditview.c @@ -0,0 +1,655 @@ +/* $XConsortium: xditview.c,v 1.32 94/04/17 20:43:36 eswu Exp $ */ +/* + +Copyright (c) 1991 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ +/* $XFree86: xc/programs/xditview/xditview.c,v 1.4 2001/08/27 23:35:12 dawes Exp $ */ +/* + * xditview -- + * + * Display ditroff output in an X window + */ + +#include <X11/Intrinsic.h> +#include <X11/StringDefs.h> +#include <X11/Xatom.h> +#include <X11/Shell.h> +#include <X11/Xos.h> /* rindex declaration */ +#include <X11/Xaw/Paned.h> +#include <X11/Xaw/Panner.h> +#include <X11/Xaw/Porthole.h> +#include <X11/Xaw/Viewport.h> +#include <X11/Xaw/Box.h> +#include <X11/Xaw/Command.h> +#include <X11/Xaw/Dialog.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/SimpleMenu.h> +#include <X11/Xaw/SmeBSB.h> +#include <X11/Xaw/AsciiText.h> + +#include "Dvi.h" + +#include "xdit.bm" +#include "xdit_mask.bm" +#include <stdio.h> +#include <stdlib.h> + +/* Command line options table. Only resources are entered here...there is a + pass over the remaining options after XtParseCommand is let loose. */ + +static XrmOptionDescRec options[] = { +{"-page", "*dvi.pageNumber", XrmoptionSepArg, NULL}, +{"-backingStore", "*dvi.backingStore", XrmoptionSepArg, NULL}, +{"-noPolyText", "*dvi.noPolyText", XrmoptionNoArg, "TRUE"}, +{"-resolution", "*dvi.screenResolution",XrmoptionSepArg, NULL}, +}; + +static char current_file_name[1024]; +static FILE *current_file; + +static void MakePrompt(Widget, char *, void (*)(char *), char *); + +/* + * Report the syntax for calling xditview. + */ + +static void +Syntax(char *call) +{ + (void) printf ("Usage: %s [-fg <color>] [-bg <color>]\n", call); + (void) printf (" [-bd <color>] [-bw <pixels>] [-help]\n"); + (void) printf (" [-display displayname] [-geometry geom]\n"); + (void) printf (" [-page <page-number>] [-backing <backing-store>]\n"); + (void) printf (" [-resolution <screen-resolution>]\n\n"); + exit(1); +} + +static void NewResolution (char *resString); +static void NewFile (char *name); +static void DisplayPageNumber (void); +static void VisitFile (char *name, Boolean resetPage); +static Widget toplevel, paned, porthole, dvi; +#ifdef NOTDEF +static Widget form, panner; +#endif +static Widget popupMenu; +static Widget menuBar; +static Widget fileMenuButton, fileMenu; +static Widget prevButton, pageNumber, nextButton; + +static void NextPage(Widget entry, XtPointer name, XtPointer data); +static void PreviousPage(Widget entry, XtPointer name, XtPointer data); +static void SetResolution(Widget entry, XtPointer name, XtPointer data); +static void OpenFile(Widget entry, XtPointer name, XtPointer data); +static void RevisitFile(Widget entry, XtPointer name, XtPointer data); +static void Quit(Widget entry, XtPointer closure, XtPointer data); + +struct menuEntry { + char *name; + void (*function)(Widget entry, XtPointer name, XtPointer data); +}; + +static struct menuEntry popupMenuEntries[] = { + { "nextPage", NextPage }, + { "previousPage", PreviousPage }, + { "setResolution", SetResolution }, + { "openFile", OpenFile }, + { "revisitFile", RevisitFile }, + { "quit", Quit } +}; + +static struct menuEntry fileMenuEntries[] = { + { "openFile", OpenFile }, + { "revisitFile", RevisitFile }, + { "setResolution", SetResolution }, + { "quit", Quit } +}; + +static void NextPageAction(Widget, XEvent *, String *, Cardinal *); +static void PreviousPageAction(Widget, XEvent *, String *, Cardinal *); +static void SetResolutionAction(Widget, XEvent *, String *, Cardinal *); +static void OpenFileAction(Widget, XEvent *, String *, Cardinal *); +static void RevisitFileAction(Widget, XEvent *, String *, Cardinal *); +static void QuitAction(Widget, XEvent *, String *, Cardinal *); +static void AcceptAction(Widget, XEvent *, String *, Cardinal *); +static void CancelAction(Widget, XEvent *, String *, Cardinal *); +static void UpdatePageNumber(Widget, XEvent *, String *, Cardinal *); +static void Noop(Widget, XEvent *, String *, Cardinal *); + +XtActionsRec xditview_actions[] = { + { "NextPage", NextPageAction }, + { "PreviousPage", PreviousPageAction }, + { "SetResolution", SetResolutionAction }, + { "OpenFile", OpenFileAction }, + { "Quit", QuitAction }, + { "Accept", AcceptAction }, + { "Cancel", CancelAction }, + { "SetPageNumber", UpdatePageNumber }, + { "Noop", Noop } +}; + +static Atom wm_delete_window; + +#ifdef NOTDEF +/* Function Name: PannerCallback + * Description: called when the panner has moved. + * Arguments: panner - the panner widget. + * closure - *** NOT USED ***. + * report_ptr - the panner record. + * Returns: none. + */ + +/* ARGSUSED */ +static void +PannerCallback(Widget w, XtPointer closure, XtPointer report_ptr) +{ + Arg args[2]; + XawPannerReport *report = (XawPannerReport *) report_ptr; + + if (!dvi) + return; + XtSetArg (args[0], XtNx, -report->slider_x); + XtSetArg (args[1], XtNy, -report->slider_y); + + XtSetValues(dvi, args, 2); +} + +/* Function Name: PortholeCallback + * Description: called when the porthole or its child has + * changed + * Arguments: porthole - the porthole widget. + * panner_ptr - the panner widget. + * report_ptr - the porthole record. + * Returns: none. + */ + +/* ARGSUSED */ +static void +PortholeCallback(Widget w, XtPointer panner_ptr, XtPointer report_ptr) +{ + Arg args[10]; + Cardinal n = 0; + XawPannerReport *report = (XawPannerReport *) report_ptr; + Widget panner = (Widget) panner_ptr; + + XtSetArg (args[n], XtNsliderX, report->slider_x); n++; + XtSetArg (args[n], XtNsliderY, report->slider_y); n++; + if (report->changed != (XawPRSliderX | XawPRSliderY)) { + XtSetArg (args[n], XtNsliderWidth, report->slider_width); n++; + XtSetArg (args[n], XtNsliderHeight, report->slider_height); n++; + XtSetArg (args[n], XtNcanvasWidth, report->canvas_width); n++; + XtSetArg (args[n], XtNcanvasHeight, report->canvas_height); n++; + } + XtSetValues (panner, args, n); +} +#endif + +int +main(int argc, char **argv) +{ + char *file_name = 0; + int i; + XtAppContext xtcontext; + Arg topLevelArgs[2]; + Widget entry; + + XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL); + + toplevel = XtAppInitialize(&xtcontext, "Xditview", + options, XtNumber (options), + &argc, argv, NULL, NULL, 0); + if (argc > 2) + Syntax(argv[0]); + + XtAppAddActions(xtcontext, xditview_actions, XtNumber (xditview_actions)); + XtOverrideTranslations + (toplevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: Quit()")); + + XtSetArg (topLevelArgs[0], XtNiconPixmap, + XCreateBitmapFromData (XtDisplay (toplevel), + XtScreen(toplevel)->root, + (char *) xdit_bits, + xdit_width, xdit_height)); + + XtSetArg (topLevelArgs[1], XtNiconMask, + XCreateBitmapFromData (XtDisplay (toplevel), + XtScreen(toplevel)->root, + (char *) xdit_mask_bits, + xdit_mask_width, xdit_mask_height)); + XtSetValues (toplevel, topLevelArgs, 2); + if (argc > 1) + file_name = argv[1]; + + /* + * create the popup menu and insert the entries + */ + popupMenu = XtCreatePopupShell ("popupMenu", simpleMenuWidgetClass, toplevel, + NULL, 0); + for (i = 0; i < XtNumber (popupMenuEntries); i++) { + entry = XtCreateManagedWidget(popupMenuEntries[i].name, + smeBSBObjectClass, popupMenu, + NULL, (Cardinal) 0); + XtAddCallback(entry, XtNcallback, popupMenuEntries[i].function, NULL); + } + + paned = XtCreateManagedWidget("paned", panedWidgetClass, toplevel, + NULL, (Cardinal) 0); + menuBar = XtCreateManagedWidget ("menuBar", boxWidgetClass, paned, 0, 0); + + fileMenuButton = XtCreateManagedWidget ("fileMenuButton", menuButtonWidgetClass, + menuBar, NULL, (Cardinal) 0); + fileMenu = XtCreatePopupShell ("fileMenu", simpleMenuWidgetClass, + fileMenuButton, NULL, (Cardinal) 0); + for (i = 0; i < XtNumber (fileMenuEntries); i++) { + entry = XtCreateManagedWidget(fileMenuEntries[i].name, + smeBSBObjectClass, fileMenu, + NULL, (Cardinal) 0); + XtAddCallback (entry, XtNcallback, fileMenuEntries[i].function, NULL); + } + + prevButton = XtCreateManagedWidget ("prevButton", commandWidgetClass, + menuBar, NULL, (Cardinal) 0); + + pageNumber = XtCreateManagedWidget("pageNumber", asciiTextWidgetClass, + menuBar, NULL, (Cardinal) 0); + + nextButton = XtCreateManagedWidget ("nextButton", commandWidgetClass, + menuBar, NULL, (Cardinal) 0); + +#ifdef NOTDEF + form = XtCreateManagedWidget ("form", formWidgetClass, paned, + NULL, (Cardinal) 0); + panner = XtCreateManagedWidget ("panner", pannerWidgetClass, + form, NULL, 0); + porthole = XtCreateManagedWidget ("porthole", portholeWidgetClass, + form, NULL, 0); + XtAddCallback(porthole, + XtNreportCallback, PortholeCallback, (XtPointer) panner); + XtAddCallback(panner, + XtNreportCallback, PannerCallback, (XtPointer) porthole); +#else + porthole = XtCreateManagedWidget ("viewport", viewportWidgetClass, + paned, NULL, 0); +#endif + dvi = XtCreateManagedWidget ("dvi", dviWidgetClass, porthole, NULL, 0); + if (file_name) + VisitFile (file_name, FALSE); + XtRealizeWidget (toplevel); + wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", + False); + (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel), + &wm_delete_window, 1); + XtAppMainLoop(xtcontext); + + return 0; +} + +static void +DisplayPageNumber () +{ + Arg arg[2]; + int actual_number, last_page; + XawTextBlock text; + int length; + char value[128]; + char *cur; + + XtSetArg (arg[0], XtNpageNumber, &actual_number); + XtSetArg (arg[1], XtNlastPageNumber, &last_page); + XtGetValues (dvi, arg, 2); + if (actual_number == 0) + sprintf (value, "<none>"); + else if (last_page > 0) + sprintf (value, "%d of %d", actual_number, last_page); + else + sprintf (value, "%d", actual_number); + text.firstPos = 0; + text.length = strlen (value); + text.ptr = value; + text.format = FMT8BIT; + XtSetArg (arg[0], XtNstring, &cur); + XtGetValues (XawTextGetSource (pageNumber), arg, 1); + length = strlen (cur); + XawTextReplace (pageNumber, 0, length, &text); +} + +static void +SetPageNumber (int number) +{ + Arg arg[1]; + + XtSetArg (arg[0], XtNpageNumber, number); + XtSetValues (dvi, arg, 1); + DisplayPageNumber (); +} + +static void +UpdatePageNumber (Widget w, XEvent *xev, String *s, Cardinal *c) +{ + char *string; + Arg arg[1]; + + XtSetArg (arg[0], XtNstring, &string); + XtGetValues (XawTextGetSource(pageNumber), arg, 1); + SetPageNumber (atoi(string)); +} + +static void +NewResolution(resString) +char *resString; +{ + int res; + Arg arg[1]; + + res = atoi (resString); + if (res <= 0) + return; + XtSetArg (arg[0], XtNscreenResolution, res); + XtSetValues (dvi, arg, 1); +} + +static void +VisitFile (char *name, Boolean resetPage) +{ + Arg arg[3]; + char *n; + FILE *new_file; + Boolean seek = 0; + int i; + + if (current_file) { + if (!strcmp (current_file_name, "-")) + ; + else if (current_file_name[0] == '|') + pclose (current_file); + else + fclose (current_file); + } + if (!strcmp (name, "-")) + new_file = stdin; + else if (name[0] == '|') + new_file = popen (name+1, "r"); + else { + new_file = fopen (name, "r"); + seek = 1; + } + if (!new_file) { + /* XXX display error message */ + return; + } + i = 0; + XtSetArg (arg[i], XtNfile, new_file); i++; + XtSetArg (arg[i], XtNseek, seek); i++; + if (resetPage) { + XtSetArg (arg[i], XtNpageNumber, 1); i++; + } + XtSetValues (dvi, arg, i); + XtSetArg (arg[0], XtNtitle, name); + if (name[0] != '/' && (n = rindex (name, '/'))) + n = n + 1; + else + n = name; + XtSetArg (arg[1], XtNiconName, n); + XtSetValues (toplevel, arg, 2); + strcpy (current_file_name, name); + current_file = new_file; + DisplayPageNumber (); +} + +static void +NewFile (name) +char *name; +{ + VisitFile (name, TRUE); +} + +static char fileBuf[1024]; +static char resolutionBuf[1024]; + +static void +ResetMenuEntry (Widget entry) +{ + Arg arg[1]; + + XtSetArg (arg[0], XtNpopupOnEntry, entry); + XtSetValues (XtParent(entry) , arg, (Cardinal) 1); +} + +/*ARGSUSED*/ +static void +NextPage (entry, name, data) + Widget entry; + XtPointer name, data; +{ + NextPageAction(entry, NULL, NULL, NULL); + ResetMenuEntry (entry); +} + +static void +NextPageAction (Widget w, XEvent *xev, String *s, Cardinal *c) +{ + Arg args[1]; + int number; + + XtSetArg (args[0], XtNpageNumber, &number); + XtGetValues (dvi, args, 1); + SetPageNumber (number+1); +} + +/*ARGSUSED*/ +static void +PreviousPage (entry, name, data) + Widget entry; + XtPointer name, data; +{ + PreviousPageAction (entry, NULL, NULL, NULL); + ResetMenuEntry (entry); +} + +static void +PreviousPageAction (Widget w, XEvent *xev, String *s, Cardinal *c) +{ + Arg args[1]; + int number; + + XtSetArg (args[0], XtNpageNumber, &number); + XtGetValues (dvi, args, 1); + SetPageNumber (number-1); +} + +/*ARGSUSED*/ +static void +SetResolution (entry, name, data) + Widget entry; + XtPointer name, data; +{ + SetResolutionAction (entry, NULL, NULL, NULL); + ResetMenuEntry (entry); +} + +static void +SetResolutionAction (Widget w, XEvent *xev, String *s, Cardinal *c) +{ + Arg args[1]; + int cur; + + XtSetArg (args[0], XtNscreenResolution, &cur); + XtGetValues (dvi, args, 1); + sprintf (resolutionBuf, "%d", cur); + MakePrompt (toplevel, "Screen resolution:", NewResolution, resolutionBuf); +} + +/*ARGSUSED*/ +static void +OpenFile (entry, name, data) + Widget entry; + XtPointer name, data; +{ + OpenFileAction (entry, NULL, NULL, NULL); + ResetMenuEntry (entry); +} + +static void +OpenFileAction (Widget w, XEvent *xev, String *s, Cardinal *c) +{ + if (current_file_name[0]) + strcpy (fileBuf, current_file_name); + else + fileBuf[0] = '\0'; + MakePrompt (toplevel, "File to open:", NewFile, fileBuf); +} + +/*ARGSUSED*/ +static void +RevisitFile (entry, name, data) + Widget entry; + XtPointer name, data; +{ + RevisitFileAction (entry, NULL, NULL, NULL); + ResetMenuEntry (entry); +} + +static void +RevisitFileAction (Widget w, XEvent *xev, String *s, Cardinal *c) +{ + if (current_file_name[0]) + VisitFile (current_file_name, FALSE); +} + +/*ARGSUSED*/ +static void +Quit (entry, closure, data) + Widget entry; + XtPointer closure, data; +{ + QuitAction (entry, NULL, NULL, NULL); +} + +static void +QuitAction (Widget w, XEvent *xev, String *s, Cardinal *c) +{ + exit (0); +} + +Widget promptShell, promptDialog; +void (*promptfunction)(char *); + +/* ARGSUSED */ +static +void CancelAction (widget, event, params, num_params) + Widget widget; + XEvent *event; + String *params; + Cardinal *num_params; +{ + if (promptShell) { + XtSetKeyboardFocus(toplevel, (Widget) None); + XtDestroyWidget(promptShell); + promptShell = (Widget) 0; + } +} + + +/* ARGSUSED */ +static +void AcceptAction (widget, event, params, num_params) + Widget widget; + XEvent *event; + String *params; + Cardinal *num_params; +{ + (*promptfunction)(XawDialogGetValueString(promptDialog)); + CancelAction (widget, event, params, num_params); +} + +static +void Noop (Widget w, XEvent *xev, String *s, Cardinal *c) +{ +} + +static void +MakePrompt(centerw, prompt, func, def) +Widget centerw; +char *prompt; +void (*func)(char *); +char *def; +{ + static Arg dialogArgs[] = { + {XtNlabel, (XtArgVal) 0}, + {XtNvalue, (XtArgVal) 0}, + }; + Arg valueArgs[1]; + Arg centerArgs[2]; + Position source_x, source_y; + Position dest_x, dest_y; + Dimension center_width, center_height; + Dimension prompt_width, prompt_height; + Widget valueWidget; + + CancelAction ((Widget)NULL, (XEvent *) 0, (String *) 0, (Cardinal *) 0); + promptShell = XtCreatePopupShell ("promptShell", transientShellWidgetClass, + toplevel, NULL, (Cardinal) 0); + dialogArgs[0].value = (XtArgVal)prompt; + dialogArgs[1].value = (XtArgVal)def; + promptDialog = XtCreateManagedWidget( "promptDialog", dialogWidgetClass, + promptShell, dialogArgs, XtNumber (dialogArgs)); + XawDialogAddButton(promptDialog, "accept", NULL, NULL); + XawDialogAddButton(promptDialog, "cancel", NULL, NULL); + valueWidget = XtNameToWidget (promptDialog, "value"); + if (valueWidget) { + XtSetArg (valueArgs[0], XtNresizable, TRUE); + XtSetValues (valueWidget, valueArgs, 1); + /* + * as resizable isn't set until just above, the + * default value will be displayed incorrectly. + * rectify the situation by resetting the values + */ + XtSetValues (promptDialog, dialogArgs, XtNumber (dialogArgs)); + } + XtSetKeyboardFocus (promptDialog, valueWidget); + XtSetKeyboardFocus (toplevel, valueWidget); + XtRealizeWidget (promptShell); + /* + * place the widget in the center of the "parent" + */ + XtSetArg (centerArgs[0], XtNwidth, ¢er_width); + XtSetArg (centerArgs[1], XtNheight, ¢er_height); + XtGetValues (centerw, centerArgs, 2); + XtSetArg (centerArgs[0], XtNwidth, &prompt_width); + XtSetArg (centerArgs[1], XtNheight, &prompt_height); + XtGetValues (promptShell, centerArgs, 2); + source_x = (int)(center_width - prompt_width) / 2; + source_y = (int)(center_height - prompt_height) / 3; + XtTranslateCoords (centerw, source_x, source_y, &dest_x, &dest_y); + XtSetArg (centerArgs[0], XtNx, dest_x); + XtSetArg (centerArgs[1], XtNy, dest_y); + XtSetValues (promptShell, centerArgs, 2); + XtMapWidget(promptShell); + promptfunction = func; +} diff --git a/xditview.man b/xditview.man new file mode 100644 index 0000000..3e3f59e --- /dev/null +++ b/xditview.man @@ -0,0 +1,177 @@ +.\" $XConsortium: xditview.man,v 1.10 94/04/17 20:43:37 gildea Exp $ +.\" +.\" $XFree86: xc/programs/xditview/xditview.man,v 1.3 2001/01/27 18:21:10 dawes Exp $ +.\" +.TH XDITVIEW 1 __xorgversion__ +.SH NAME +xditview \- display ditroff output +.SH SYNOPSIS +.B xditview +[ \-\fItoolkitoption\fP .\|.\|. ] [ \-\fIoption\fP .\|.\|. ] [ \fIfilename\fP ] +.SH DESCRIPTION +The +.I xditview +program displays +.I ditroff +output on an X display. It uses no special +metrics and automatically converts the printer coordinates into screen +coordinates; using the user-specified screen resolution, rather than the +actual resolution so that the appropriate fonts can be found. If +``\fB\-\fP'' is given as the +.I filename, +.I xditview +reads from standard input. +If ``\fB|\fP'' is the first character of +.I filename, +.I xditview +forks +.I sh +to run the rest of the ``file name'' and uses the +standard output of that command. +.SH OPTIONS +.I Xditview +accepts all of the standard X Toolkit command line options along with the +additional options listed below: +.TP 8 +.B \-page \fIpage-number\fP +This option specifies the page number of the document to be displayed at +start up time. +.TP 8 +.B \-resolution \fIscreen-resolution\fP +This specifies the desired screen resolution to use; fonts will be opened by +requesting this resolution field in the XLFD names. +.TP 8 +.B \-noPolyText +Some X servers incorrectly implement PolyText with multiple strings +per request. This option suppesses the use of this feature in +.I xditview. +.TP 8 +.B \-backingStore \fIbacking-store-type\fP +Redisplay can take up to a second or so; this option causes +the server to save the window contents so that when it is scrolled around the +viewport, the window is painted from contents saved in backing store. +\fIbacking-store-type\fP can be one of \fBAlways\fP, \fPWhenMapped\fP or +\fPNotUseful\fP. +.PP +The following standard X Toolkit command line arguments are commonly used with +.I xditview: +.TP 8 +.B \-bg \fIcolor\fP +This option specifies the color to use for the background of the window. +The default is \fIwhite\fP. +.TP 8 +.B \-bd \fIcolor\fP +This option specifies the color to use for the border of the window. +The default is \fIblack\fP. +.TP 8 +.B \-bw \fInumber\fP +This option specifies the width in pixels of the border surrounding the window. +.TP 8 +.B \-fg \fIcolor\fP +This option specifies the color to use for displaying text. The default is +\fIblack\fP. +.TP 8 +.B \-fn \fIfont\fP +This option specifies the font to be used for displaying widget text. The +default is \fIfixed\fP. +.TP 8 +.B \-rv +This option indicates that reverse video should be simulated by swapping +the foreground and background colors. +.TP 8 +.B \-geometry \fIgeometry\fP +This option specifies the preferred size and position of the window. +.TP 8 +.B \-display \fIhost\fP:\fIdisplay\fP +This option specifies the X server to contact. +.TP 8 +.B \-xrm \fIresourcestring\fP +This option specifies a resource string to be used. +.SH X DEFAULTS +This program uses a +.I Dvi +widget. It understands all of the core resource names and +classes as well as: +.PP +.TP 8 +.B width (\fPclass\fB Width) +Specifies the width of the window. +.TP 8 +.B height (\fPclass\fB Height) +Specifies the height of the window. +.TP 8 +.B foreground (\fPclass\fB Foreground) +Specifies the default foreground color. +.TP 8 +.B font (\fPclass\fB Font) +Specifies the font to be used for error messages. +.TP 8 +.B FontMap (\fBclass\fB FontMap) +To associate the +.I ditroff +fonts with appropriate X fonts, this string +resource contains a set of new-line separated specifications, each of which +consists of a ditroff name, some white space and an XLFD pattern with * +characters in appropriate places to allow all sizes to be listed. The +default fontMap is: +.nf +.sp +R \-*\-times\-medium\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +I \-*\-times\-medium\-i\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +B \-*\-times\-bold\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +F \-*\-times\-bold\-i\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +BI \-*\-times\-bold\-i\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +C \-*\-courier\-medium\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +CO \-*\-courier\-medium\-o\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +CB \-*\-courier\-bold\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +CF \-*\-courier\-bold\-o\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +H \-*\-helvetica\-medium\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +HO \-*\-helvetica\-medium\-o\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +HB \-*\-helvetica\-bold\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +HF \-*\-helvetica\-bold\-o\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +N \-*\-new century schoolbook\-medium\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +NI \-*\-new century schoolbook\-medium\-i\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +NB \-*\-new century schoolbook\-bold\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +NF \-*\-new century schoolbook\-bold\-i\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +A \-*\-charter\-medium\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +AI \-*\-charter\-medium\-i\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +AB \-*\-charter\-bold\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +AF \-*\-charter\-bold\-i\-normal\-\^\-*\-*\-*\-*\-*\-*\-iso8859\-1\en\e +S \-*\-symbol\-medium\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-adobe\-fontspecific\en\e +S2 \-*\-symbol\-medium\-r\-normal\-\^\-*\-*\-*\-*\-*\-*\-adobe\-fontspecific\en +.sp +.fi +.SH "USING XDITVIEW WITH DITROFF" +.PP +You can use any ditroff output file with +.I xditview, +although files which use +the fonts appropriate to the fontMap will look more accurate on the screen. +On servers which support scaled fonts, all requested font sizes will be +accurately reflected on the screen; for servers which do not support scaled +.I xditview +will use the closest font from the same family. +.SH "SEE ALSO" +.IR X (__miscmansuffix__), +.IR xrdb (1), +.IR ditroff (1), +.I "X Logical Font Description Conventions" +.SH ORIGIN +Portions of this program originated in +.I xtroff which was derived +from +.I suntroff. +.SH COPYRIGHT +Copyright ([\d,\s]*) X Consortium +.br +See \fIX\fP(1) for a full statement of rights and permissions. +.SH AUTHORS +Keith Packard (MIT X Consortium) +.br +Richard L. Hyde (Purdue) +.br +David Slattengren (Berkeley) +.br +Malcom Slaney (Schlumberger Palo Alto Research) +.br +Mark Moraes (University of Toronto) |