curvedraw

diff src/widgets.cc @ 16:7f795f7fecd6

readme and COPYING
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 20 Dec 2015 10:55:57 +0200
parents 2b7ae76c173f
children
line diff
     1.1 --- a/src/widgets.cc	Sun Dec 20 09:06:04 2015 +0200
     1.2 +++ b/src/widgets.cc	Sun Dec 20 10:55:57 2015 +0200
     1.3 @@ -1,3 +1,20 @@
     1.4 +/*
     1.5 +curvedraw - a simple program to draw curves
     1.6 +Copyright (C) 2015  John Tsiombikas <nuclear@member.fsf.org>
     1.7 +
     1.8 +This program is free software: you can redistribute it and/or modify
     1.9 +it under the terms of the GNU General Public License as published by
    1.10 +the Free Software Foundation, either version 3 of the License, or
    1.11 +(at your option) any later version.
    1.12 +
    1.13 +This program is distributed in the hope that it will be useful,
    1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 +GNU General Public License for more details.
    1.17 +
    1.18 +You should have received a copy of the GNU General Public License
    1.19 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.20 +*/
    1.21  #include <stdio.h>
    1.22  #include <stdlib.h>
    1.23  #include <string.h>
    1.24 @@ -11,16 +28,24 @@
    1.25  #include "opengl.h"
    1.26  #include "widgets.h"
    1.27  
    1.28 +#define FONT_FILE	"data/droid_sans.ttf"
    1.29 +#define FONT_SIZE	24
    1.30 +
    1.31  static dtx_font *font;
    1.32  
    1.33 -static void init_font()
    1.34 +static bool init_font()
    1.35  {
    1.36 -	if(font) return;
    1.37 +	if(font) return true;
    1.38  
    1.39 -	if(!(font = dtx_open_font("data/droid_sans.ttf", 24))) {
    1.40 -		fprintf(stderr, "failed to load font\n");
    1.41 -		abort();
    1.42 +	if(!(font = dtx_open_font(FONT_FILE, FONT_SIZE))) {
    1.43 +		static bool msg_printed;
    1.44 +		if(!msg_printed) {
    1.45 +			fprintf(stderr, "failed to load font %s\n", FONT_FILE);
    1.46 +			msg_printed = true;
    1.47 +		}
    1.48 +		return false;
    1.49  	}
    1.50 +	return true;
    1.51  }
    1.52  
    1.53  Widget::Widget()
    1.54 @@ -74,7 +99,7 @@
    1.55  
    1.56  void Label::draw() const
    1.57  {
    1.58 -	init_font();
    1.59 +	if(!init_font()) return;
    1.60  
    1.61  	glMatrixMode(GL_MODELVIEW);
    1.62  	glPushMatrix();