Commit 6acb88ca authored by Charlie Fenton's avatar Charlie Fenton

API, SCR: Switch from *.txf fonts to TrueType fonts in graphics apps, ensuring...

API, SCR: Switch from *.txf fonts to TrueType fonts in graphics apps, ensuring that all related files have no licensing issues

svn path=/trunk/boinc/; revision=25939
parent da7e40f1
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Source: http://boinc.berkeley.edu/source_code.php
// Copyright(C) 2002-2007 University of California
// Copyright(C) 2002-2012 University of California
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
......@@ -22,31 +22,40 @@
// wxWidgets Library Licence, Version 3.1
// http://www.wxwidgets.org/
// Source: http://www.wxwidgets.org/
// Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al
// Copyright (c) 1998-2012 Julian Smart, Robert Roebling et al
//
//
// cURL & libCURL
// http://curl.haxx.se/
// Source: http://curl.haxx.se/
// Copyright (c) 1996 - 2006, Daniel Stenberg, <daniel@haxx.se>.
// Copyright (c) 1996 - 2012, Daniel Stenberg, <daniel@haxx.se>.
//
//
// OpenSSL & SSLeay
// http://www.openssl.org/
// Source: http://www.openssl.org/
// Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
// Copyright (c) 1998-2012 The OpenSSL Project. All rights reserved.
// Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
//
//
// zLib Commpression Library
// http://www.zlib.org
// Source: http://www.zlib.org
// Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
// Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
//
//
// International Components for Unicode
// http://www.icu-project.org/
// Source: http://www.icu-project.org/
// Copyright &copy; 1997-2009 International Business Machines Corporation and others. All Rights Reserved.
// Copyright &copy; 1995-2012 International Business Machines Corporation and others. All Rights Reserved.
//
//
// Liberation Fonts
// https://fedorahosted.org/liberation-fonts/
// Source: https://fedorahosted.org/liberation-fonts/
// Digitized data copyright (c) 2010 Google Corporation
// with Reserved Font Arimo, Tinos and Cousine.
// Copyright (c) 2012 Red Hat, Inc.
// with Reserved Font Name Liberation.
//
//
......@@ -29,7 +29,6 @@
#ifdef _WIN32
#ifndef SANS_JPEGLIB
#ifdef __cplusplus
extern "C" {
#include "jpeglib.h"
......@@ -37,7 +36,6 @@ extern "C" {
#else
#include "jpeglib.h"
#endif
#endif
#include "bmplib.h"
#include "tgalib.h"
......@@ -54,11 +52,9 @@ extern "C" {
#include <alloca.h>
#endif
#ifndef SANS_JPEGLIB
extern "C"{
#include <jpeglib.h>
}
#endif
#endif
......@@ -655,7 +651,6 @@ void printdata(const char* filename, int x, int y, unsigned char* data) {
}
#endif
#ifndef SANS_JPEGLIB
void DecodeJPG(jpeg_decompress_struct* cinfo, tImageJPG *pImageData) {
jpeg_read_header(cinfo, TRUE);
jpeg_start_decompress(cinfo);
......@@ -753,7 +748,6 @@ int TEXTURE_DESC::CreateTextureJPG(const char* strFileName) {
}
return 0;
}
#endif
#ifdef _WIN32
int TEXTURE_DESC::CreateTextureBMP(const char* strFileName) {
......@@ -797,25 +791,6 @@ int TEXTURE_DESC::CreateTexturePPM(const char* strFileName) {
}
int TEXTURE_DESC::CreateTextureRGB(const char* strFileName) {
if(!strFileName) return -1;
int sizeX;
int sizeY;
int sizeZ;
// Load the image and store the data
unsigned int *pImage = read_rgb_texture(strFileName,&sizeX,&sizeY,&sizeZ);
if(pImage == NULL) return -1;
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glGenTextures(1, (GLuint*)&id);
glBindTexture(GL_TEXTURE_2D, id);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, sizeX, sizeY, GL_RGBA, GL_UNSIGNED_BYTE, pImage);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
if (pImage)
free(pImage);
return 0;
}
#ifdef _WIN32
int TEXTURE_DESC::CreateTextureTGA(const char* strFileName) {
if(!strFileName) // Return from the function if no file name was passed in
......@@ -860,13 +835,11 @@ int TEXTURE_DESC::load_image_file(const char* filename) {
// for now, just try all the image types in turn
present = true;
#ifndef SANS_JPEGLIB
retval = CreateTextureJPG(filename);
if (!retval) {
fprintf(stderr, "Successfully loaded '%s'.\n", filename);
return 0;
}
#endif
#ifdef _WIN32
retval = CreateTexturePPM(filename);
if (!retval) {
......@@ -884,12 +857,6 @@ int TEXTURE_DESC::load_image_file(const char* filename) {
return 0;
}
#endif
retval = CreateTextureRGB(filename);
if (!retval) {
fprintf(stderr, "Successfully loaded '%s'.\n", filename);
return 0;
}
done:
present = false;
fprintf(stderr, "Failed to load '%s'.\n", filename);
......
......@@ -219,7 +219,6 @@ struct TEXTURE_DESC {
int CreateTextureBMP(const char* strFileName);
int CreateTexturePPM(const char* strFileName);
int CreateTextureTGA(const char* strFileName);
int CreateTextureRGB(const char* strFileName);
};
......
This diff is collapsed.
// Copyright (c) Mark J. Kilgard, 1997.
// This program is freely distributable without licensing fees and is
// provided without guarantee or warrantee expressed or implied.
// This program is -not- in the public domain.
#ifndef __TEXFONT_H__
#define __TEXFONT_H__
#include "boinc_gl.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TXF_FORMAT_BYTE 0
#define TXF_FORMAT_BITMAP 1
#define TXF_NUM_FONT 28
extern const char *font_names [];
typedef struct {
unsigned short c; // Potentially support 16-bit glyphs.
unsigned char width;
unsigned char height;
signed char xoffset;
signed char yoffset;
signed char advance;
char dummy; // Space holder for alignment reasons.
short x;
short y;
} TexGlyphInfo;
typedef struct {
GLfloat t0[2];
GLshort v0[2];
GLfloat t1[2];
GLshort v1[2];
GLfloat t2[2];
GLshort v2[2];
GLfloat t3[2];
GLshort v3[2];
GLfloat advance;
} TexGlyphVertexInfo;
typedef struct {
GLuint texobj;
int tex_width;
int tex_height;
int max_ascent;
int max_descent;
int num_glyphs;
int min_glyph;
int range;
unsigned char *teximage;
TexGlyphInfo *tgi;
TexGlyphVertexInfo *tgvi;
TexGlyphVertexInfo **lut;
} TexFont;
extern const char *txfErrorString(void);
extern TexFont *txfLoadFont(const char *filename);
extern void txfUnloadFont(TexFont * txf);
extern GLuint CreateTexFont(
TexFont * txf,
GLuint texobj,
GLboolean setupMipmaps);
extern void txfBindFontTexture(TexFont * txf);
extern void txfGetStringMetrics(
TexFont * txf,
char *string,
int len,
int *width,
int *max_ascent,
int *max_descent);
extern void txfRenderGlyph(
TexFont * txf,
int c);
extern void txfRenderString(
TexFont * txf,
char *string,
int len);
extern void txfRenderFancyString(
TexFont * txf,
char *string,
int len);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __TEXFONT_H__
This diff is collapsed.
......@@ -28,45 +28,37 @@
// this should basically be a drop-in for the old boinc txf_* functions i.e.
// txf_load_font and txf_render_string, with extra options on the latter for rotating etc
// adapted by Carl Christensen
// originally adapted by Carl Christensen
#ifndef _TTFONT_H_
#define _TTFONT_H_
#include "qcn_graphics.h"
#include "boinc_gl.h"
#include <FTGL/ftgl.h>
// I put in it's own namespace so call TTFont::ttf_load_fonts() etc
namespace TTFont {
extern FTFont* g_font[NUM_FONT];
extern int g_iFont;
extern void ttf_load_fonts(const char* dir = NULL, const char* strScaleFont = NULL, const int& iScaleFont =30);
extern void ttf_render_string(
const double& alpha_value,
// reference value to which incoming alpha values are compared.
// 0 through to 1
const double& x,
const double& y,
const double& z, // text position
const double& z, // text position
const float& fscale, // scale factor
const GLfloat * col, // colour
const int& iFont, // font index
const char* s, // string ptr
const float& fRotAngle = 0.0f, // optional rotation angle
const float& fRotX = 0.0f, // optional rotation vector for X
const float& fRotY = 0.0f, // optional rotation vector for Y
const float& fRotZ = 1.0f, // optional rotation vector for Z
const float& fRadius = 0.0f // circular radius to draw along
const GLfloat * col, // colour
const char* s, // string ptr
const int& iFont = 0, // font index
const float& fRotAngle = 0.0f, // optional rotation angle
const float& fRotX = 0.0f, // optional rotation vector for X
const float& fRotY = 0.0f, // optional rotation vector for Y
const float& fRotZ = 1.0f, // optional rotation vector for Z
const float& fRadius = 0.0f // circular radius to draw along
);
void ttf_cleanup();
GLuint CreateRGBAlpha(const char* strFileName);
GLuint CreateRGBTransparentTexture(const char* strFileName, float* transColor = NULL); // default in prototype to transColor = NULL i.e. no "filter color" required
} // namespace
#endif // inclusion
......
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// Interface functions for tex_info stuff.
// Contributed by Tolu Aina
#ifdef _WIN32
#include "boinc_win.h"
#endif
#include <cstring>
#include "filesys.h"
#include "boinc_api.h"
#include "texfont.h"
#include "txf_util.h"
#ifndef _MAX_PATH
#define _MAX_PATH 256
#endif
static TexFont* txf[TXF_NUM_FONT];
// load fonts. call once.
//
void txf_load_fonts(char* dir) {
char vpath[_MAX_PATH], phys_path[_MAX_PATH];
for (int i=0 ; i<TXF_NUM_FONT; i++){
sprintf(vpath, "%s/%s", dir, font_names[i]);
boinc_resolve_filename(vpath, phys_path, sizeof(phys_path));
if (is_file(phys_path)) {
txf[i] = txfLoadFont(phys_path);
if(txf[i]) {
fprintf(stderr, "Successfully loaded '%s'...\n", phys_path);
CreateTexFont(txf[i], 0, GL_TRUE);
} else {
fprintf(stderr, "Failed to load '%s' error message: '%s'...\n", phys_path, txfErrorString());
}
}
}
}
void txf_render_string(
float alpha_value,
// reference value to which incoming alpha values are compared.
// 0 through to 1
double x, double y, double z, // text position
float fscale, // scale factor
GLfloat * col, // colour
int i, // font index see texfont.h
char * s, // string ptr
float fRotAngle, // optional rotation angle
float fRotX, // optional rotation vector for X
float fRotY, // optional rotation vector for Y
float fRotZ // optional rotation vector for Z
){
// if requested font isn't available, find first one that is
//
while((i < TXF_NUM_FONT) && !txf[i]) i++;
if((i >= TXF_NUM_FONT) || !txf[i]) {
// bad font index
return;
}
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, txf[i]->texobj);
glTranslated(x, y, z);
glScalef(1/fscale, 1/fscale, 1/fscale);
if (fRotAngle != 0.0f) {
// we want to rotate around Z y default,
// which keeps our text in 2D plane
glRotatef(fRotAngle, fRotX, fRotY, fRotZ);
}
glEnable(GL_ALPHA_TEST);
// use .1 and .5 for a dark and bright background respectively
glAlphaFunc(GL_GEQUAL, alpha_value);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glColor4fv(col);
txfRenderString(txf[i], s, (int)strlen(s));
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}
#if 0
int main (){
// usage:
// first parameter is alpha value : use .1 and .5 for dark and bright background seems to work
// 7th can probably be list of #defines of font names.
render_string(.1f, -1, -1, 0, 200.0f, white, 0, "hello world.");
}
#endif
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// Interface functions for tex_info stuff.
// Contributed by Tolu Aina
#ifndef _TXF_UTIL_
#define _TXF_UTIL_
#ifdef __cplusplus
extern "C" {
#endif
extern void txf_load_fonts(char* dir);
extern void txf_render_string(
float alpha_value,
// reference value to which incoming alpha values are compared.
// 0 through to 1
double x, double y, double z, // text position
float fscale, // scale factor
GLfloat * col, // colour
int i, // font index see texfont.h
char * s, // string ptr
float fRotAngle = 0.0f, // optional rotation angle
float fRotX = 0.0f, // optional rotation vector for X
float fRotY = 0.0f, // optional rotation vector for Y
float fRotZ = 1.0f // optional rotation vector for Z
);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
......@@ -5084,8 +5084,8 @@ Charlie 27 July 2012
libraries; eliminate extra output from wxMac build script.
mac_build/
buildfreetype.sh
buildFTGL.sh
buildfreetype.sh (new)
buildFTGL.sh (new)
buildWxMac.sh
setupforBOINC.sh
......@@ -5129,3 +5129,25 @@ David 1 Aug 2012
feeder.cpp
vda/
ssim.cpp
Charlie 1 Aug 2012
- API, SCR: Switch from *.txf fonts to TrueType fonts in graphics
applications, ensuring that all related files have no licensing
issues.
/
COPYRIGHT
api/
gutil/cpp,.h
ttfont.cpp,.h
texfont.cpp,.h (deleted)
txf_util.cpp,.h (deleted)
txf/
*.txf (deleted)
clientscr/
ss_app.cpp
mac_build/
boinc.xcodeproj/
project.pbxproj
mac_installer/
release_boinc.sh
......@@ -32,10 +32,11 @@
#endif
#include "diagnostics.h"
#include "ttfont.h"
#include "gutil.h"
#include "boinc_gl.h"
#include "graphics2.h"
#include "txf_util.h"
//#include "txf_util.h"
#include "network.h"
#include "gui_rpc_client.h"
#include "util.h"
......@@ -44,17 +45,19 @@
using std::string;
using std::vector;
using TTFont::ttf_render_string;
using TTFont::ttf_load_fonts;
// text sizes - larger is smaller (???)
#define TASK_INTRO_SIZE 1000.
#define TASK_NONE_SIZE 500.
#define TASK_INTRO_SIZE 1200.
#define TASK_NONE_SIZE 600.
#define TASK_NONE_REASON_SIZE 800.
#define TASK_PROJ_SIZE 1000.
#define TASK_INFO_SIZE 1200.
#define PROJ_INTRO_SIZE 800.
#define PROJ_NAME_SIZE 500.
#define PROJ_INFO_SIZE 800.
#define ALERT_SIZE 800.
#define TASK_PROJ_SIZE 1200.
#define TASK_INFO_SIZE 1350.
#define PROJ_INTRO_SIZE 900.
#define PROJ_NAME_SIZE 600.
#define PROJ_INFO_SIZE 900.
#define ALERT_SIZE 900.
float white[4] = {1., 1., 1., 1.};
TEXTURE_DESC logo;
......@@ -180,7 +183,7 @@ static void draw_logo(float* pos, float alpha) {
void show_result(RESULT* r, float x, float& y, float alpha) {
PROGRESS_2D progress;
char buf[256];
txf_render_string(.1, x, y, 0, TASK_PROJ_SIZE, white, 0, (char*)r->project->project_name.c_str());
ttf_render_string(x, y, 0, TASK_PROJ_SIZE, white, (char*)r->project->project_name.c_str());
y -= .02;
float prog_pos[] = {x, y, 0};
float prog_c[] = {.5, .4, .1, alpha/2};
......@@ -188,14 +191,14 @@ void show_result(RESULT* r, float x, float& y, float alpha) {
progress.init(prog_pos, .4, -.01, -0.008, prog_c, prog_ci);
progress.draw(r->fraction_done);
sprintf(buf, "%.2f%% ", r->fraction_done*100);
txf_render_string(.1, x+.41, y, 0, TASK_INFO_SIZE, white, 0, buf);
ttf_render_string(x+.41, y, 0, TASK_INFO_SIZE, white, buf);
y -= .03;
x += .05;
sprintf(buf, "Elapsed: %.0f sec Remaining: %.0f sec", r->elapsed_time, r->estimated_cpu_time_remaining);
txf_render_string(.1, x, y, 0, TASK_INFO_SIZE, white, 0, buf);
ttf_render_string(x, y, 0, TASK_INFO_SIZE, white, buf);
y -= .03;
sprintf(buf, "App: %s Task: %s", r->app->user_friendly_name, r->wup->name);
txf_render_string(.1, x, y, 0, TASK_INFO_SIZE, white, 0, buf);
ttf_render_string(x, y, 0, TASK_INFO_SIZE, white, buf);
y -= .03;
}
......@@ -206,12 +209,12 @@ void show_coords() {
for (i=-100; i< 101; i+=5) {
sprintf(buf, "%d", i);
float x = (float)i/100;
txf_render_string(.1, x, 0, 0, 1000., white, 0, buf);
ttf_render_string(x, 0, 0, 1000., white, buf);
}
for (i=-100; i< 101; i+=5) {
sprintf(buf, "%d", i);
float y = (float)i/100;
txf_render_string(.1, 0, y, 0, 1000., white, 0, buf);
ttf_render_string(0, y, 0, 1000., white, buf);
}
}
#endif
......@@ -219,26 +222,26 @@ void show_coords() {
void show_project(unsigned int index, float alpha) {
float x=.2, y=.6;
char buf[1024];
txf_render_string(.1, x, y, 0, PROJ_INTRO_SIZE, white, 0, "This computer is participating in");
ttf_render_string(x, y, 0, PROJ_INTRO_SIZE, white, "This computer is participating in");
y -= .07;
PROJECT *p = cc_state.projects[index];
txf_render_string(.1, x, y, 0, PROJ_NAME_SIZE, white, 0, (char*)p->project_name.c_str());
ttf_render_string(x, y, 0, PROJ_NAME_SIZE, white, (char*)p->project_name.c_str());
y -= .07;
txf_render_string(.1, x, y, 0, PROJ_INFO_SIZE, white, 0, p->master_url);
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, p->master_url);
y -= .05;
sprintf(buf, "User: %s", p->user_name.c_str());
txf_render_string(.1, x, y, 0, PROJ_INFO_SIZE, white, 0, buf);
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, buf);
y -= .05;
if (p->team_name.size()) {
sprintf(buf, "Team: %s", p->team_name.c_str());
txf_render_string(.1, x, y, 0, PROJ_INFO_SIZE, white, 0, buf);
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, buf);
y -= .05;
}
sprintf(buf, "Total credit: %.0f Average credit: %.0f", p->user_total_credit, p->user_expavg_credit);
txf_render_string(.1, x, y, 0, PROJ_INFO_SIZE, white, 0, buf);
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, buf);
y -= .05;
if (p->suspended_via_gui) {
txf_render_string(.1, x, y, 0, PROJ_INFO_SIZE, white, 0, "Suspended");
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, "Suspended");
}
}
......@@ -246,17 +249,17 @@ void show_disconnected() {
float x=.3, y=.3;
char buf[256];
sprintf(buf, "%s is not running.", brand_name);
txf_render_string(.1, x, y, 0, ALERT_SIZE, white, 0, buf);
ttf_render_string(x, y, 0, ALERT_SIZE, white, buf);
}
void show_no_projects() {
float x=.2, y=.3;
char buf[256];
sprintf(buf, "%s is not attached to any projects.", brand_name);
txf_render_string(.1, x, y, 0, ALERT_SIZE, white, 0, buf);
ttf_render_string(x, y, 0, ALERT_SIZE, white, buf);
y = .25;
sprintf(buf, "Attach to projects using %s.", brand_name);
txf_render_string(.1, x, y, 0, ALERT_SIZE, white, 0, buf);
ttf_render_string(x, y, 0, ALERT_SIZE, white, buf);
}
#define MAX_JOBS_DISPLAY 4
......@@ -277,7 +280,7 @@ void show_jobs(unsigned int index, double alpha) {
if (!r->active_task) continue;
if (r->scheduler_state != CPU_SCHED_SCHEDULED) continue;
if (!nfound) {
txf_render_string(.1, x, y, 0, TASK_INTRO_SIZE, white, 0, "Running tasks:");
ttf_render_string(x, y, 0, TASK_INTRO_SIZE, white, "Running tasks:");
y -= .05;
}
show_result(r, x, y, alpha);
......@@ -288,7 +291,7 @@ void show_jobs(unsigned int index, double alpha) {
}
if (!nfound) {
y = .5;
txf_render_string(.1, x, y, 0, TASK_NONE_SIZE, white, 0, "No running tasks");
ttf_render_string(x, y, 0, TASK_NONE_SIZE, white, "No running tasks");
char *p = 0;
switch (cc_status.task_suspend_reason) {
case SUSPEND_REASON_BATTERIES:
......@@ -318,7 +321,7 @@ void show_jobs(unsigned int index, double alpha) {
}
if (p) {
y -= .1;
txf_render_string(.1, x, y, 0, TASK_NONE_REASON_SIZE, white, 0, p);
ttf_render_string(x, y, 0, TASK_NONE_REASON_SIZE, white, p);
}
}
}
......@@ -462,7 +465,7 @@ void boinc_app_key_release(int, int){}
void app_graphics_init() {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
txf_load_fonts(".");
ttf_load_fonts(".");
#ifdef _WCG
logo.load_image_file("wcg.bmp");
#else
......
This diff is collapsed.
......@@ -29,7 +29,7 @@
## updated 12/2/11 by Charlie Fenton to restore wrapper and reboot if needed