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

Subversion Repositories or1k_old

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

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

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

powered by: WebSVN 2.1.0

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