pauceano / freetype-gl Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/freetype-gl
License: Other
Automatically exported from code.google.com/p/freetype-gl
License: Other
Freetype GL - A C OpenGL Freetype engine ======================================== This code intends to show how to display fonts efficiently using regular C, Freetype and OpenGL. The idea is to use a single texture and a single vertex buffer. The code is fairly simple and organized as follow: ** mandatory ** texture-font: The texture-font structure is in charge of creating bitmap glyphs and to upload them to the texture atlas. texture-atlas: This structure is responsible for the packing of small regions into a bigger texture. It is based on the skyline bottom left algorithm which appear to be well suited for storing glyphs. More information at: http://clb.demon.fi/files/RectangleBinPack.pdf vector: This structure loosely mimics the std::vector class from c++. It is used by texture-atlas (for storing nodes), texture-font (for storing glyphs) and font-manager (for storing fonts). More information at: http://www.cppreference.com/wiki/container/vector/start ** optional *** markup: Simple structure that describes text properties (font family, font size, colors, underline, etc.) font-manager: Structure in charge of caching fonts. vertex-buffer: Generic vertex buffer structure inspired by pyglet (python). (more information at http://www.pyglet.org) edtaa3func: Distance field computation by Stefan Gustavson (more information at http://contourtextures.wikidot.com/) makefont: Allow to generate header file with font information (texture + glyphs) such that it can be used without freetype. Contributors: ============= * Ryan.H.Kawicki (Initial CMake project) * Julian Mayer (Several bugfixes and code for demo-opengl-4.cc) * Sylvain Duclos (Android port) * Wang Yongcong (Improvements on the windows build and code review) * Marcel Metz (Bug report & fix and CMmake no demo option) * Jonas Wielicki (Bug report & fix on the CMakefile) * whatmannerofburgeristhis (Bug report in makefont) * Andrei Petrovici (Fine analysis of the whole code and report of potential problems) * Cristi Caloghera (Report on bad vertex buffer usage) * Andrei Petrovici (Code review) * Kim Jacobsen (Bug report & fix) * bsoddd (Bug report & fix) * Greg Douglas (Bug report & fix) * Jim Teeuwen (Bug report & fix) * quarnster (Bug report & fix) * Per Inge Mathisen (Bug report & fix) * Wojciech Mamrak (Code review, bug report & fix) * Wael Eloraiby (Put code to the C89 norm and fix CMakefile) * Christian Forfang (Code review, fix & patch for 3.2 core profile) * Lukas Murmann (Code review & fix for 3.2 core profile) * Jérémie Roy (Code review, fix and new ideas) * dsewtz (Bug report & fix) * jcgamestoy (Bug report & fix) * Behdad Esfahbod (Bug fix on harfbuzz demo) * Adrian Broher (Code analysis & fix) * Brian Foster Allen (bug report & fix)
[deleted issue]
In "texture-font.c" line 533
FT_Get_Glyph() allocates heap memory
Fix:
if( self->outline_type > 0 )
{
FT_Done_Glyph( ft_glyph );
}
Should be moved inside load glyph loop.
Original issue reported on code.google.com by [email protected]
on 4 Jul 2012 at 8:49
I'm using this in my current game, and I've made a few changes to it so far,
mostly trying to remove all deprecated OpenGL functions.
So I'm wondering, is there a way to submit code to the project?
Original issue reported on code.google.com by [email protected]
on 29 Mar 2013 at 12:09
Please see the attached file, you may add some changes to your project.
1. Added function text_buffer_delete ().
2. Added shader_t in the structure text_buffer_t
3. Added builtin_shader.c, builtin_shader.h, shaders_src.h.
4. Some functions, such as texture_font_new (), texture_font_load_face() "char
* filename" argument is replaced by "LPCTSTR filename".
5. In texture-font.cpp added function FT_Done_Face_MMF()
and changes in texture_font_load_face () to load the font through the Memory
Mapped Files and FT_New_Memory_Face().
6. Functions ftgl_open (), ftgl_close (), ftgl_fdraw () to load the font, use
and release resources correctly (simple-interface.cpp).
7. CrtDbg.h for fast memory leaks detect.
Original issue reported on code.google.com by [email protected]
on 19 Jul 2012 at 5:23
Attachments:
see attachment.
Original issue reported on code.google.com by [email protected]
on 19 Jul 2012 at 5:41
Attachments:
/*** fix: ***/
void
text_buffer_add_wchar( text_buffer_t * self,
vec2 * pen, markup_t * markup,
wchar_t current, wchar_t previous )
{
...
size_t i = 0;
...
}
Original issue reported on code.google.com by [email protected]
on 18 Jul 2012 at 9:49
Hello,
Recently I wanted to compile freetype-gl library with Visual C++ 10 (from
project files created using CMake), and I came across several issues.
Forget for a while about demos.
I changed the project to build as C++ (issue 34), but it was not enough.
File texture-font.c lacks #include "platform.h" (in both trunk and
branch 3.0), which defines round function.
In branch 3.0 there are errors about undeclared indentifier M_PI in
mat4.h - so I have added:
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif
in file mat4.c
Another issue was related to include paths and linking against required
libraries. I am not accustomed to CMake, but maybe a variable for
specifying location of them is something that can be considered?
Nevertheless, to make everything as simple as possible, and without
modifying project's include paths, I simply copied required libraries
into main folder (svn/trunk and svn/branches/gl-3.0, respectively).
In 3.0 branch an issue arised about undefined identifier strndup in
vertex-attribute.c, so I have added the following (it is defined in another c
file - let external linkage do the job):
#if defined(__APPLE__) || defined(_WIN32) || defined(_WIN64)
char *
strndup( const char *s1, size_t n);
#endif
Now proceeding with both branches splits.
For gl-3.0, I compiled against the latest glew, i.e. 1.9.0.
For trunk, I have compiled against some legacy glew version I have
found somewhere on my computer, because there was a name conflict with
respect to GL_TYPE in file vertex-attribute.c.
Now both static libraries compiled fine (there were a lot of warnings
about possible loss of data in text-buffer.c, mat4.c and others, and
about unsafe functions - I did not focus on solving them).
Since libraries were working, I focused on compiling demos. I have
chosen demo-subpixel, because I was especially interested in it.
This demo project I changed to build as C++ as well. After fixing
markup definition (strange syntax, huh), I received a lot of linker
errors (LNK2019) complaining about various unresolved glew external
symbols in both trunk and branch-3.0. All of them disappeared after
adding glew32.lib to additional dependencies (shouldn't this be done
automatically?).
BTW, there is a nice mess with locations of various libraries; e.g.:
additional dependency is hardcoded:
- freetype-gl/freetype-gl/svn/branches/gl-3.0/windows/freetype/freetype.lib
yet additional include directory for ft2build.h is not;
- static libraries files (glew32.lib, glut32.lib) are expected in
main folder, yet glew.h is expected in GL folder which does not exist;
- glut.h is expected in GLUT folder which does not exist in main
directory, but only in windows one;
- additional library directory
freetype-gl/freetype-gl/svn/branches/gl-3.0/$(Configuration)
is specified for no reason;
- folder Fonts is not being copied into build location for gl-3.0;
- folders Fonts and Shaders should be copied into $(Configuration)
rather than main build directory.
It is not hard to make the solution running, but one would expect
CMake to deal with it, I guess.
I also decided to check SDF examples, and the file "edtaa3func.c"
lacks #include "edtaa3func.h". Without it in C++ it results in LNK2019.
From my C++ experience it makes perfect sense why this is
needed, but since I haven't written even one plain C program, I can't
tell you why in C this is not required :)
In other demos I have experienced other various issues, but I think it
is enough complains for now :)
On gl-3.0 all examples worked nicely (I have checked just few of them
- most of them require some additional functions I did not want to
seek for over the internet).
The problem arises with trunk's demo-subpixel which crashes somewhere
in between vertex_buffer_new and vertex_attribute_new. Debugger shows
line no. 180 in vertex-attribute.c as the next statement to be
executed.
Hope that helps.
PS. demo-cartoon does crash exactly in the same place.
One final question: I have compiled (gl-3.0) and run demo-subpixel
(compiled against FT with LCD rendering enabled), yet the resultant
text is only antialiased. Any ideas as to why?
regards
Original issue reported on code.google.com by [email protected]
on 28 Jan 2013 at 9:03
/*** problem ***/
texture_glyph_t *
texture_font_get_glyph( texture_font_t * self,
wchar_t charcode ){
...
static wchar_t *buffer = 0;
...
if( !buffer)
{
buffer = (wchar_t *) calloc( 2, sizeof(wchar_t) );
}
...
}
/*** fix ***/
//static wchar_t *buffer = 0;
wchar_t buffer[2] = {0,0};
//delete following lines:
//if( !buffer)
//{
// buffer = (wchar_t *) calloc( 2, sizeof(wchar_t) );
//}
Original issue reported on code.google.com by [email protected]
on 18 Jul 2012 at 10:08
What steps will reproduce the problem?
1. Compile for windows on VS2010
What is the expected output? What do you see instead?
Lots of Build errors. 'FT_Library_SetLcdFilterWeights' not found. 'round' not
found.
Original issue reported on code.google.com by [email protected]
on 6 Sep 2012 at 9:00
Lines 123 and 143 should be changed from:
prev_glyph = (TextureGlyph *) vector_get( self->glyphs, i );
to:
prev_glyph = (TextureGlyph *) vector_get( self->glyphs, j );
Original issue reported on code.google.com by [email protected]
on 15 Aug 2011 at 2:34
I ran into some problems when building the gl-3.0 branch (MinGW-64 under MSys):
1. round() is defined multiple times.
2. It doesn't link GLEW nor GLUT.
Why have you chosen to not link glew when building in windows? I had to add it
to the makefile so it would link.
Is GLUT actually used for the library, or is it just for some of the demos? I
don't actually have it on this computer, but the makefile didn't err, even
though it wasn't found. It just silently ignored it, and the linker complained
about unresolved symbols.
I'd rather not fiddle around with the CMakeLists.txt myself, because I'm still
learning how this build system works.
Original issue reported on code.google.com by [email protected]
on 18 Mar 2013 at 4:08
When integrating freetype-gl into other projects it would be be an advantage to
disable the building of the demos to reduce the complete build time and to
prevent cluttering the freetype-gl output with the parent project.
The attached patch introduces the 'freetype-gl_BUILD_DEMOS' cmake option, which
can be set up with the ccmake, the make-gui oder with the -D parameter. The
option is enabled by default and build the demo applications.
Original issue reported on code.google.com by [email protected]
on 19 Feb 2012 at 4:25
Attachments:
working base: r119
1, VS do not support C99, so the compiler option "/TP" must be used to indicate
that the source should be treated as C++
2. lib GLEW should be included and placed in "freetype-gl/windows"
3. glut.h should be placed in "freetype-gl/windows/glut/GL"
4. CMakeLists.txt has bugs about path setting under WIN32
5. source code has compatible problems under VS:
a. void* ptr; ptr+=1; // it's not allowed
b. stdlib.h must be included before glut.h
c. some demos need to init glew
Patch is attached below.
Original issue reported on code.google.com by [email protected]
on 7 Mar 2012 at 6:32
Attachments:
When trying to build the latest revision on Windows 7 Professional (64bit, if
this is important) using Visual Studio 2010 (Professional) and CMake 2.8.8 I
encounter several errors. Both 32bit and 64bit builds fail.
1. Using a clean svn-update, CMake will initially fail:
Check for working C compiler using: Visual Studio 10
Check for working C compiler using: Visual Studio 10 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 10
Check for working CXX compiler using: Visual Studio 10 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Found OpenGL: opengl32
NOT FOUND: Libstdc++ is not installed. It is needed by demo-atb-agg.c
Configuring done
This is interesting, as the libstdc++-check should be disabled. However, this
can be "solved" by commenting out the other lines concerning demo-atb-agg.c
2. After working around issue 1., the following output is produced by CMake:
Check for working C compiler using: Visual Studio 10
Check for working C compiler using: Visual Studio 10 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 10
Check for working CXX compiler using: Visual Studio 10 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Found OpenGL: opengl32
Configuring done
Generating done
When loading the generated project files, building the freetype-gl lib will
fail (loading "Project.sln"). Error messages:
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error
C2054: expected '(' to follow 'WINGDIAPI'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error
C2085: 'APIENTRY' : not in formal parameter list
According to
http://www.opengl.org/archives/resources/faq/technical/gettingstarted.htm this
is caused by not including <windows.h> before <gl.h>. By following this tip (by
modifying texture-atlas.c and , the second issue can be eliminated.
3. After solving the first two problems, the C-compiler floods the console with
syntax errors. Apparently he doesn't like the following line from
texture-atlas.c
texture_atlas_t *self = (texture_atlas_t *) malloc( sizeof(texture_atlas_t) );
Error code: error C2143: syntax error: missing ';' before 'type'
A quick Google search told me that Visual Studio's C compiler hates it when you
declare and define a variable in the same line. So I changed the project
settings to "Compile as C++".
4. After massively reducing the errors, I noticed that the include directory
for freetype is not set by default. After pointing to the directory included in
the latest revision, this error disappeared.
5. After solving the errors above, I encountered an error I cannot solve yet.
For some reason, Visual C++ doesn't know several (most) of the OpenGL-functions
used, despite <GL/gl.h> being correctly included. Oddly it does know some of
them.
Example:
glDeleteBuffers is unknown.
glDrawElements is known.
Original issue reported on code.google.com by [email protected]
on 1 May 2012 at 1:52
[deleted issue]
When compiling the freetype-gl project under Fedora linux the compiler
complaints about the missing stdarg.h header, that is required by the various
variable argument macros in the outline demo.
The attached patch fixes this and removes the duplicate demo definition of
demo-line-aa.
Original issue reported on code.google.com by [email protected]
on 18 Feb 2012 at 2:31
Attachments:
I tested freetype-gl on Windows XP+8600 GT, Windows 7x64+9800GT and Windows
7x32 + Intel HD Graphics 2000. The first two configurations of the problem is
not observed. At the Intel HD Graphics 2000, I get messages "Access violation"
in two places in a file vertex-buffer.cpp. Exceptions occur after several
successful attempts sometimes glDrawElements, sometimes glDeleteBuffers.
void
vertex_buffer_render (vertex_buffer_t * self,
GLenum mode, const char * what) {
...
glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, self-> indices_id) ;/ * redundant code *
/
glDrawElements (mode, icount, GL_UNSIGNED_INT, 0) ;/ * Access violation * /
...
}
void
vertex_buffer_delete (vertex_buffer_t * self) {
...
glDeleteBuffers (1, & self-> indices_id) ;/ * Access violation * /
...
}
glDeleteBuffers () calls _unlock () from mlock.c (crt), and an exception occurs.
The previous version of freetype-gl (where "vertex_buffer_t" called
"VertexBuffer") works fine on the HD 2000. But there were memory leaks that I
could not fix.
Original issue reported on code.google.com by [email protected]
on 19 Jul 2012 at 7:39
What steps will reproduce the problem?
1. Go to the project page at http://code.google.com/p/freetype-gl/
2. Follow usage example
3. Discover texture_glyph_add_to_vertex_buffer() isn't in the library at all
What is the expected output? What do you see instead?
An example which works
Original issue reported on code.google.com by [email protected]
on 2 Mar 2012 at 8:48
Do you plan to support font substitution, so that when a font doesn't supply a
needed glyph, it is loaded from another automatically? That would be nice for
general unicode support, since very few fonts support the full unicode range.
You already seem to use fontconfig, so that shouldn't introduce new
dependencies.
Original issue reported on code.google.com by [email protected]
on 4 Sep 2011 at 10:39
Is this library inline with OpenGL 3.3+ ie. Core Profile. Ensuring forward
compatibility?
Reviewing the shaders it appears it might not be. The following no longer
exist in core profile:
- gl_ModelViewProjectionMatrix
- gl_MultiTexCoord0
- gl_Color
I am not sure your specific targets with this project. Since this project is
rather new it might be worth it to shift it to OpenGL 3.3+ now rather than
later.
Doing so would also make it more inline with OpenGL ES 2.0 for mobile devices.
Original issue reported on code.google.com by [email protected]
on 5 Feb 2012 at 6:16
In latest trunk version, in CMakeLists.txt, the line
FILE(GLOB Fonts "fonts/*.ttf")
makes demo apps not want to run out of the build directory on case-sensitive
filesystems. Please change the directory name to all lowercase (ie "fonts"
instead of "Fonts"), as the code in the demo programs expects. Thank you! :)
Original issue reported on code.google.com by [email protected]
on 20 Jan 2013 at 2:24
void
vertex_buffer_upload ( vertex_buffer_t *self ){
...
if( !self->vertices_id )
{
glGenBuffers( 1, &self->vertices_id );
/*delete line*/glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id );
}
if( !self->indices_id )
{
glGenBuffers( 1, &self->indices_id );
/*delete line*/glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id );
}
...
// Upload vertices
glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id );
...
// Upload indices
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id );
}
Original issue reported on code.google.com by [email protected]
on 18 Jul 2012 at 9:40
I am using latest code snapshot (pulled from the trunk yesterday) and freetype
2.4.9 (recompiled with FT_CONFIG_OPTION_SUBPIXEL_RENDERING option)
After spending few hours trying to get subpixel rendering to work in my code, I
compiled freetype-gl demo-subpixel sample, thinking I am doing something wrong.
Unfortunately, even demo-subpixel suffers from the same problem (please see
attached image)
Some info about the configuration:
- Building and running on x64 Windows Server 2008 R2 (Win 7)
- Using NVidia 580 GTX with NVidia's drivers, all OpenGL settings are
configured to defaults ("Application decide")
- Using freetype 2.4.9, recompiled with the FT_CONFIG_OPTION_SUBPIXEL_RENDERING
option (and using patented algorithms, no legacy LCD filter - but that alone
does not make any difference)
I tried changing LCD filters (light/default/legacy...) and this did not help at
all :( I triple-checked that I am using right freetype library.
One hint - if I remove the gamma correction operation in the fragment shader:
vec3 color = pow( vec3(r,g,b), vec3(1.0/vgamma));
The artifacts disappear.
Any idea what could be wrong?
Original issue reported on code.google.com by [email protected]
on 24 Jun 2012 at 10:38
Attachments:
I checked out the source, compiled and looked at the subpixel demo. This demo
did not show any color differences at all. (only greytone antialiasing). I then
looked at the fragment shader and found several issues.
1: The resulting subpixel color is multiplied by the font color, in this case
black, removing any color anyway.
2: The mixing of rgb code does not contain any usage of next, only previous and
current
3: The vertex structure for the glyph | is only one pixel wide, which does not
allow the fragment shader to do anything with the neighboring pixel.
Is there a newer version that rendered the screenshot on the mainpage? which
correctly has subpixel AA.
Original issue reported on code.google.com by [email protected]
on 25 Feb 2013 at 2:31
Hi,
The current trunk does not build correctly with MinGW, and every example
segfaults as the glezwInit() function is not called (thus every gl* function is
a non-initialized pointer).
I have attached a patch to correct this problem, and it also makes some
modifications to platform.h (there was an ifdef WIN32 that really was an ifdef
_MSC_VER).
I also modified the CMakeLists.txt to be require GLEW (as it is used by the
project), and removed the headers from the source variable (CMake does not need
this, and it makes the CMakeLists cleaner IMHO).
If you want me to add more to this patch I'll be glad.
Best.
Original issue reported on code.google.com by packadal
on 12 Nov 2012 at 2:47
Attachments:
What steps will reproduce the problem?
1. texture_atlas_t *atlas = texture_atlas_new( 512, 512, 4 );
2. when using depth=4 to create a new texture_atlas, opengl texture data seems
wrong
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 28 Mar 2012 at 3:43
Working base r108
Each call of texture_font_get_glyph with char code -1 will create a new glyph.
Because the check of loaded glyphs :
if( (glyph->charcode == charcode) &&
(glyph->outline_type == self->outline_type) &&
(glyph->outline_thickness == self->outline_thickness) )
compare not only charcode but outline_type and outline_thickness. But the
creation of the glyph of char code -1 dose not initialize outline_type and
outline_thickness.
Original issue reported on code.google.com by [email protected]
on 29 Jan 2012 at 4:13
What steps will reproduce the problem?
1. Build makefont
2. Attempt to use it
3. Crashes in 2 (maybe 3?) different places at random
What is the expected output? What do you see instead?
Expected output is the header for the font, instead it crashes. I have been
unable to use it to produce a valid font.
What version of the product are you using? On what operating system?
OS X 10.7.3 x86_64
Please provide any additional information below.
First crash:
Font filename : ./Vera.ttf
Font size : 16.0
Number of glyphs : 95
Number of missed glyphs : 0
Texture size : 128x128x1
Texture occupancy : 64.59%
Header filename : vera.h
Assertion failed: (self), function vector_size, file
/Users/matt/src/freetype-gl-read-only/vector.c, line 145.
Program received signal SIGABRT, Aborted.
0x00007fff8b738ce2 in __pthread_kill ()
(gdb) bt
#0 0x00007fff8b738ce2 in __pthread_kill ()
#1 0x00007fff8a53b7d2 in pthread_kill ()
#2 0x00007fff8a52ca7a in abort ()
#3 0x00007fff8a55f5de in __assert_rtn ()
#4 0x00000001000065ff in vector_size (self=0x0) at
/Users/matt/src/freetype-gl-read-only/vector.c:145
#5 0x00000001000033db in main (argc=1, argv=0x7fff5fbff718) at
/Users/matt/src/freetype-gl-read-only/makefont.c:128
Second crash:
Font filename : ./Vera.ttf
Font size : 16.0
Number of glyphs : 95
Number of missed glyphs : 0
Texture size : 128x128x1
Texture occupancy : 64.59%
Header filename : vera.h
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000026
0x000000010000383c in main (argc=1, argv=0x7fff5fbff718) at
/Users/matt/src/freetype-gl-read-only/makefont.c:312
312 wchar_t charcode = kerning->charcode;
(gdb) bt
#0 0x000000010000383c in main (argc=1, argv=0x7fff5fbff718) at
/Users/matt/src/freetype-gl-read-only/makefont.c:312
I can sort of work around these crashes and it will occasionally crash at
another invalid address in a part later down in the final loop in makefont.c
for( j=0; j < vector_size(glyph->kerning); ++j )
{
const kerning_t *kerning = (const kerning_t *) vector_get( glyph->kerning, j);
wchar_t charcode = kerning->charcode;
Original issue reported on code.google.com by [email protected]
on 12 Mar 2012 at 11:31
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
svn 189
Archlinux
$ uname -a
Linux cherry 3.6.10-1-ARCH #1 SMP PREEMPT Tue Dec 11 09:40:17 CET 2012 x86_64
GNU/Linux
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 24 Feb 2013 at 9:38
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
There is a missing teminating / in the license header comment.
The first character (-1) produces an unterminated quote.
Missing ,'s:
At the end
if( i < (vector_size(glyph->kerning)-1) )
looks like it should be
if( i < (glyph_count - 1) )
Original issue reported on code.google.com by [email protected]
on 13 Mar 2012 at 3:12
For Asian language, such as Chinese, the common used character is about 6K
(total amount exceed 10K). So the current implementation of texture font is not
enough. Potential improvement could be:
1. Use hash table for glyph fetching.
2. Create glyphs on the fly. It may introduce some streaming mechanism that a
background thread keep reading from the input stream and render all glyph to
the atalas
3. Texture font may contain multiple atalas now, so texture font : texture
atlas is n:n relationship (currently is n:1). Reference counting on atlas may
help.
4. Vertex buffer should sort all glyph mesh according texture id.
I'm now porting freetype-gl to my game engine, and intent to solve the problems
mentioned above.
In the attach file is the code of hash table of glyph. It's tested but without
comment ( interface is straight forward ). A generic hash table may be better,
but it's normally a key-value pair and take more memory. For thousands of
glyph, it's a bit waste. I hope it may help.
Original issue reported on code.google.com by [email protected]
on 6 Feb 2012 at 5:04
Attachments:
working base: r119
We could benefit much from euclidean distance transform, such as none-cost
scaling, easily outline / glow rendering... I'm trying to use edt font in my
game, the main idea is:
1, generate high resolution bitmap glyph (1024x1024 or bigger) with Freetype
2, generate the distance transform of it
3, down sample the edt bitmap (scale to 32x32) and pack it into atlas
Then we could use it as normal glyphs.
Here is a simple demo (which is modified from demo-distance-field.c) to
demonstrate the idea. It print a line of text on the screen. You could press
+/- key to scale text size, and spacebar to show atlas. The bigger the original
font size, the better the scaled output.
It's an useful technique and could be part of texture_font_t : )
Notice: The program is only tested under VS. If you gat problems, please email
me
Original issue reported on code.google.com by [email protected]
on 7 Mar 2012 at 4:49
Attachments:
I have some changes that may be of interest to you.
I created a CMake project to allow the project to be compiled under Visual
Studio for Windows.
I am still creating a substitute for the fontconfig option, but if you are
interested in these changes, let me know so I can get them to you.
Ryan
Original issue reported on code.google.com by [email protected]
on 17 Aug 2011 at 12:04
When executing the demos demo-atb-agg, demo-display-list, demo-subpixel the
execution is terminated with the error message:
FT_Error (line 92, code 0x01) : cannot open resource
The demos in question point to various font files, that don't exist in the
repository.
The attached patch replaced the file pathes with ./Vera.ttf and introduces a
new family entry for the demo-atb-add executable.
Original issue reported on code.google.com by [email protected]
on 18 Feb 2012 at 2:39
Attachments:
1. I put all the 3rd libraries and headers in a directory named "dependence",
and a cmake file that set all the path variable such as
FREETYPE_INCLUDE_DIR_ft2build etc. Then I modified the CMakeLists to try to
include the settings. That may help to ease the work to compile under Windows
Visual Studio.
2. I add two files : platform.h/.c to handle some platform specific issues
3. I make a few modifications to the source for compatible problems under
Windows Visual Studio.
The changes are based on r108 from the SVN repository and packed in the
attached files.
Original issue reported on code.google.com by [email protected]
on 26 Jan 2012 at 9:05
Attachments:
What steps will reproduce the problem?
1. Open CMakeLists.txt file from Qt Creator/File/Open File or Project
2. Select freetype-gl-read-only folder
3. Run one of the demos.
What is the expected output? What do you see instead?
I Expect to see the demo, the exit on Compile Output is :
In file included from \freetype-gl-read-only\texture-atlas.c:39:
\freetype-gl-read-only\/opengl.h:46:25: error: GL/glew.h: No such file or
directory
\freetype-gl-read-only\/opengl.h:47:26: error: GL/wglew.h: No such file or
directory
\freetype-gl-read-only\/opengl.h:48:72: error: GLUT/glut.h: No such file or
directory
What version of the product are you using? On what operating system?
Qt Creator 2.4.1. and Windows Vista
Please provide any additional information below.
I suspect than on CMakeLists.txt there are errors like :
SET( GLUT_INCLUDE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/windows/glut )
INCLUDE_DIRECTORIES( ${GLUT_INCLUDE_DIRS}
Original issue reported on code.google.com by [email protected]
on 25 Jan 2013 at 4:39
/*** problem: ***/
vertex_buffer_t *
vertex_buffer_new( const char *format ){
...
self->items = vector_new( sizeof(ivec4) );
...
}
/*** fix: ***/
void
vertex_buffer_delete( vertex_buffer_t *self ){
...
if(NULL != self->items)
vector_delete( self->items );
...
}
Original issue reported on code.google.com by [email protected]
on 18 Jul 2012 at 9:24
Just a minor note:
The function `text_buffer_clear` is defined twice in the same file
(text-buffer.h):
http://code.google.com/p/freetype-gl/source/browse/branches/gl-3.0/text-buffer.h
#211
http://code.google.com/p/freetype-gl/source/browse/branches/gl-3.0/text-buffer.h
#270
Original issue reported on code.google.com by [email protected]
on 20 Oct 2012 at 12:18
I found this on Sunday while preparing the new build of my small project:
It appears that text_buffer_clear() is not implemented. I needed it for the
subpixel rendering in my code which is using text_buffers and needs to enter
new text for every new frame.
So I tried to implement it with simple:
vertex_buffer_clear(textBuffer->buffer);
I am not 100% sure if that is enough...
However, then I noticed a strange memory leak, which I traced to vertex buffer
not clearing the "items" vector.
So, I simply added vector_clear( self->items) in vertex_buffer_clear().
I am not sure, however, if this is the right approach - but it definitely
solved the leaking for me.
Original issue reported on code.google.com by [email protected]
on 25 Jun 2012 at 7:21
This is a simple issue I am having that is most likely with my own code. I am
trying to get glyphs like 'g' and 'j' rendering properly but they seem to not
be positioned properly with the data I am providing.
Screenshot is attached. Here is the code I am using to build the string that I
am rendering.
[code]
// Codepoint is a typedef of char32_t, part of the C++11 standard.
SH_Rect SH_Font::getGlyphTex(short size,Codepoint utf8Codepoint)
{
cacheFontSize(size);
texture_glyph_t* glyph = texture_font_get_glyph(mTextureFonts[size],utf8Codepoint);
// Reverse the y values so that the glyph renders right-side up.
SH_Vector2 topRight { glyph->s1, glyph->t0 };
SH_Vector2 bottomLeft { glyph->s0, glyph->t1 };
return SH_Rect { bottomLeft, topRight };
}
float SH_Font::getKerning(short size,Codepoint current,Codepoint preceeding)
{
cacheFontSize(size);
texture_glyph_t* g = texture_font_get_glyph(mTextureFonts[size],current);
return texture_glyph_get_kerning(g,preceeding);
}
SH_Vector2 SH_Font::getOffset(short size,Codepoint c)
{
cacheFontSize(size);
texture_glyph_t* glyph = texture_font_get_glyph(mTextureFonts[size],c);
return SH_Vector2 { glyph->offset_x, glyph->offset_y };
}
SH_Vector2 SH_Font::getGlyphSize(short size,Codepoint c)
{
cacheFontSize(size);
texture_glyph_t* glyph = texture_font_get_glyph(mTextureFonts[size],c);
return SH_Vector2 { glyph->width, glyph->height };
}
bool SH_Font::load(const string& resourceName)
{
mName = resourceName;
SH_Filesystem::readFile(resourceName,mFontData);
if(!mFontData.empty())
{
unsigned missed = 0;
mAtlas = texture_atlas_new(512,512,1);
cacheFontSize(8);
cacheFontSize(12);
cacheFontSize(24);
if(missed > 0)
{
SH_Log::out("%s [%s] -> %s %d","SH_Font",mName.c_str(),"Loaded font, but missed a few glyphs:",missed);
}
// Bind the null texture...
SH_Graphics::bindTexture(GL_TEXTURE_2D,0);
}
return true;
}
void SH_FontComponent::drawString(const SH_String& renderString)
{
assert(mFont);
SH_String oldString = mRenderString;
mRenderString = renderString;
// We might not have set the size, but if the string changes, we have to
// recompile.
if(mIsCompiled)
{
mIsCompiled = (mRenderString == oldString);
}
// Compile the render command.
if(!mIsCompiled)
{
SH_Log::out("%s [%s] -> %s '%ls' \n","SH_Font",mFont->getName().c_str(),"Compiling string",mRenderString.c_str());
SH_Color vertColor { 1,1,1,1 };
vector<SH_Vertex> vertices;
vertices.resize(mRenderString.size() * 4);
vector<GLushort> indices;
indices.resize(mRenderString.size() * 6);
SH_Vector2 pen { 0,0 };
for(unsigned i=0;i<renderString.size();i++)
{
if(i > 0)
{
pen.x += mFont->getKerning(mFontSize,renderString[i],renderString[i-1]);
}
if(renderString[i] == U'\n')
{
pen.x = 0.0f;
pen.y -= mFont->getLineHeight(mFontSize);
continue;
}
SH_Vector2 glyphSize = mFont->getGlyphSize(mFontSize,renderString[i]);
if(renderString[i] == U' ')
{
pen.x += mFont->getAdvanceX(mFontSize,' ');
pen.x += glyphSize.x;
continue;
}
SH_Rect glyphTex = mFont->getGlyphTex(mFontSize,renderString[i]);
SH_Vector2 offset = mFont->getOffset(mFontSize,renderString[i]);
SH_Vector2 advance = mFont->getAdvance(mFontSize,renderString[i]);
float hFrameWidth = glyphSize.x * 0.5f;
float hFrameHeight = glyphSize.y * 0.5f;
vertices[i*4+0] = SH_Vertex {
{ -hFrameWidth, -hFrameHeight, 0 },
glyphTex.getBottomLeft(),
vertColor //,normal,binormal,tannormal
};
vertices[i*4+1] = SH_Vertex {
{ hFrameWidth, -hFrameHeight, 0 },
glyphTex.getBottomRight(),
vertColor //,normal,binormal,tannormal
};
vertices[i*4+2] = SH_Vertex {
{ hFrameWidth, hFrameHeight, 0 },
glyphTex.getTopRight(),
vertColor //,normal,binormal,tannormal
};
vertices[i*4+3] = SH_Vertex {
{ -hFrameWidth, hFrameHeight, 0 },
glyphTex.getTopLeft(),
vertColor //,normal,binormal,tannormal
};
offset *= 0.5;
for(unsigned j=0;j<4;j++)
{
vertices[i*4+j].Position += pen + offset;
}
indices[i*6+0] = ((i*4) + 0);
indices[i*6+1] = ((i*4) + 2);
indices[i*6+2] = ((i*4) + 1);
indices[i*6+3] = ((i*4) + 0);
indices[i*6+4] = ((i*4) + 3);
indices[i*6+5] = ((i*4) + 2);
pen += advance;
}
SH_Graphics::bindArrayBuffer(mInstruction.VertexBuffer);
glBufferData(GL_ARRAY_BUFFER,vertices.size()*sizeof(SH_Vertex),&vertices[0],GL_STATIC_DRAW);
SH_Graphics::bindElementBuffer(mInstruction.IndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,indices.size()*sizeof(GLushort),&indices[0],GL_STATIC_DRAW);
mInstruction.IndexCount = (unsigned)indices.size();
mInstruction.RenderMode = SH_RENDERMODE_TRIANGLES;
mIsCompiled = true;
}
// Draw call.
render();
}
[/code]
Original issue reported on code.google.com by [email protected]
on 10 Sep 2012 at 1:26
Attachments:
What steps will reproduce the problem?
1. allocate a vertex buffer with vertex_buffer_t *vertex_buffer_new( const char
*format )
2. deallocate with void vertex_buffer_delete( vertex_buffer_t *self )
3. vertex_attributes are not freed
fix:
add the following lines to vertex_buffer_delete:
for( int i=0; i<MAX_VERTEX_ATTRIBUTE; ++i )
{
if (self->attributes[i] != 0)
free(self->attributes[i]);
}
Original issue reported on code.google.com by [email protected]
on 25 Jun 2012 at 12:14
When compiling freetype-gl project in Fedora Linux the linker complaints about
missing math related symbols in the demo applications. As far as I understood
from a research on the web UNIX systems traditionally separated the standard c
library and the math library for performance reasons and most Linux
distributions inherit this behavior.
The attached patch (created against r113) adds explicit linking against the
math library.
Original issue reported on code.google.com by [email protected]
on 18 Feb 2012 at 1:36
Attachments:
Hi,
To integrate freetype-gl in my software, i need to create font directly from
memory.
So, i customize the library by adding to fields in texture_font_t :
const void * memfont;
unsigned int memfontSize;
and change the texture_font_new prototype by :
texture_font_t * texture_font_new( texture_atlas_t * atlas,
const char * filename,
const void * memfont,
unsigned int memfontSize,
const float size );
passing 0 to filename or (memfont and memfont size)
So, i had to customize
. some asserts => assert (filename) changed with (assert (filename || memfonSize)
. and the texture_font_load_face core function. (see attachement)
Original issue reported on code.google.com by [email protected]
on 25 Jul 2012 at 10:51
Attachments:
The CMakeLists.txt for the gl-3 branch didn't build the matrix code and didn't
build the distance-field-2 demo. I updated it to do so.
Great job with this lib btw.
Original issue reported on code.google.com by [email protected]
on 18 Nov 2012 at 9:04
Attachments:
Has this lib been tested in VS C++ environment? I tried to use it ,having all
kind of weird (mostly language) errors coming from this lib.
Original issue reported on code.google.com by [email protected]
on 12 Dec 2012 at 7:47
The library and files do not build with visual C++ express because it's mainly
a c89 compiler. Disregarding the demos, attached are the modification you need
to do on the code so it can build. Remember, it's trying to compile as C89
code, variables need to be declared at the start of the scope.
You need to modify the CMakeLists.txt and include GLEW since it's also missing.
Original issue reported on code.google.com by [email protected]
on 19 Feb 2013 at 3:38
Attachments:
The conditional check at [1] will always be false. The variable `i` is
initialized to 0 at [2] and after that, never changed. This means that the
`kerning` value will also always be 0.
[1]:
http://code.google.com/p/freetype-gl/source/browse/branches/gl-3.0/text-buffer.c
#250
[2]:
http://code.google.com/p/freetype-gl/source/browse/branches/gl-3.0/text-buffer.c
#205
Original issue reported on code.google.com by [email protected]
on 20 Oct 2012 at 12:19
texture-font.c has a number of error check cases, where freetype resources are
not cleaned up. Notably starting at the following location:
http://code.google.com/p/freetype-gl/source/browse/branches/gl-3.0/texture-font.
c#398
The particular case on that line, frees the FT_Library, but not the loaded
FT_Face. A few cases further down don't free the FT_Library, FT_Face or loaded
FT_Stroker. Namely at:
- texture-font.c#425
- texture-font.c#437
- texture-font.c#456
- texture-font.c#476
Original issue reported on code.google.com by [email protected]
on 21 Oct 2012 at 3:39
Looking at the vertex_buffer_upload function, I notice that you bind the buffer
and upload the data twice to the GPU if the buffers have not been created yet.
No matter what, the glBufferSubData gets called even if a glBufferData was
called before.
Small rearrangement avoids this:
void vertex_buffer_upload ( vertex_buffer_t *self )
{
if( !self->vertices_id )
{
glGenBuffers( 1, &self->vertices_id );
glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id );
glBufferData( GL_ARRAY_BUFFER,
self->vertices->size*self->vertices->item_size,
self->vertices->items, GL_DYNAMIC_DRAW );
}
else
{
glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id );
glBufferSubData( GL_ARRAY_BUFFER, 0,
self->vertices->size*self->vertices->item_size,
self->vertices->items );
}
glBindBuffer( GL_ARRAY_BUFFER, 0 );
if( !self->indices_id )
{
glGenBuffers( 1, &self->indices_id );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id );
glBufferData( GL_ELEMENT_ARRAY_BUFFER,
self->indices->size*self->indices->item_size,
self->indices->items, GL_DYNAMIC_DRAW );
}
else
{
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id );
glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, 0,
self->indices->size*self->indices->item_size,
self->indices->items );
}
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
}
PS: nice work!
Original issue reported on code.google.com by [email protected]
on 23 May 2012 at 6:22
it seems the use of a function named GL_TYPE() clashes with new glext.h headers
that define this as a macro.
i'm using an old snapshot but inspecting trunk leads to the suspicion this is a
problem there as well.
this is the error that was forwarded to me:
Compiling file sources/freetype-gl/texture-atlas.c ...
Compiling file sources/freetype-gl/texture-font.c ...
Compiling file sources/freetype-gl/vector.c ...
Compiling file sources/freetype-gl/vertex-buffer.c ...
In file included from sources/freetype-gl/vertex-buffer.c:38:
sources/freetype-gl//vertex-buffer.h:442:3: error:
expected identifier or '('
GL_TYPE( char ctype );
^
/usr/include/GL/glext.h:2972:43: note: expanded from:
#define GL_TYPE 0x92FA
^
sources/freetype-gl/vertex-buffer.c:592:34: error:
called object type 'int' is not a function or function pointer
GLenum type = GL_TYPE( ctype );
~~~~~~~^
sources/freetype-gl/vertex-buffer.c:600:34: error:
called object type 'int' is not a function or function pointer
GLenum type = GL_TYPE( ctype );
~~~~~~~^
sources/freetype-gl/vertex-buffer.c:612:30: error:
called object type 'int' is not a function or function pointer
GLenum type = GL_TYPE( ctype );
~~~~~~~^
sources/freetype-gl/vertex-buffer.c:586:31: warning:
array index of '2' indexes past the end of an array (that contains 2
elements) [-Warray-bounds]
p = strpbrk ( format, "n" );
~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/x86_64-linux-gnu/bits/string2.h:1097:39: note: expanded from:
: ((__a2 = ((__const char ) (accept))[2], a2 == '\0') \
^ ~
sources/freetype-gl/vertex-buffer.c:586:31: warning:
array index of '3' indexes past the end of an array (that contains 2
elements) [-Warray-bounds]
p = strpbrk ( format, "n" );
~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/x86_64-linux-gnu/bits/string2.h:1099:27: note: expanded from:
: (((const char *) (accept))[3] == '\0' \
^ ~
sources/freetype-gl/vertex-buffer.c:745:1: error:
expected identifier or '('
GL_TYPE( char ctype )
^
/usr/include/GL/glext.h:2972:43: note: expanded from:
#define GL_TYPE 0x92FA
^
2 warnings and 5 errors generated.
make[3]: ** [obj/sources/freetype-gl/vertex-buffer.c.o] Error 1
Original issue reported on code.google.com by [email protected]
on 30 Nov 2012 at 7:12
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.