Skip to content

Commit 344039d

Browse files
committed
Finished opening a window
1 parent d74c98a commit 344039d

File tree

1,750 files changed

+146860
-11937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,750 files changed

+146860
-11937
lines changed

.gitignore

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
1-
# Compiled Object files
2-
*.slo
3-
*.lo
1+
*/build/*
2+
*/dist/*
3+
*/nbproject/private/*
4+
/.project
45
*.o
5-
*.obj
6+
*.gz
7+
*.ilk
8+
*.pdb
9+
*.tlog
10+
*.manifest
11+
*.res
12+
*.user
13+
*.lastbuildstate
614
*.sdf
7-
8-
# Precompiled Headers
9-
*.gch
10-
*.pch
11-
12-
# Compiled Dynamic libraries
13-
*.so
14-
*.dylib
15-
*.dll
16-
17-
# Fortran module files
18-
*.mod
19-
*.smod
20-
21-
# Compiled Static libraries
22-
*.lai
23-
*.la
24-
*.a
25-
*.lib
26-
27-
# Executables
15+
*.suo
16+
*.rc
2817
*.exe
29-
*.out
30-
*.app
31-
32-
# Temporary Files
33-
#================
34-
35-
/Debug
36-
/Release
37-
/x64
38-
/x86
39-
40-
# Resource files
41-
/Resources
18+
/*.log
19+
*.cache
20+
*.idb
21+
Makefile-Release.mk
22+
*.obj
23+
24+
*.log
25+
26+
*.ipch
27+
28+
*.unsuccessfulbuild
29+
30+
*.opensdf

.vs/OpenGL/v14/.suo

-54.5 KB
Binary file not shown.

Common/.dep.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This code depends on make tool being used
2+
DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
3+
ifneq (${DEPFILES},)
4+
include ${DEPFILES}
5+
endif

Common/FreetypeGL/font-manager.c

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
/* =========================================================================
2+
* Freetype GL - A C OpenGL Freetype engine
3+
* Platform: Any
4+
* WWW: http://code.google.com/p/freetype-gl/
5+
* -------------------------------------------------------------------------
6+
* Copyright 2011 Nicolas P. Rougier. All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright
15+
* notice, this list of conditions and the following disclaimer in the
16+
* documentation and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR
19+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
21+
* EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* The views and conclusions contained in the software and documentation are
30+
* those of the authors and should not be interpreted as representing official
31+
* policies, either expressed or implied, of Nicolas P. Rougier.
32+
* ========================================================================= */
33+
#include <fontconfig/fontconfig.h>
34+
#include <assert.h>
35+
#include <stdio.h>
36+
#include <wchar.h>
37+
#include "font-manager.h"
38+
39+
#ifdef __cplusplus
40+
extern "C" {
41+
#endif
42+
43+
44+
wchar_t *
45+
wcsdup( const wchar_t *string )
46+
{
47+
wchar_t * result;
48+
assert( string );
49+
result = (wchar_t *) malloc( (wcslen(string) + 1) * sizeof(wchar_t) );
50+
wcscpy( result, string );
51+
return result;
52+
}
53+
54+
55+
FontManager *
56+
font_manager_new( size_t width, size_t height, size_t depth )
57+
{
58+
FontManager *self = NULL;
59+
60+
TextureAtlas *atlas = texture_atlas_new( width, height, depth );
61+
self = (FontManager *) malloc( sizeof(FontManager) );
62+
if( !self )
63+
{
64+
return 0;
65+
}
66+
self->atlas = atlas;
67+
self->fonts = vector_new( sizeof(TextureFont) );
68+
self->cache = wcsdup( L" " );
69+
/*
70+
self->cache = wcsdup( L" !\"#$%&'()*+,-./0123456789:;<=>?"
71+
L"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
72+
L"`abcdefghijklmnopqrstuvwxyz{|}~" );
73+
*/
74+
75+
return self;
76+
}
77+
78+
void
79+
font_manager_delete( FontManager *self )
80+
{
81+
assert( self );
82+
vector_delete( self->fonts );
83+
texture_atlas_delete( self->atlas );
84+
if( self->cache )
85+
{
86+
free( self->cache );
87+
}
88+
free( self );
89+
}
90+
91+
TextureFont *
92+
font_manager_get_from_filename( FontManager *self,
93+
const char * filename,
94+
const float size )
95+
{
96+
size_t i;
97+
TextureFont *font;
98+
99+
assert( self );
100+
101+
for( i=0; i<self->fonts->size;++i )
102+
{
103+
font = (TextureFont *) vector_get( self->fonts, i );
104+
if( (strcmp(font->filename, filename) == 0) && ( font->size == size) )
105+
{
106+
return font;
107+
}
108+
}
109+
font = texture_font_new( self->atlas, filename, size );
110+
texture_font_cache_glyphs( font, self->cache );
111+
if( font )
112+
{
113+
vector_push_back( self->fonts, font );
114+
}
115+
return font;
116+
}
117+
118+
119+
TextureFont *
120+
font_manager_get_from_description( FontManager *self,
121+
const char * family,
122+
const float size,
123+
const int bold,
124+
const int italic )
125+
{
126+
assert( self );
127+
128+
TextureFont *font;
129+
char *filename = font_manager_match_description( self, family, size, bold, italic );
130+
// fprintf(stderr, "Matched filename for %s: %s\n", family, filename);
131+
if( !filename )
132+
{
133+
return 0;
134+
}
135+
font = font_manager_get_from_filename( self, filename, size );
136+
free( filename );
137+
return font;
138+
}
139+
140+
TextureFont *
141+
font_manager_get_from_markup( FontManager *self,
142+
const Markup *markup )
143+
{
144+
assert( self );
145+
assert( markup );
146+
TextureFont *font =
147+
font_manager_get_from_description( self, markup->family, markup->size,
148+
markup->bold, markup->italic );
149+
return font;
150+
}
151+
152+
153+
char *
154+
font_manager_match_description( FontManager *self,
155+
const char * family,
156+
const float size,
157+
const int bold,
158+
const int italic )
159+
{
160+
char *filename = 0;
161+
int weight = FC_WEIGHT_REGULAR;
162+
int slant = FC_SLANT_ROMAN;
163+
if ( bold )
164+
{
165+
weight = FC_WEIGHT_BOLD;
166+
}
167+
if( italic )
168+
{
169+
slant = FC_SLANT_ITALIC;
170+
}
171+
FcInit();
172+
FcPattern *pattern = FcPatternCreate();
173+
FcPatternAddDouble( pattern, FC_SIZE, size );
174+
FcPatternAddInteger( pattern, FC_WEIGHT, weight );
175+
FcPatternAddInteger( pattern, FC_SLANT, slant );
176+
FcPatternAddString( pattern, FC_FAMILY, (FcChar8*) family );
177+
FcConfigSubstitute( 0, pattern, FcMatchPattern );
178+
FcDefaultSubstitute( pattern );
179+
FcResult result;
180+
FcPattern *match = FcFontMatch( 0, pattern, &result );
181+
FcPatternDestroy( pattern );
182+
183+
if ( !match )
184+
{
185+
fprintf( stderr, "fontconfig error: could not match family '%s'", family );
186+
return 0;
187+
}
188+
else
189+
{
190+
FcValue value;
191+
FcResult result = FcPatternGet( match, FC_FILE, 0, &value );
192+
if ( result )
193+
{
194+
fprintf( stderr, "fontconfig error: could not match family '%s'", family );
195+
}
196+
else
197+
{
198+
filename = strdup( (char *)(value.u.s) );
199+
}
200+
}
201+
FcPatternDestroy( match );
202+
return filename;
203+
}
204+
205+
206+
const wchar_t *
207+
font_manager_get_cache( FontManager *self )
208+
{
209+
assert( self );
210+
return self->cache;
211+
}
212+
213+
void
214+
font_manager_set_cache( FontManager *self,
215+
const wchar_t * cache )
216+
{
217+
assert( self );
218+
assert( cache );
219+
220+
if( self->cache )
221+
{
222+
free( self->cache );
223+
}
224+
self->cache = wcsdup( cache );
225+
}
226+
227+
#ifdef __cplusplus
228+
}
229+
#endif

0 commit comments

Comments
 (0)