OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [mw/] [src/] [demos/] [nanox/] [logfont.c] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <unistd.h>
5
#if UNIX
6
#include <time.h>
7
#endif
8
#define MWINCLUDECOLORS
9
#include "nano-X.h"
10
/*
11
 * logical font demo for Nano-X
12
 */
13
 
14
#define MAXW            630
15
#define MAXH            470
16
 
17
int main(int argc, char **argv)
18
{
19
        GR_WINDOW_ID    window;
20
        GR_EVENT        event;
21
        GR_GC_ID        gc;
22
        GR_FONT_ID      fontid;
23
        int             x, y, rnd = 0;
24
        MWLOGFONT       lf;
25
        char            description[128];
26
 
27
        srand(time(0));
28
 
29
        GrOpen();
30
        window = GrNewWindow(GR_ROOT_WINDOW_ID, 5, 5, MAXW, MAXH, 4, BLACK, BLUE);
31
        GrMapWindow(window);
32
 
33
        gc = GrNewGC();
34
 
35
        GrSelectEvents(window,GR_EVENT_MASK_ALL);
36
        GrSetGCUseBackground(gc,GR_FALSE);
37
        GrSetGCBackground(gc, GR_RGB(0, 0, 0));
38
 
39
        y = 30;
40
        x = 0;
41
 
42
        while(1) {
43
              GrCheckNextEvent(&event);
44
 
45
              if(event.type == GR_EVENT_TYPE_CLOSE_REQ) {
46
                        GrClose();
47
                        exit(0);
48
              }
49
 
50
              /*sleep(1);*/
51
 
52
              MWLF_Clear(&lf);
53
              description[0] = '\0';
54
              /*lf.lfSerif = 1;*/
55
 
56
              if ( rnd & 1 ) {
57
                      lf.lfWeight = MWLF_WEIGHT_BOLD;
58
                      strcat(description,"Bold ");
59
              }
60
 
61
 
62
              if ( rnd & 2 ) {
63
                      lf.lfItalic = 1;
64
                      strcat(description,"Italics ");
65
              }
66
              if ( rnd & 4 ) {
67
                      lf.lfOblique = 1;
68
                      strcat(description,"Oblique ");
69
              }
70
 
71
              if ( rnd & 8 ) {
72
                      lf.lfMonospace = 1;
73
                      strcat(description,"Monospace ");
74
              } else {
75
                      lf.lfProportional = 1;
76
                      strcat(description,"Proportional ");
77
              }
78
 
79
              if ( argc > 1 )
80
                      strcpy(lf.lfFaceName,argv[1]);
81
              else
82
                      strcpy(lf.lfFaceName,"fantasy");
83
 
84
              fontid = GrCreateFont(0, 0, &lf);
85
              /* GrSetFontSize(fontid, 1+(int)(80.0 * rand() / (RAND_MAX+1.0))); */
86
              GrSetFontSize(fontid,26);
87
              GrSetFontRotation(fontid, 330);   /* 33 degrees*/
88
              GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0);
89
              GrSetGCFont(gc, fontid);
90
              /*GrSetGCBackground(gc, rand() & 0xffffff);*/
91
              GrSetGCForeground(gc, 0xffffff);
92
              /* x = (int) ((MAXW * 1.0) *rand()/(RAND_MAX+1.0));
93
                 y = (int) ((MAXH * 1.0) *rand()/(RAND_MAX+1.0)); */
94
 
95
              GrText(window, gc,x,y, description, -1, GR_TFASCII);
96
 
97
              GrDestroyFont(fontid);
98
 
99
              rnd++;
100
              y += 30;
101
              if ( y > 460 )
102
                      y = 0;
103
        }
104
 
105
        GrClose();
106
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.