Exemple #1
0
BOOL InitMenuFonts(void)
{
    if(!(bigfont=openfont(BIG_FONT))) /* eat2 */
    {
        D(bug("Unable to open the ETW font!\n"));
        return FALSE;
    }
    if(!(smallfont=openfont(SMALL_FONT))) /* eat */
    {
        D(bug("Unable to open the ETW font!\n"));
        closefont(bigfont);
        return FALSE;
    }
    if(!(titlefont=openfont(TITLE_FONT))) /* eatinfo */
    {
        D(bug("Unable to open the ETW font!\n"));
        closefont(smallfont);
        closefont(bigfont);
        return FALSE;
    }

    D(bug("Font aperti correttamente\n"));

    return TRUE;
}
Exemple #2
0
Font*
opendefaultfont(Display *d)
{
	Font *fnt;

	fnt = openfont(d, getenv("font"));
	if(fnt == nil)
		openfont(d, "/lib/font/bit/pelm/latin1.8.font");
	return fnt;
}
Exemple #3
0
Font *
getfont(int i)
{
    if(fonts[i] == nil) {
        fonts[i] = openfont(display, fontpaths[i]);
        if(fonts[i] == nil)
            error("can't open font file");
    }
    return fonts[i];
}
Exemple #4
0
void scaleresource_setdefaults (void)
{
	setdeffont ();
	for (int i = 0; i < MAX_GUI_FONTS; i++) {
		TCHAR tmp[256];
		_stprintf (tmp, _T("%s%s"), fontreg[i], fontprefix);
		regdelete (NULL, tmp);
	}
	openfont (true);
}
Exemple #5
0
int scaleresource_choosefont (HWND hDlg, int fonttype)
{
	CHOOSEFONT cf = { 0 };
	LOGFONT lf = { 0 };
	HDC hdc;
	TCHAR *fontname[2];
	int *fontsize[2], *fontstyle[2], *fontweight[2];
	int lm;

	fontname[0] = fontname_gui;
	fontname[1] = fontname_list;
	fontsize[0] = &fontsize_gui;
	fontsize[1] = &fontsize_list;
	fontstyle[0] = &fontstyle_gui;
	fontstyle[1] = &fontstyle_list;
	fontweight[0] = &fontweight_gui;
	fontweight[1] = &fontweight_list;

	cf.lStructSize = sizeof cf;
	cf.hwndOwner = hDlg;
	cf.Flags = CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_NOSCRIPTSEL | CF_SCREENFONTS;
	cf.lpLogFont = &lf;
	cf.nFontType = REGULAR_FONTTYPE;
	cf.iPointSize = *fontsize[fonttype];

	hdc = GetDC (NULL);
	lm = GetDeviceCaps (hdc, LOGPIXELSY);

	_tcscpy (lf.lfFaceName, fontname[fonttype]);
	lf.lfHeight = -MulDiv (*fontsize[fonttype], lm, 72);
	lf.lfWeight = *fontweight[fonttype];
	lf.lfItalic = (*fontstyle[fonttype] & ITALIC_FONTTYPE) != 0;

	if (!ChooseFont (&cf)) {
		ReleaseDC (NULL, hdc);
		return 0;
	}

	_tcscpy (fontname[fonttype], lf.lfFaceName);
	*fontsize[fonttype] = lf.lfHeight;
	*fontsize[fonttype] = -MulDiv (*fontsize[fonttype], 72, GetDeviceCaps (hdc, LOGPIXELSY));

	*fontstyle[fonttype] = lf.lfItalic ? ITALIC_FONTTYPE : 0;

	*fontweight[fonttype] = lf.lfWeight;

	ReleaseDC (NULL, hdc);

	regsetfont (NULL, fontprefix, fontreg[fonttype], fontname[fonttype], *fontsize[fonttype], *fontstyle[fonttype], *fontweight[fonttype]);

	openfont (true);


	return 1;
}
Exemple #6
0
void scaleresource_setfont (HWND hDlg)
{
	if (!listviewcnt || (!_tcscmp (fontname_gui, fontname_list) && fontsize_gui == fontsize_list && fontstyle_gui == fontstyle_list && fontweight_gui == fontweight_list))
		return;
	openfont (false);
	if (!listviewfont)
		return;
	for (int i = 0; i < listviewcnt; i++) {
		SendMessage (GetDlgItem (hDlg, listviews[i]), WM_SETFONT, WPARAM(listviewfont), FALSE);
	}
}
Exemple #7
0
Reffont*
rfget(int fix, int save, int setfont, char *name)
{
	Reffont *r;
	Font *f;
	int i;

	r = nil;
	if(name == nil){
		name = fontnames[fix];
		r = reffonts[fix];
	}
	if(r == nil){
		for(i=0; i<nfontcache; i++)
			if(strcmp(name, fontcache[i]->f->name) == 0){
				r = fontcache[i];
				goto Found;
			}
		f = openfont(display, name);
		if(f == nil){
			warning(nil, "can't open font file %s: %r\n", name);
			return nil;
		}
		r = emalloc(sizeof(Reffont));
		r->f = f;
		fontcache = erealloc(fontcache, (nfontcache+1)*sizeof(Reffont*));
		fontcache[nfontcache++] = r;
	}
    Found:
	if(save){
		incref(&r->ref);
		if(reffonts[fix])
			rfclose(reffonts[fix]);
		reffonts[fix] = r;
		if(name != fontnames[fix]){
			free(fontnames[fix]);
			fontnames[fix] = estrdup(name);
		}
	}
	if(setfont){
		reffont.f = r->f;
		incref(&r->ref);
		rfclose(reffonts[0]);
		font = r->f;
		reffonts[0] = r;
		incref(&r->ref);
		iconinit();
	}
	incref(&r->ref);
	return r;
}
Exemple #8
0
void
init(void)
{
	mailfs = nsmount("mail", nil);
	if(mailfs == nil)
		sysfatal("mount mail: %r");
	mousectl = initmouse(nil, screen);
	if(mousectl == nil)
		sysfatal("initmouse: %r");
	initplumb();

	/* make background color */
	bgrnd = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DWhite);
	blue = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x008888FF);	/* blue-green */
	left = allocimage(display, leftright, GREY1, 0, DWhite);
	right = allocimage(display, leftright, GREY1, 0, DWhite);
	if(bgrnd==nil || blue==nil || left==nil || right==nil){
		fprint(2, "faces: can't create images: %r\n");
		threadexitsall("image");
	}

	loadimage(left, leftright, leftdata, sizeof leftdata);
	loadimage(right, leftright, rightdata, sizeof rightdata);

	/* initialize little fonts */
	tinyfont = openfont(display, "/lib/font/bit/misc/ascii.5x7.font");
	if(tinyfont == nil)
		tinyfont = font;
	mediumfont = openfont(display, "/lib/font/bit/pelm/latin1.8.font");
	if(mediumfont == nil)
		mediumfont = font;
	datefont = font;

	facep.y += datefont->height;
	if(datefont->height & 1)	/* stipple parity */
		facep.y++;
	faces = nil;
}
Exemple #9
0
void
init(void)
{
	mousefd = open("/dev/mouse", OREAD);
	if(mousefd < 0){
		fprint(2, "faces: can't open mouse: %r\n");
		exits("mouse");
	}
	initplumb();

	/* make background color */
	bgrnd = allocimagemix(display, DPalebluegreen, DWhite);
	blue = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x008888FF);	/* blue-green */
	left = allocimage(display, leftright, GREY1, 0, DWhite);
	right = allocimage(display, leftright, GREY1, 0, DWhite);
	if(bgrnd==nil || blue==nil || left==nil || right==nil){
		fprint(2, "faces: can't create images: %r\n");
		exits("image");
	}

	loadimage(left, leftright, leftdata, sizeof leftdata);
	loadimage(right, leftright, rightdata, sizeof rightdata);

	/* initialize little fonts */
	tinyfont = openfont(display, "/lib/font/bit/misc/ascii.5x7.font");
	if(tinyfont == nil)
		tinyfont = font;
	mediumfont = openfont(display, "/lib/font/bit/pelm/latin1.8.font");
	if(mediumfont == nil)
		mediumfont = font;
	datefont = font;

	facep.y += datefont->height;
	if(datefont->height & 1)	/* stipple parity */
		facep.y++;
	faces = nil;
}
Exemple #10
0
void scaleresource_init (const TCHAR *prefix, int fullscreen)
{
	if (os_vista)
		font_vista_ok = 1;

	fontprefix = prefix;

	setdeffont ();

	regqueryfont (NULL, fontprefix, fontreg[0], fontname_gui, &fontsize_gui, &fontstyle_gui, &fontweight_gui);
	regqueryfont (NULL, fontprefix, fontreg[1], fontname_list, &fontsize_list, &fontstyle_list, &fontweight_list);

	//write_log (_T("GUI font %s:%d:%d:%d\n"), fontname_gui, fontsize_gui, fontstyle_gui, fontweight_gui);
	//write_log (_T("List font %s:%d:%d:%d\n"), fontname_list, fontsize_list, fontstyle_list, fontweight_list);

	getbaseunits (fullscreen);

	openfont (true);
}
Exemple #11
0
void
colinit(void)
{
	mediumfont = openfont(display, "/lib/font/bit/pelm/latin1.8.font");
	if(mediumfont == nil)
		mediumfont = font;

	/* Peach */
	mkcol(0, 0xFFAAAAFF, 0xFFAAAAFF, 0xBB5D5DFF);
	/* Aqua */
	mkcol(1, DPalebluegreen, DPalegreygreen, DPurpleblue);
	/* Yellow */
	mkcol(2, DPaleyellow, DDarkyellow, DYellowgreen);
	/* Green */
	mkcol(3, DPalegreen, DMedgreen, DDarkgreen);
	/* Blue */
	mkcol(4, 0x00AAFFFF, 0x00AAFFFF, 0x0088CCFF);
	/* Grey */
	cols[5][0] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xEEEEEEFF);
	cols[5][1] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xCCCCCCFF);
	cols[5][2] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x888888FF);
}
Exemple #12
0
void
iconinit(void)
{
	Rectangle r;

	/* Green */
	tagcols[BACK] = allocimagemix(display, DPalegreen, DWhite);
	if(tagcols[BACK] == nil)
		error("allocimagemix");
	tagcols[HIGH] = eallocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkgreen);
	tagcols[BORD] = eallocimage(display, Rect(0,0,1,1), screen->chan, 1, DMedgreen);
	tagcols[TEXT] = display->black;
	tagcols[HTEXT] = display->black;

	/* Grey */
	textcols[BACK] = display->white;
	textcols[HIGH] = eallocimage(display, Rect(0,0,1,1), CMAP8,1, 0xCCCCCCFF);
	textcols[BORD] = display->black;
	textcols[TEXT] = display->black;
	textcols[HTEXT] = display->black;

	r = Rect(0, 0, Scrollsize+2, font->height+1);
	button = eallocimage(display, r, screen->chan, 0, DNofill);
	draw(button, r, tagcols[BACK], nil, r.min);
	r.max.x -= 2;
	border(button, r, 2, tagcols[BORD], ZP);

	r = button->r;
	colbutton = eallocimage(display, r, screen->chan, 0, 0x00994CFF);

	but2col = eallocimage(display, Rect(0,0,1,2), screen->chan, 1, 0xAA0000FF);
	but3col = eallocimage(display, Rect(0,0,1,2), screen->chan, 1, 0x444488FF);

	passfont = openfont(display, fontnames[1]);
	if(passfont == nil)
		error("openfont");
}
Exemple #13
0
int
plotopen(void)
{
	if(display != nil)
		return 1;
	display = initdisplay(nil, nil, drawerror);
	if(display == nil){
		fprint(2, "initdisplay failed: %r\n");
		return -1;
	}
	grey = allocimage(display, Rect(0, 0, 1, 1), CMAP8, 1, 0x777777FF);
	lightgrey = allocimage(display, Rect(0, 0, 1, 1), CMAP8, 1, 0xAAAAAAFF);
	alphagrey = allocimage(display, Rect(0, 0, 2, 2), RGBA32, 1, 0x77777777);
	green = allocimage(display, Rect(0, 0, 1, 1), CMAP8, 1, 0x00AA00FF);
	lightblue = allocimage(display, Rect(0, 0, 1, 1), CMAP8, 1, 0x009EEEFF);
	ocstipple = allocimage(display, Rect(0, 0, 2, 2), CMAP8, 1, 0xAAAAAAFF);
	draw(ocstipple, Rect(0, 0, 1, 1), display->black, nil, ZP);
	draw(ocstipple, Rect(1, 1, 2, 2), display->black, nil, ZP);

	suncolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0xFFFF77FF);
	mooncolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0xAAAAAAFF);
	shadowcolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0x00000055);
	mercurycolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0xFFAAAAFF);
	venuscolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0xAAAAFFFF);
	marscolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0xFF5555FF);
	jupitercolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0xFFFFAAFF);
	saturncolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0xAAFFAAFF);
	uranuscolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0x77DDDDFF);
	neptunecolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0x77FF77FF);
	plutocolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0x7777FFFF);
	cometcolor = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, 0xAAAAFFFF);
	font = openfont(display, fontname);
	if(font == nil)
		fprint(2, "warning: no font %s: %r\n", fontname);
	return 1;
}
Exemple #14
0
static void
loadfont(int n, int s)
{
    char file[256];
    int i, fd, t, deep;
    static char *try[3] = {"", "times/R.", "pelm/"};
    Subfont *f;
    Font *ff;

    try[0] = fname[n];
    for (t = 0; t < 3; t++) {
        i = s * mag * charmap[fmap[n]].xheight/0.72;	/* a pixel is 0.72 points */
        if (i < MINSIZE)
            i = MINSIZE;
        dprint(2, "size %d, i %d, mag %g\n", s, i, mag);
        for(; i >= MINSIZE; i--) {
            /* if .font file exists, take that */
            snprint(file, sizeof file, "%s/%s%d.font",
                    libfont, try[t], i);
            ff = openfont(display, file);
            if(ff != 0) {
                fonttab[n][s] = ff;
                dprint(2, "using %s for font %d %d\n", file, n, s);
                return;
            }
            /* else look for a subfont file */
            for (deep = log2[screen->depth]; deep >= 0; deep--) {
                snprint(file, sizeof file, "%s/%s%d.%d",
                        libfont, try[t], i, deep);
                dprint(2, "trying %s for %d\n", file, i);
                if ((fd = open(file, 0)) >= 0) {
                    f = readsubfont(display, file, fd, 0);
                    if (f == 0) {
                        fprint(2, "can't rdsubfontfile %s: %r\n", file);
                        exits("rdsubfont");
                    }
                    close(fd);
                    ff = mkfont(f, 0);
                    if(ff == 0) {
                        fprint(2, "can't mkfont %s: %r\n", file);
                        exits("rdsubfont");
                    }
                    fonttab[n][s] = ff;
                    dprint(2, "using %s for font %d %d\n", file, n, s);
                    return;
                }
            }
        }
    }
    fprint(2, "can't find font %s.%d or substitute, quitting\n", fname[n], s);
    exits("no font");
}

