[go: up one dir, main page]

Menu

[72b583]: / tests / c / showbox.c  Maximize  Restore  History

Download this file

69 lines (58 with data), 3.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>
#include <libps/pslib.h>
#ifdef MEMORY_DEBUGGING
#include <libps/pslib-mp.h>
#endif
void errorhandler(PSDoc *p, int error, const char *str, void *data) {
fprintf(stderr, "PSLib: %s\n", str);
}
int main() {
PSDoc *psdoc;
int antiqua;
float boxwidth, boxheight, baseline, colsep, leftmargin;
float fontsize;
int boxed, line;
boxwidth = 100;
boxheight = 630;
baseline = 100;
colsep = 20;
leftmargin = 100;
boxed = 0;
fontsize = 10.0;
PS_boot();
#ifdef MEMORY_DEBUGGING
PS_mp_init();
#endif
#ifdef MEMORY_DEBUGGING
psdoc = PS_new2(errorhandler, PS_mp_malloc, PS_mp_realloc, PS_mp_free, NULL);
#else
psdoc = PS_new();
#endif
PS_open_file(psdoc, "showbox.ps");
PS_set_info(psdoc, "Creator", __FILE__);
PS_set_info(psdoc, "Author", "Uwe Steinmann");
PS_set_info(psdoc, "Title", "Boxed Text");
PS_set_info(psdoc, "Keywords", "Boxes, Text Rendering");
PS_set_info(psdoc, "BoundingBox", "0 0 596 842");
antiqua = PS_findfont(psdoc, "AlteSchwabacher", "AlteSchwabacher.enc", 1);
PS_begin_page(psdoc, 596, 842);
PS_setfont(psdoc, antiqua, 10.0);
PS_set_value(psdoc, "leading", 15.0);
// PS_set_parameter(psdoc, "linebreak", "true");
PS_show_boxed(psdoc,
"pslib supports ligatures if the used font contains any.\n\rThe most common ligatures are fi, ff, and fl, which are\navailable in many fonts. Sometimes also ffi and ffl exist.\nThose ligatures are recognized by pslib automatically, even\nif they are not declared as a ligature in the fonts afm\nfile. Old german fonts like Fraktur or Schwabacher provide\nmuch more ligatures which are quite often available under\nvery misleading glyph names. The font AlteSchwabacher used\nin this document has a sch-Ligature named as 'logicalnot'.\nAccessing these ligatures requires some manual intervention.\nIn order to understand what needs to be done for using such\nligatures, one should first understand how pslib checks for\nligatures. pslib checks for each character if it forms a\nligature with the following character. If that is the case\nit will further check if this ligature forms a ligature with\nnext character. It does it until no more ligatures are\n found. If the current char and the next char do not form a\n ligature, pslib will check if the next char and the one\n following the next char form a ligature. If that is the\n case, it will check again for the current char and the just\n found ligature. This sounds very complicated but it provides\n great flexibility in defining ligatures. The definition of\n new ligatures is done in the encoding file (see\n AlteSchwabacher.enc for examples). Each definition\n specifies two glyph names constructing the ligature and the\n glyph name of the ligature. The glyph name of the ligature\n is the name as it is used in the afm file. In the case of\n the ligature sch it would be 'logicalnot'. A formerly\n defined ligature can be used in the following ligature\n definition. This is required if a ligature is made of more\n than two characters like the sch ligature. One has to define\n first the ch ligature and than the sch ligature. If a\n ligature is defined but the font does not contain the\n appropriate glyph, then it will be automatically disolved\n and a warning is issued.",
leftmargin, 400, 400, 380, "left", NULL);
PS_end_page(psdoc);
PS_deletefont(psdoc, antiqua);
PS_close(psdoc);
PS_delete(psdoc);
#ifdef MEMORY_DEBUGGING
PS_mp_list_unfreed();
#endif
PS_shutdown();
exit(0);
}