本文整理汇总了C++中ps_output类的典型用法代码示例。如果您正苦于以下问题:C++ ps_output类的具体用法?C++ ps_output怎么用?C++ ps_output使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ps_output类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: import_file
void resource_manager::import_file(const char *filename, ps_output &out)
{
out.end_line();
string name(filename);
resource *r = lookup_resource(RESOURCE_FILE, name);
supply_resource(r, -1, out.get_file(), 1);
}
示例2: output_prolog
void resource_manager::output_prolog(ps_output &out)
{
FILE *outfp = out.get_file();
out.end_line();
char *path;
if (!getenv("GROPS_PROLOGUE")) {
string e = "GROPS_PROLOGUE";
e += '=';
e += GROPS_PROLOGUE;
e += '\0';
if (putenv(strsave(e.contents())))
fatal("putenv failed");
}
char *prologue = getenv("GROPS_PROLOGUE");
FILE *fp = font::open_file(prologue, &path);
if (!fp)
fatal("can't find `%1'", prologue);
fputs("%%BeginResource: ", outfp);
procset_resource->print_type_and_name(outfp);
putc('\n', outfp);
process_file(-1, fp, path, outfp);
fclose(fp);
a_delete path;
fputs("%%EndResource\n", outfp);
}
示例3: print_header_comments
void resource_manager::print_header_comments(ps_output &out)
{
for (resource *r = resource_list; r; r = r->next)
if (r->type == RESOURCE_FONT && (r->flags & resource::FONT_NEEDED))
supply_resource(r, 0, 0);
print_resources_comment(resource::NEEDED, out.get_file());
print_resources_comment(resource::SUPPLIED, out.get_file());
print_language_level_comment(out.get_file());
print_extensions_comment(out.get_file());
}
示例4: document_setup
void resource_manager::document_setup(ps_output &out)
{
int nranks = 0;
resource *r;
for (r = resource_list; r; r = r->next)
if (r->rank >= nranks)
nranks = r->rank + 1;
if (nranks > 0) {
// Sort resource_list in reverse order of rank.
Presource *head = new Presource[nranks + 1];
Presource **tail = new Presource *[nranks + 1];
int i;
for (i = 0; i < nranks + 1; i++) {
head[i] = 0;
tail[i] = &head[i];
}
for (r = resource_list; r; r = r->next) {
i = r->rank < 0 ? 0 : r->rank + 1;
*tail[i] = r;
tail[i] = &(*tail[i])->next;
}
resource_list = 0;
for (i = 0; i < nranks + 1; i++)
if (head[i]) {
*tail[i] = resource_list;
resource_list = head[i];
}
a_delete head;
a_delete tail;
// check it
for (r = resource_list; r; r = r->next)
if (r->next)
assert(r->rank >= r->next->rank);
for (r = resource_list; r; r = r->next)
if (r->type == RESOURCE_FONT && r->rank >= 0)
supply_resource(r, -1, out.get_file());
}
}
示例5: begin_page
void ps_printer::begin_page(int n)
{
out.begin_comment("Page:")
.comment_arg(i_to_a(n));
out.comment_arg(i_to_a(++pages_output))
.end_comment();
output_style.f = 0;
output_space_code = 32;
output_draw_point_size = -1;
output_line_thickness = -1;
output_hpos = output_vpos = -1;
ndefined_styles = 0;
out.simple_comment("BeginPageSetup");
#if 0
/*
* NOTE:
* may decide to do this once per page
*/
media_set();
#endif
out.put_symbol("BP")
.simple_comment("EndPageSetup");
if (sbuf_color != default_color)
set_color(&sbuf_color);
}
示例6: do_file
void ps_printer::do_file(char *arg, const environment *env)
{
while (csspace(*arg))
arg++;
if (*arg == '\0') {
error("missing argument to X file command");
return;
}
const char *filename = arg;
do {
++arg;
} while (*arg != '\0' && *arg != ' ' && *arg != '\n');
out.put_fix_number(env->hpos)
.put_fix_number(env->vpos)
.put_symbol("EBEGIN");
rm.import_file(filename, out);
out.put_symbol("EEND");
output_hpos = output_vpos = -1;
output_style.f = 0;
output_draw_point_size = -1;
output_line_thickness = -1;
ndefined_styles = 0;
if (!ndefs)
ndefs = 1;
}
示例7: set_style
void ps_printer::set_style(const style &sty)
{
char buf[1 + INT_DIGITS + 1];
for (int i = 0; i < ndefined_styles; i++)
if (sty == defined_styles[i]) {
sprintf(buf, "F%d", i);
out.put_symbol(buf);
return;
}
if (ndefined_styles >= MAX_DEFINED_STYLES)
ndefined_styles = 0;
sprintf(buf, "F%d", ndefined_styles);
out.put_literal_symbol(buf);
const char *psname = sty.f->get_internal_name();
if (psname == 0)
fatal("no internalname specified for font `%1'", sty.f->get_name());
char *encoding = ((ps_font *)sty.f)->encoding;
if (sty.sub == 0) {
if (encoding != 0) {
char *s = ((ps_font *)sty.f)->reencoded_name;
if (s == 0) {
int ei = set_encoding_index((ps_font *)sty.f);
char *tem = new char[strlen(psname) + 1 + INT_DIGITS + 1];
sprintf(tem, "%[email protected]%d", psname, ei);
psname = tem;
((ps_font *)sty.f)->reencoded_name = tem;
}
else
psname = s;
}
}
else
psname = get_subfont(sty.sub, psname);
out.put_fix_number((font::res/(72*font::sizescale))*sty.point_size);
if (sty.height != 0 || sty.slant != 0) {
int h = sty.height == 0 ? sty.point_size : sty.height;
h *= font::res/(72*font::sizescale);
int c = int(h*tan(radians(sty.slant)) + .5);
out.put_fix_number(c)
.put_fix_number(h)
.put_literal_symbol(psname)
.put_symbol("MF");
}
else {
out.put_literal_symbol(psname)
.put_symbol("SF");
}
defined_styles[ndefined_styles++] = sty;
}
示例8: encode_subfont
void ps_printer::encode_subfont(subencoding *sub)
{
assert(sub->glyphs != 0);
out.put_literal_symbol(make_subencoding_name(sub->idx))
.put_delimiter('[');
for (int i = 0; i < 256; i++)
{
if (sub->glyphs[i])
out.put_literal_symbol(sub->glyphs[i]);
else
out.put_literal_symbol(".notdef");
}
out.put_delimiter(']')
.put_symbol("def");
}
示例9: reencode_font
void ps_printer::reencode_font(ps_font *f)
{
out.put_literal_symbol(f->reencoded_name)
.put_symbol(make_encoding_name(f->encoding_index))
.put_literal_symbol(f->get_internal_name())
.put_symbol("RE");
}
示例10: fill_path
void ps_printer::fill_path(const environment *env)
{
if (sbuf_color == *env->fill)
out.put_symbol("FL");
else
set_color(env->fill, 1);
}
示例11: do_exec
void ps_printer::do_exec(char *arg, const environment *env)
{
flush_sbuf();
while (csspace(*arg))
arg++;
if (*arg == '\0') {
error("missing argument to X exec command");
return;
}
if (!check_line_lengths(arg)) {
error("lines in X exec command must not be more than 255 characters long");
return;
}
out.put_fix_number(env->hpos)
.put_fix_number(env->vpos)
.put_symbol("EBEGIN")
.special(arg)
.put_symbol("EEND");
output_hpos = output_vpos = -1;
output_style.f = 0;
output_draw_point_size = -1;
output_line_thickness = -1;
ndefined_styles = 0;
if (!ndefs)
ndefs = 1;
}
示例12: media_set
void ps_printer::media_set()
{
/*
* The setpagedevice implies an erasepage and initgraphics, and
* must thus precede any descriptions for a particular page.
*
* NOTE:
* This does not work with ps2pdf when there are included eps
* segments that contain PageSize/setpagedevice.
* This might be a bug in ghostscript -- must be investigated.
* Using setpagedevice in an .eps is really the wrong concept, anyway.
*
* NOTE:
* For the future, this is really the place to insert other
* media selection features, like:
* MediaColor
* MediaPosition
* MediaType
* MediaWeight
* MediaClass
* TraySwitch
* ManualFeed
* InsertSheet
* Duplex
* Collate
* ProcessColorModel
* etc.
*/
if (!(broken_flags & (USE_PS_ADOBE_2_0|NO_PAPERSIZE))) {
out.begin_comment("BeginFeature:")
.comment_arg("*PageSize")
.comment_arg(media_name())
.end_comment();
int w = media_width();
int h = media_height();
if (w > 0 && h > 0)
// warning to user is done elsewhere
fprintf(out.get_file(),
"<< /PageSize [ %d %d ] /ImagingBBox null >> setpagedevice\n",
w, h);
out.simple_comment("EndFeature");
}
}
示例13: end_page
void ps_printer::end_page(int)
{
flush_sbuf();
set_color(&default_color);
out.put_symbol("EP");
if (invis_count != 0) {
error("missing `endinvis' command");
invis_count = 0;
}
}
示例14: define_encoding
void ps_printer::define_encoding(const char *encoding, int encoding_index)
{
char *vec[256];
int i;
for (i = 0; i < 256; i++)
vec[i] = 0;
char *path;
FILE *fp = font::open_file(encoding, &path);
if (fp == 0)
fatal("can't open encoding file `%1'", encoding);
int lineno = 1;
const int BUFFER_SIZE = 512;
char buf[BUFFER_SIZE];
while (fgets(buf, BUFFER_SIZE, fp) != 0) {
char *p = buf;
while (csspace(*p))
p++;
if (*p != '#' && *p != '\0' && (p = strtok(buf, WS)) != 0) {
char *q = strtok(0, WS);
int n = 0; // pacify compiler
if (q == 0 || sscanf(q, "%d", &n) != 1 || n < 0 || n >= 256)
fatal_with_file_and_line(path, lineno, "bad second field");
vec[n] = new char[strlen(p) + 1];
strcpy(vec[n], p);
}
lineno++;
}
a_delete path;
out.put_literal_symbol(make_encoding_name(encoding_index))
.put_delimiter('[');
for (i = 0; i < 256; i++) {
if (vec[i] == 0)
out.put_literal_symbol(".notdef");
else {
out.put_literal_symbol(vec[i]);
a_delete vec[i];
}
}
out.put_delimiter(']')
.put_symbol("def");
fclose(fp);
}
示例15: set_line_thickness_and_color
void ps_printer::set_line_thickness_and_color(const environment *env)
{
if (line_thickness < 0) {
if (output_draw_point_size != env->size) {
// we ought to check for overflow here
int lw = ((font::res/(72*font::sizescale))*linewidth*env->size)/1000;
out.put_fix_number(lw)
.put_symbol("LW");
output_draw_point_size = env->size;
output_line_thickness = -1;
}
}
else {
if (output_line_thickness != line_thickness) {
out.put_fix_number(line_thickness)
.put_symbol("LW");
output_line_thickness = line_thickness;
output_draw_point_size = -1;
}
}
if (sbuf_color != *env->col)
set_color(env->col);
}