Main Page | Directories | File List | File Members

mainpage.h

00001 
00026 #include <pango/pango.h>
00027 #include <pango/pangoft2.h>
00028 #include <stdio.h>
00029 #include "libpaps.h"
00030 
00031 int main(int argc, char*argv[])
00032 {
00033   paps_t *paps = paps_new();
00034   gchar *header, *ps_layout;
00035   PangoContext *pango_context;
00036   PangoFontDescription *font_description;
00037   PangoDirection pango_dir = PANGO_DIRECTION_LTR;
00038   PangoLayout *layout;
00039   gchar *font_family = "sans";
00040   int font_scale = 14;
00041   GString *ps_text = g_string_new("");
00042   
00043   pango_context = paps_get_pango_context();
00044   
00045   /* Setup pango */
00046   pango_context_set_language (pango_context, pango_language_from_string ("en_US"));
00047   pango_context_set_base_dir (pango_context, pango_dir);
00048   
00049   font_description = pango_font_description_new ();
00050   pango_font_description_set_family (font_description, g_strdup (font_family));
00051   pango_font_description_set_style (font_description, PANGO_STYLE_NORMAL);
00052   pango_font_description_set_variant (font_description, PANGO_VARIANT_NORMAL);
00053   pango_font_description_set_weight (font_description, PANGO_WEIGHT_NORMAL);
00054   pango_font_description_set_stretch (font_description, PANGO_STRETCH_NORMAL);
00055   pango_font_description_set_size (font_description, font_scale * PANGO_SCALE);
00056   
00057   pango_context_set_font_description (pango_context, font_description);
00058 
00059   // Create a layout and set its properties
00060   layout = pango_layout_new (pango_context);
00061   pango_layout_set_justify (layout, TRUE);
00062   pango_layout_set_width (layout, paps_postscript_points_to_pango(5*72));
00063   
00064   pango_layout_set_text (layout,
00065                          "It was the best of times, it was the worst of times, "
00066                          "it was the age of wisdom, it was the age of foolishness, "
00067                          "it was the epoch of belief, it was the epoch of incredulity, "
00068                          "it was the season of Light, it was the season of Darkness, "
00069                          "it was the spring of hope, it was the winter of despair, "
00070                          "we had everything before us, we had nothing before us, "
00071                          "we were all going direct to Heaven, we were all going direct "
00072                          "the other way--in short, the period was so far like the present "
00073                          "period, that some of its noisiest authorities insisted on its "
00074                          "being received, for good or for evil, in the superlative degree "
00075                          "of comparison only. "
00076                          "\n\n"
00077                          "There were a king with a large jaw and a queen with a plain face, "
00078                          "on the throne of England; there were a king with a large jaw and "
00079                          "a queen with a fair face, on the throne of France.  In both "
00080                          "countries it was clearer than crystal to the lords of the State "
00081                          "preserves of loaves and fishes, that things in general were "
00082                          "settled for ever. "
00083                          "\n\n"
00084                          "It was the year of Our Lord one thousand seven hundred and "
00085                          "seventy-five.  Spiritual revelations were conceded to England at "
00086                          "that favoured period, as at this.  Mrs. Southcott had recently "
00087                          "attained her five-and-twentieth blessed birthday, of whom a "
00088                          "prophetic private in the Life Guards had heralded the sublime "
00089                          "appearance by announcing that arrangements were made for the "
00090                          "swallowing up of London and Westminster.  Even the Cock-lane "
00091                          "ghost had been laid only a round dozen of years, after rapping "
00092                          "out its messages, as the spirits of this very year last past "
00093                          "(supernaturally deficient in originality) rapped out theirs. "
00094                          "Mere messages in the earthly order of events had lately come to "
00095                          "the English Crown and People, from a congress of British subjects "
00096                          "in America:  which, strange to relate, have proved more important "
00097                          "to the human race than any communications yet received through "
00098                          "any of the chickens of the Cock-lane brood. "
00099                          , -1);
00100 
00101   ps_layout = paps_layout_to_postscript_strdup(paps,
00102                                                0, 0,
00103                                                layout);
00104   g_string_append_printf(ps_text,
00105                          "gsave\n"
00106                          "1 0.8 0.8 setrgbcolor\n"
00107                          "72 72 10 mul translate\n"
00108                          "3 rotate %s\n"
00109                          "grestore\n",
00110                          ps_layout);
00111   g_free(ps_layout);
00112 
00113   pango_font_description_set_size (font_description, 25 * PANGO_SCALE);
00114   pango_context_set_font_description (pango_context, font_description);
00115   pango_layout_set_width (layout, paps_postscript_points_to_pango(7*72));
00116   pango_layout_set_text (layout,
00117                          "paps by Dov Grobgeld (\327\223\327\221 \327\222\327\250\327\225"
00118                          "\327\221\327\222\327\234\327\223\n"
00119                          "Printing through \316\240\316\261\316\275\350\252\236 (Pango)\n"
00120                          "\n"
00121                          "Arabic \330\247\331\204\330\263\331\204\330\247\330\271"
00122                          "\331\204\331\212\331\203\331\205\n"
00123                          "Hebrew \327\251\327\201\326\270\327\234\327\225\326\271\327\235\n"
00124                          "Greek (\316\225\316\273\316\273\316\267\316\275\316\271\316\272"
00125                          "\316\254)  \316\223\316\265\316\271\316\254 \317\203\316\261\317\202\n"
00126                          "Japanese  (\346\227\245\346\234\254\350\252\236) \343\201\223\343"
00127                          "\202\223\343\201\253\343\201\241\343\201\257, \357\275\272\357\276"
00128                          "\235\357\276\206\357\276\201\357\276\212\n"
00129                          "Chinese  (\344\270\255\346\226\207, \346\231\256\351\200\232\350"
00130                          "\257\235,\346\261\211\350\257\255)     \344\275\240\345\245\275\n"
00131                          "Vietnamese    (Ti\341\272\277ng Vi\341\273\207t)      Xin Ch"
00132                          "\303\240o\n",
00133                          -1
00134                          );
00135   ps_layout = paps_layout_to_postscript_strdup(paps,
00136                                                0, 0,
00137                                                layout);
00138   g_string_append_printf(ps_text,
00139                          "gsave\n"
00140                          "0.2 0.2 1.0 setrgbcolor\n"
00141                          "100 700 translate\n"
00142                          "-10 rotate %s\n"
00143                          "grestore\n",
00144                          ps_layout);
00145   g_string_append_printf(ps_text,
00146                          "gsave\n"
00147                          "0 0.5 0.1 setrgbcolor\n"
00148                          "500 300 translate\n"
00149                          "-5 rotate -0.5 1 scale %s\n"
00150                          "grestore\n",
00151                          ps_layout);
00152   g_free(ps_layout);
00153 
00154 
00155   header = paps_get_postscript_header_strdup(paps);
00156   printf("%s",header);
00157   g_free(header);
00158 
00159   printf("%s", ps_text->str);
00160 
00161   return 0;
00162 }
00163 \endcode
00164 
00165   The result is shown here:
00166   
00167   \image html example-output.png
00168   
00169 
00170 */

Generated on Tue Nov 15 22:06:18 2005 for libpaps by  doxygen 1.4.4