home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 5
/
FreshFish_July-August1994.bin
/
bbs
/
gnu
/
gs-2.6.1.4-src.lha
/
src
/
amiga
/
gs-2.6.1.4
/
gschar.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-27
|
24KB
|
792 lines
/* Copyright (C) 1989, 1992, 1993 Aladdin Enterprises. All rights reserved.
This file is part of Ghostscript.
Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the Ghostscript General Public License for full details.
Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License. A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
copies. */
/* gschar.c */
/* Character writing operators for Ghostscript library */
#include "gx.h"
#include "memory_.h"
#include "string_.h"
#include "gserrors.h"
#include "gxfixed.h" /* ditto */
#include "gxarith.h"
#include "gxmatrix.h"
#include "gzstate.h" /* must precede gzdevice */
#include "gzdevice.h" /* must precede gxchar */
#include "gxdevmem.h"
#include "gxchar.h"
#include "gxcache.h"
#include "gxfont.h"
#include "gspath.h"
#include "gzpath.h"
#include "gzcolor.h"
/* Exported size of enumerator */
const uint gs_show_enum_sizeof = sizeof(gs_show_enum);
/* Imported procedures */
extern void gx_set_black(P1(gs_state *));
/* Forward declarations */
private int continue_kshow(P1(gs_show_enum *));
private int continue_show(P1(gs_show_enum *));
private int continue_show_update(P1(gs_show_enum *));
private int show_setup(P3(gs_show_enum *, gs_state *, const char *));
private void show_cache_setup(P1(gs_show_enum *));
private int show_state_setup(P1(gs_show_enum *));
private int show_origin_setup(P4(gs_state *, fixed, fixed, int));
private int stringwidth_setup(P3(gs_show_enum *, gs_state *, const char *));
/* Print the ctm if debugging */
#define print_ctm(s,pgs)\
dprintf7("[p]%sctm=[%g %g %g %g %g %g]\n", s,\
pgs->ctm.xx, pgs->ctm.xy, pgs->ctm.yx, pgs->ctm.yy,\
pgs->ctm.tx, pgs->ctm.ty)
/* ------ String writing operators ------ */
/* Setup macros for show operators */
#define setup_show_n()\
penum->size = size
#define setup_a()\
penum->add = 1, penum->ax = ax, penum->ay = ay,\
penum->slow_show = 1
#define setup_width()\
penum->wchr = chr, penum->wcx = cx, penum->wcy = cy,\
penum->slow_show = 1
/* show[_n] */
int
gs_show_n_init(register gs_show_enum *penum,
gs_state *pgs, const char *str, uint size)
{ setup_show_n();
penum->slow_show = 0;
return show_setup(penum, pgs, str);
}
int
gs_show_init(gs_show_enum *penum, gs_state *pgs, const char *str)
{ return gs_show_n_init(penum, pgs, str, strlen(str));
}
/* ashow[_n] */
int
gs_ashow_n_init(register gs_show_enum *penum,
gs_state *pgs, floatp ax, floatp ay, const char *str, uint size)
{ int code;
setup_show_n();
code = show_setup(penum, pgs, str);
setup_a();
return code;
}
int
gs_ashow_init(gs_show_enum *penum,
gs_state *pgs, floatp ax, floatp ay, const char *str)
{ return gs_ashow_n_init(penum, pgs, ax, ay, str, strlen(str));
}
/* widthshow[_n] */
int
gs_widthshow_n_init(register gs_show_enum *penum,
gs_state *pgs, floatp cx, floatp cy, gs_char chr, const char *str, uint size)
{ int code;
setup_show_n();
code = show_setup(penum, pgs, str);
setup_width();
return code;
}
int
gs_widthshow_init(gs_show_enum *penum,
gs_state *pgs, floatp cx, floatp cy, gs_char chr, const char *str)
{ return gs_widthshow_n_init(penum, pgs, cx, cy, chr, str, strlen(str));
}
/* awidthshow[_n] */
int
gs_awidthshow_n_init(register gs_show_enum *penum,
gs_state *pgs, floatp cx, floatp cy, gs_char chr, floatp ax, floatp ay,
const char *str, uint size)
{ int code;
setup_show_n();
code = show_setup(penum, pgs, str);
setup_a();
setup_width();
return code;
}
int
gs_awidthshow_init(gs_show_enum *penum,
gs_state *pgs, floatp cx, floatp cy, gs_char chr, floatp ax, floatp ay,
const char *str)
{ return gs_awidthshow_n_init(penum, pgs, cx, cy, chr, ax, ay,
str, strlen(str));
}
/* kshow[_n] */
int
gs_kshow_n_init(register gs_show_enum *penum,
gs_state *pgs, const char *str, uint size)
{ int code;
if ( pgs->font->FontType == ft_composite)
return_error(gs_error_invalidfont);
setup_show_n();
code = show_setup(penum, pgs, str);
penum->do_kern = penum->slow_show = 1;
return code;
}
int
gs_kshow_init(gs_show_enum *penum, gs_state *pgs, const char *str)
{ return gs_kshow_n_init(penum, pgs, str, strlen(str));
}
/* xyshow[_n] */
int
gs_xyshow_n_init(register gs_show_enum *penum,
gs_state *pgs, const char *str, uint size)
{ int code;
setup_show_n();
code = show_setup(penum, pgs, str);
penum->do_kern = -1;
penum->slow_show = 1;
return code;
}
int
gs_xyshow_init(gs_show_enum *penum, gs_state *pgs, const char *str)
{ return gs_xyshow_n_init(penum, pgs, str, strlen(str));
}
/* glyphshow */
private gs_proc_encode_char(gs_glyphshow_encode_char);
int
gs_glyphshow_init(gs_show_enum *penum, gs_state *pgs, gs_glyph glyph)
{ int code;
if ( pgs->font->FontType == ft_composite)
return_error(gs_error_invalidfont);
penum->size = 1;
penum->slow_show = 0;
code = show_setup(penum, pgs, "\000"); /* arbitrary char */
penum->current_glyph = glyph;
penum->encode_char = gs_glyphshow_encode_char;
return code;
}
private gs_glyph
gs_glyphshow_encode_char(gs_show_enum *penum, gs_font *pfont, gs_char *pchr)
{ /* We just nil out the character, and return the pre-loaded glyph. */
*pchr = gs_no_char;
return penum->current_glyph;
}
/* cshow[_n] */
int
gs_cshow_n_init(register gs_show_enum *penum,
gs_state *pgs, const char *str, uint size)
{ int code;
setup_show_n();
code = show_setup(penum, pgs, str);
penum->do_kern = -1;
penum->stringwidth_flag = 1;
penum->slow_show = 1;
return code;
}
int
gs_cshow_init(gs_show_enum *penum, gs_state *pgs, const char *str)
{ return gs_cshow_n_init(penum, pgs, str, strlen(str));
}
/* ------ Related operators ------ */
/* stringwidth[_n] */
int
gs_stringwidth_n_init(gs_show_enum *penum, gs_state *pgs, const char *str, uint size)
{ setup_show_n();
return stringwidth_setup(penum, pgs, str);
}
int
gs_stringwidth_init(gs_show_enum *penum, gs_state *pgs, const char *str)
{ return gs_stringwidth_n_init(penum, pgs, str, strlen(str));
}
/* Common code for stringwidth[_n] */
private int
stringwidth_setup(gs_show_enum *penum, gs_state *pgs, const char *str)
{ int code = (penum->slow_show = 0, show_setup(penum, pgs, str));
if ( code < 0 ) return_error(code);
penum->stringwidth_flag = 1;
/* Do an extra gsave and suppress output */
if ( (code = gs_gsave(pgs)) < 0 ) return code;
penum->level = pgs->level; /* for level check in show_update */
/* Set up a null device that forwards xfont requests properly. */
penum->dev_null = gs_null_device;
penum->dev_null.target = pgs->device->info;
pgs->device->info = (gx_device *)&penum->dev_null;
/* Establish an arbitrary current point. */
return gx_path_add_point(pgs->path, pgs->ctm.tx_fixed, pgs->ctm.ty_fixed);
}
/* charpath[_n] */
int
gs_charpath_n_init(gs_show_enum *penum, gs_state *pgs,
const char *str, uint size, int bool)
{ int code;
setup_show_n();
code = show_setup(penum, pgs, str);
penum->charpath_flag = (bool ? 2 : 1);
penum->can_cache = 0;
return code;
}
int
gs_charpath_init(gs_show_enum *penum, gs_state *pgs,
const char *str, int bool)
{ return gs_charpath_n_init(penum, pgs, str, strlen(str), bool);
}
/* ------ Width/cache operators ------ */
private int set_cache_device(P6(gs_show_enum *, gs_state *,
floatp, floatp, floatp, floatp));
/* setcachedevice */
int
gs_setcachedevice(gs_show_enum *penum, gs_state *pgs,
floatp wx, floatp wy, floatp llx, floatp lly, floatp urx, floatp ury)
{ int code = gs_setcharwidth(penum, pgs, wx, wy); /* default is don't cache */
if ( code < 0 ) return code;
return set_cache_device(penum, pgs, llx, lly, urx, ury);
}
/* setcachedevice2 */
int
gs_setcachedevice2(gs_show_enum *penum, gs_state *pgs,
floatp w0x, floatp w0y, floatp llx, floatp lly, floatp urx, floatp