Index: xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c =================================================================== RCS file: /cvs/xorg/xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xpsimplehelloworld.c --- xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c 23 Apr 2004 19:55:00 -0000 1.2 +++ xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c 3 Oct 2004 22:52:42 -0000 @@ -15,40 +15,41 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OPEN GROUP 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 Open Group 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 Open Group. * * Author: Roland Mainz */ #include #include #include #include #include #include +#include #include /* Turn a NULL pointer string into an empty string */ #define NULLSTR(x) (((x)!=NULL)?(x):("")) #define Log(x) { if(verbose) printf x; } static const char *ProgramName; /* program name (from argv[0]) */ static Bool verbose = False; /* verbose output what the program is doing */ static void usage(void) { fprintf (stderr, "usage: %s [options]\n", ProgramName); fprintf (stderr, "-printer printernname\tprinter to use\n"); fprintf (stderr, "-printfile file\tprint to file instead of printer\n"); fprintf (stderr, "-embedpsl2data string\tPostScript level 2 fragment to embed\n" "\t\t(use 'xppsembeddemo1' to embed demo data)\n"); fprintf (stderr, "-v\tverbose output\n"); fprintf (stderr, "\n"); @@ -158,40 +159,97 @@ XpuStartJobToSpooler(pdpy); XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartJobNotify); } #ifdef MULTIPLE_DOCUMENTS_IN_ONE_JOB /* Start document (one job can contain any number of "documents") * XpStartDoc() isn't mandatory if job only contains one document - first * XpStartPage() will generate a "synthetic" XpStartDoc() if one had not * already been done. */ XpStartDoc(pdpy, XPDocNormal); XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartDocNotify); #endif /* MULTIPLE_DOCUMENTS_IN_ONE_JOB */ pscreen = XpGetScreenOfContext(pdpy, pcontext); pscreennumber = XScreenNumberOfScreen(pscreen); /* Obtain some info about page geometry */ XpGetPageDimensions(pdpy, pcontext, &dummy, &dummy, &winrect); +#if 1 + puts("font info start."); +{ + char *mode; + char **fonts; + int numfonts; + + numfonts = 0; + fonts = XListFonts(pdpy, "*", INT_MAX, &numfonts); + printf("fonts=%lx, numfonts=%ld\n", (long)fonts, (long)numfonts); + if(fonts) + XFreeFontNames(fonts); + + mode = "xp-list-internal-printer-fonts"; + printf("--> mode=%s\n", mode); + XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", mode, XPAttrMerge); + numfonts = 0; + fonts = XListFonts(pdpy, "*", INT_MAX, &numfonts); + printf("fonts=%lx, numfonts=%ld\n", (long)fonts, (long)numfonts); + { + int i; + for( i = 0 ; i < numfonts ; i++ ) + printf("\tfontname='%s'\n", NULLSTR(fonts[i])); + } + if(fonts) + XFreeFontNames(fonts); + + mode = "xp-list-glyph-fonts"; + printf("--> mode=%s\n", mode); + XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", mode, XPAttrMerge); + numfonts = 0; + fonts = XListFonts(pdpy, "*", INT_MAX, &numfonts); + printf("fonts=%lx, numfonts=%ld\n", (long)fonts, (long)numfonts); + if(fonts) + XFreeFontNames(fonts); + + mode = "xp-list-internal-printer-fonts xp-list-glyph-fonts"; + printf("--> mode=%s\n", mode); + XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", mode, XPAttrMerge); + numfonts = 0; + fonts = XListFonts(pdpy, "*", INT_MAX, &numfonts); + printf("fonts=%lx, numfonts=%ld\n", (long)fonts, (long)numfonts); + if(fonts) + XFreeFontNames(fonts); + + mode = ""; + printf("--> mode=%s\n", mode); + XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", mode, XPAttrMerge); + numfonts = 0; + fonts = XListFonts(pdpy, "*", INT_MAX, &numfonts); + printf("fonts=%lx, numfonts=%ld\n", (long)fonts, (long)numfonts); + if(fonts) + XFreeFontNames(fonts); +} + puts("font info done."); +#endif + pwin = XCreateSimpleWindow(pdpy, XRootWindowOfScreen(pscreen), winrect.x, winrect.y, winrect.width, winrect.height, 10, XBlackPixel(pdpy, pscreennumber), XWhitePixel(pdpy, pscreennumber)); gcvalues.background = XWhitePixel(pdpy, pscreennumber); gcvalues.foreground = XBlackPixel(pdpy, pscreennumber); pgc = XCreateGC(pdpy, pwin, GCBackground|GCForeground, &gcvalues); Log(("start page.\n")); XpStartPage(pdpy, pwin); XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartPageNotify); /* Mapping the window inside XpStartPage()/XpEndPage() * Set XCreateWindow/border_width to 0 or move XMapWindow in front of * XpStartPage() to get rid of the surrounding black border lines. * (This is usually done before XpStartPage() in real applications) */