void
loadfontname(int n, char *s)
{
    int i;
    Font *f, *g = 0;

    if (strcmp(s, fname[n]) == 0)
        return;
    if(fname[n] && fname[n][0]) {
        if(lastload[n] && strcmp(lastload[n], fname[n]) == 0)
            return;
        strcpy(lastload[n], fname[n]);
    }
    fontlookup(n, s);
    for (i = 0; i < NSIZE; i++)
        if (f = fonttab[n][i]) {
            if (f != g) {
                freefont(f);
                g = f;
            }
            fonttab[n][i] = 0;
        }
}

void
allfree(void)
{
    int i;

    for (i=0; i<NFONT; i++)
        loadfontname(i, "??");
}


void
readmapfile(char *file)
{
    Biobuf *fp;
    char *p, cmd[100];

    if ((fp=Bopen(file, OREAD)) == 0) {
        fprint(2, "proof: can't open map file %s\n", file);
        exits("urk");
    }
    while((p=Brdline(fp, '\n')) != 0) {
        p[Blinelen(fp)-1] = 0;
        scanstr(p, cmd, 0);
        if(p[0]=='\0' || eq(cmd, "#"))	/* skip comments, empty */
            continue;
        else if(eq(cmd, "xheight"))
            buildxheight(fp);
        else if(eq(cmd, "map"))
            buildmap(fp);
        else if(eq(cmd, "special"))
            buildtroff(p);
        else if(eq(cmd, "troff"))
            buildtroff(p);
        else
            fprint(2, "weird map line %s\n", p);
    }
    Bterm(fp);
}
Exemple #15
0
int
geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *label, char *windir, int ref)
{
	int fd, n;
	Subfont *df;
	char buf[128];

	display = initdisplay(devdir, windir, error);
	if(display == nil)
		return -1;

	/*
	 * Set up default font
	 */
	df = getdefont(display);
	display->defaultsubfont = df;
	if(df == nil){
		fprint(2, "imageinit: can't open default subfont: %r\n");
    Error:
		closedisplay(display);
		display = nil;
		return -1;
	}
	if(fontname == nil){
		fd = open("/env/font", OREAD);
		if(fd >= 0){
			n = read(fd, buf, sizeof(buf));
			if(n>0 && n<sizeof buf-1){
				buf[n] = 0;
				fontname = buf;
			}
			close(fd);
		}
	}
	/*
	 * Build fonts with caches==depth of screen, for speed.
	 * If conversion were faster, we'd use 0 and save memory.
	 */
	if(fontname == nil){
		snprint(buf, sizeof buf, "%d %d\n0 %d\t%s\n", df->height, df->ascent,
			df->n-1, deffontname);
//BUG: Need something better for this	installsubfont("*default*", df);
		font = buildfont(display, buf, deffontname);
		if(font == nil){
			fprint(2, "imageinit: can't open default font: %r\n");
			goto Error;
		}
	}else{
		font = openfont(display, fontname);	/* BUG: grey fonts */
		if(font == nil){
			fprint(2, "imageinit: can't open font %s: %r\n", fontname);
			goto Error;
		}
	}
	display->defaultfont = font;

	/*
	 * Write label; ignore errors (we might not be running under rio)
	 */
	if(label){
		snprint(buf, sizeof buf, "%s/label", display->windir);
		fd = open(buf, OREAD);
		if(fd >= 0){
			read(fd, display->oldlabel, (sizeof display->oldlabel)-1);
			close(fd);
			fd = create(buf, OWRITE, 0666);
			if(fd >= 0){
				write(fd, label, strlen(label));
				close(fd);
			}
		}
	}

	snprint(buf, sizeof buf, "%s/winname", display->windir);
	if(gengetwindow(display, buf, &screen, &_screen, ref) < 0)
		goto Error;

	atexit(drawshutdown);

	return 1;
}
Exemple #16
0
void
getwidth(void)
{
	CFsys *fs;
	char buf[500], *p, *q, *f[10];
	int fd, n, nf;
	struct winsize ws;
	Font *f1;

	if((p = getenv("winid")) != nil){
		fs = nsmount("acme", "");
		if(fs == nil)
			return;
		snprint(buf, sizeof buf, "acme/%d/ctl", atoi(p));
		if((fd = fsopenfd(fs, buf, OREAD)) < 0)
			return;
		if((n=readn(fd, buf, sizeof buf-1)) <= 0)
			return;
		buf[n] = 0;
		if((nf=tokenize(buf, f, nelem(f))) < 7)
			return;
		tabwid = 0;
		if(nf >= 8 && (tabwid = atoi(f[7])) == 0)
			return;
		if((font = openfont(nil, f[6])) == nil)
			return;
		mintab = stringwidth(font, "0");
		if(tabwid == 0)
			tabwid = mintab*4;
		linewidth = atoi(f[5]);
		tabflag = 1;
		return;
	}

	if((p = getenv("termprog")) != nil && strcmp(p, "9term") == 0)
	if((p = getenv("font")) != nil)
		font = openfont(nil, p);

	if(windowrect(&ws) < 0)
		return;
	if(ws.ws_xpixel == 0)
		font = nil;
	if(font){
		// 9term leaves "is this a hidpi display" in the low bit of the ypixel height.
		if(ws.ws_ypixel&1) {
			// need hidpi font.
			// loadhifpi creates a font that crashes in stringwidth,
			// for reasons i don't understand.
			// do it ourselves
			p = getenv("font");
			q = strchr(p, ',');
			f1 = nil;
			if(q != nil)
				f1 = openfont(nil, q+1);
			if(f1 != nil)
				font = f1;
			else
				ws.ws_xpixel /= 2;
		}
		mintab = stringwidth(font, "0");
		if((p = getenv("tabstop")) != nil)
			tabwid = atoi(p)*mintab;
		else
			tabwid = 4*mintab;
		tabflag = 1;
		linewidth = ws.ws_xpixel;
	}else
		linewidth = ws.ws_col;
}