Git Product home page Git Product logo

freetype-gl's Introduction

Freetype GL - A C OpenGL Freetype engine

Build Status Travis Build Status Appveyor

A small library for displaying Unicode in OpenGL using a single texture and a single vertex buffer.

Screenshot

Installation instructions

Code organization

Mandatory files

  • 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.

  • 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 files

  • 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)
  • 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)
  • Marcel Metz (Bug report & fix, CMmake no demo option, makefont parameters)
  • PJ O'Halloran (svn to git migration)
  • William Light (Face creation from memory)
  • Jan Niklas Hasse (Bug report & fix + README.md)
  • Pierre-Emmanuel Lallemant (Bug report & fix + travis setup)
  • Robert Conde (Bug report & fix)
  • Mikołaj Siedlarek (Build system bug fix)
  • Preet Desai (Bug report & fix)
  • Andy Staton (CMake fix and added namespace safeguard (avoiding glm collisions))
  • Daniel Burke (Removed GLEW dependency and fix problems with font licences)
  • Bob Kocisko (Added horizontal text alignment and text bounds calculation)
  • Ciro Santilli (Improve markdown documentation)

freetype-gl's People

Contributors

adrianbroher avatar andystanton avatar bensanmorris avatar bromvlieg avatar burito avatar cforfang avatar cirosantilli avatar cmrschwarz avatar darkshinz avatar duvisit avatar einsteinx2 avatar forthy42 avatar gustafsson avatar jhasse avatar joshuafc avatar kode80 avatar mikeiannacone avatar msiedlarek avatar peaker avatar pelallemant avatar preet avatar rougier avatar rubo3 avatar stevenawhite avatar tsgouros avatar tustvold avatar wmamrak avatar wrl avatar xraw avatar yairchu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

freetype-gl's Issues

bold or italic markup has no effect on text

Hi.I was trying to use markup based on demo-markup.c .The problem is that the font style doesn't change if I set it to bold or italic.It also appears to be the issue in the demo-ansi.c

I compile with VS2012 , VC2010 .Win7

Bug in demo-outline, and demo-cartoon

There are some graphical issues on the following demos:
demo-outline
demo cartoon
(see pictures)

In order to reproduce it, just compile and execute those demos.

How I see it:
demo-outline
How it should be painted;
demo-outline_ok
How I see it:
demo-cartoon
How it should be painted;
demo-cartoon_ok

Distance field mode and markup

Hi.I haven't seen a demo using distance field + markup.I see that markup demo uses different shaders from those used by distance field.So is it possible to combine both?

Linking Fails

Linking the library fails under Ubuntu 13.10 with the following error
$ make
Scanning dependencies of target freetype-gl
[ 3%] Building C object CMakeFiles/freetype-gl.dir/mat4.c.o
[ 6%] Building C object CMakeFiles/freetype-gl.dir/texture-atlas.c.o
[ 9%] Building C object CMakeFiles/freetype-gl.dir/texture-font.c.o
[ 12%] Building C object CMakeFiles/freetype-gl.dir/vertex-buffer.c.o
[ 15%] Building C object CMakeFiles/freetype-gl.dir/vertex-attribute.c.o
[ 18%] Building C object CMakeFiles/freetype-gl.dir/font-manager.c.o
[ 21%] Building C object CMakeFiles/freetype-gl.dir/text-buffer.c.o
[ 25%] Building C object CMakeFiles/freetype-gl.dir/shader.c.o
[ 28%] Building C object CMakeFiles/freetype-gl.dir/vector.c.o
[ 31%] Building C object CMakeFiles/freetype-gl.dir/platform.c.o
Linking C static library libfreetype-gl.a
[ 31%] Built target freetype-gl
Scanning dependencies of target demo-ansi
[ 34%] Building C object CMakeFiles/demo-ansi.dir/demo-ansi.c.o
Linking C executable demo-ansi
[ 34%] Built target demo-ansi
Scanning dependencies of target demo-atb-agg
[ 37%] Building C object CMakeFiles/demo-atb-agg.dir/demo-atb-agg.c.o
Linking C executable demo-atb-agg
/usr/local/lib/libAntTweakBar.so: undefined reference to std::string::find_first_of(char const*, unsigned long, unsigned long) const' /usr/local/lib/libAntTweakBar.so: undefined reference tostd::basic_ostringstream<char, std::char_traits, std::allocator >::~basic_ostringstream()'
/usr/local/lib/libAntTweakBar.so: undefined reference to std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)' /usr/local/lib/libAntTweakBar.so: undefined reference tovtable for std::basic_stringstream<char, std::char_traits, std::allocator >'
/usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const' /usr/local/lib/libAntTweakBar.so: undefined reference to__cxa_begin_catch'
/usr/local/lib/libAntTweakBar.so: undefined reference to std::string::_Rep::_M_destroy(std::allocator<char> const&)' /usr/local/lib/libAntTweakBar.so: undefined reference tostd::Rb_tree_rebalance_for_erase(std::Rb_tree_node_base, std::Rb_tree_node_base&)'
/usr/local/lib/libAntTweakBar.so: undefined reference to vtable for std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >' /usr/local/lib/libAntTweakBar.so: undefined reference tooperator delete'
/usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const_, unsigned long, std::allocator<char> const&)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::string::reserve(unsigned long)'
/usr/local/lib/libAntTweakBar.so: undefined reference tooperator new(unsigned long)' /usr/local/lib/libAntTweakBar.so: undefined reference to VTT for std::basic_stringstream<char, std::char_traits, std::allocator >'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::__detail::_List_node_base::_M_unhook()' /usr/local/lib/libAntTweakBar.so: undefined reference to std::string::find_last_not_of(char const*, unsigned long, unsigned long) const'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::basic_ostream<char, std::char_traits<char> >& std::operator<< std::char_traits<char >(std::basic_ostream<char, std::char_traits<char> >&, char const_)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_istream<char, std::char_traits >& std::getline<char, std::char_traits, std::allocator >(std::basic_istream<char, std::char_traits >&, std::basic_string<char, std::char_traits, std::allocator >&, char)'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::string::_M_leak_hard()' /usr/local/lib/libAntTweakBar.so: undefined reference to std::string::assign(char const
, unsigned long)'
/usr/local/lib/libAntTweakBar.so: undefined reference to std::__throw_length_error(char const*)' /usr/local/lib/libAntTweakBar.so: undefined reference tostd::ios_base::ios_base()'
/usr/local/lib/libAntTweakBar.so: undefined reference to __cxa_guard_release' /usr/local/lib/libAntTweakBar.so: undefined reference tooperator delete(void
)'
/usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_iostream<char, std::char_traits<char> >::~basic_iostream()' /usr/local/lib/libAntTweakBar.so: undefined reference tostd::string::_M_mutate(unsigned long, unsigned long, unsigned long)'
/usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const_, std::allocator<char> const&)' /usr/local/lib/libAntTweakBar.so: undefined reference to vtable for std::basic_stringbuf<char, std::char_traits, std::allocator >'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::locale::locale()' /usr/local/lib/libAntTweakBar.so: undefined reference to operator new[](unsigned long)'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::string::append(unsigned long, char)' /usr/local/lib/libAntTweakBar.so: undefined reference to __cxa_pure_virtual'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_sync(char_, unsigned long, unsigned long)' /usr/local/lib/libAntTweakBar.so: undefined reference to vtable for std::basic_ios<char, std::char_traits >'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::__throw_out_of_range(char const_)' /usr/local/lib/libAntTweakBar.so: undefined reference to __gxx_personality_v0'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::string::_Rep::_S_empty_rep_storage' /usr/local/lib/libAntTweakBar.so: undefined reference to std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&, unsigned long, unsigned long)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::string::compare(char const*) const'
/usr/local/lib/libAntTweakBar.so: undefined reference to__cxa_guard_abort' /usr/local/lib/libAntTweakBar.so: undefined reference to std::__throw_bad_alloc()'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::string::append(std::string const&)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::string::append(char const*)'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::string::_Rep::_M_dispose(std::allocator<char> const&)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const_, long)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_stringstream<char, std::char_traits, std::allocator >::~basic_stringstream()'
/usr/local/lib/libAntTweakBar.so: undefined reference to__cxa_end_catch' /usr/local/lib/libAntTweakBar.so: undefined reference to __cxa_guard_acquire'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::string::find_first_not_of(char const_, unsigned long, unsigned long) const' /usr/local/lib/libAntTweakBar.so: undefined reference to vtable for std::basic_streambuf<char, std::char_traits >'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::locale::~locale()' /usr/local/lib/libAntTweakBar.so: undefined reference to vtable for __cxxabiv1::__class_type_info'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::string::push_back(char)' /usr/local/lib/libAntTweakBar.so: undefined reference to VTT for std::basic_ostringstream<char, std::char_traits, std::allocator >'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::ios_base::~ios_base()' /usr/local/lib/libAntTweakBar.so: undefined reference to std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::__throw_logic_error(char const_)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::_Rb_tree_increment(std::Rb_tree_node_base)'
/usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(unsigned long, char, std::allocator<char> const&)' /usr/local/lib/libAntTweakBar.so: undefined reference tostd::_Rb_tree_decrement(std::Rb_tree_node_base)'
/usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >_)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::string::assign(char const*)'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::string::assign(std::string const&)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::string::insert(unsigned long, char const*, unsigned long)'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_ios<char, std::char_traits >::clear(std::Ios_Iostate)'
/usr/local/lib/libAntTweakBar.so: undefined reference tostd::ostream::operator<<(int)' /usr/local/lib/libAntTweakBar.so: undefined reference to std::string::resize(unsigned long, char)'
/usr/local/lib/libAntTweakBar.so: undefined reference to__cxa_rethrow' /usr/local/lib/libAntTweakBar.so: undefined reference to std::basic_string<char, std::char_traits, std::allocator >::basic_string(std::string const&)'
/usr/local/lib/libAntTweakBar.so: undefined reference tovtable for __cxxabiv1::__si_class_type_info' /usr/local/lib/libAntTweakBar.so: undefined reference to std::ostream& std::ostream::M_insert(double)'
/usr/local/lib/libAntTweakBar.so: undefined reference to`std::string::append(char const
, unsigned long)'
collect2: error: ld returned 1 exit status
make[2]: *
* [demo-atb-agg] Error 1
make[1]: *** [CMakeFiles/demo-atb-agg.dir/all] Error 2
make: *** [all] Error 2

Font atlas reuse.

Hi.I wonder if I can reuse font atlases.So that ,for example,I save generated atlas to texture then on the next run I load it and pass to the texture atlas struxture to be used instead of creating a new atlas.

OpenGL 3.2 Core profile support

Rendering with 3.2 compat works and if I change it to core, I get GL_INVALID_OPERATION from somewhere in freetype-gl. I'm not sure where it comes from, but nothing gets rendered.

Change copyright notice

Current notice in most files reads

 * Copyright 2011,2012 Nicolas P. Rougier. All rights reserved.

It should now be something like

 * Copyright 2011, 2012, Nicolas P. Rougier. All rights reserved.
 * Copyright 2013, 2014, 2015 Marcel Metz & Nicolas P. Rougier. All rights reserved.

switch from wchar_t to utf8 or utf32

so, i'm using freetype-gl for font rendering in an application where
all of my strings are utf8. my concern with wchar_t is that it's of a different
size on windows (ucs2) and everywhere else (ucs4) and it seems to me that
this is a better way forward than the wchar_t situation.

i have some modifications for texture-font which make it take ucs4 (uint32_t)
values instead of wchar_t, and i'm 100% willing to submit the pull request but
i'd like to know how you feel about the situation first.

Mixed styles

Is it possible to mix styles like half of the word to be italic and the rest bold ?

makefont building error (linking with GL)

Scanning dependencies of target demo-texture
[ 96%] Building C object CMakeFiles/demo-texture.dir/demo-texture.c.o
Linking C executable demo-texture
[ 96%] Built target demo-texture
Scanning dependencies of target makefont
[100%] Building C object CMakeFiles/makefont.dir/makefont.c.o
Linking C executable makefont
/usr/bin/ld: libfreetype-gl.a(texture-atlas.c.o): undefined reference to symbol 'glTexImage2D'
/usr/bin/ld: note: 'glTexImage2D' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libGL.so so try adding it to the linker command line
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libGL.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [makefont] Error 1
make[1]: *** [CMakeFiles/makefont.dir/all] Error 2
make: *** [all] Error 2

Ubuntu 12.04 x86_64. Source tree from master.
Other demos work fine.
Some people reported this issue too (http://code.google.com/p/freetype-gl/issues/detail?id=59).

On my system it seems like it links with wrong DSO (mesa instead of nvidia):

ls -lah /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libGL.so
lrwxrwxrwx 1 root root 13 Jun 19 00:54 /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libGL.so -> mesa/libGL.so

Just a speculation: this bug (check https://bugs.launchpad.net/ubuntu/+source/mesa/+bug/943162) happens with some other software. With compile-time dynamic linking the mentioned bug doesn't occur (on my system) - but maybe with static library ("/usr/bin/ld: libfreetype-gl.a(texture-atlas.c.o)") this bug occures too..
By the way, "export LD_LIBRARY_PATH=/usr/lib/nvidia-304-updates" usually makes dlopen (runtime library loading) work, but building freetype-gl still fails (I tried rebuilding from scratch after changing LD_LIBRARY_PATH) - this is strange.

Example demo-font not working: error in vertex_buffer_new.

Hi. Trying to run this example. I had to alter a few things to make it run (but not any logic). However, when it runs, I get this error:

program: /home/ploppz/work/c++/lib/freetype-gl/vector.c:46: vector_new: Assertion `item_size' failed.

After looking at all function calls to vector_new that appears in the freetype-gl library, it appears that the error has to be in line 199 of vertex-buffer.c, where stride must be equal to 0.

In the program, this is how vertex_buffer_new is called: buffer = vertex_buffer_new( "v3f:t2f:c4f" );

How can I change the format sent to vertex_buffer_new so that it evaluates a stride that's != 0?

I'm also wondering if the examples are outdated.

Edit: Also, where can I find documentation of the format string used in vertex_buffer_new?

Thanks.

GLFW and OSX retina display

There is a problem with window size on macbook with OSX retina display. For example, the ansi demo is rendered like this:

untitled

The problem comes from OSX that advertise "wrong" window resolution (half the actual pixel size).
See also #75

Suggestion: vector performance improvement

In your vector.h/.c you use runtime evaluated self->item_size:

// ------------------------------------------------------------- vector_get ---
void *
vector_get( const vector_t *self,
            size_t index )
{
    assert( self );
    assert( self->size );
    assert( index  < self->size );

    return (char *) self->items + index * self->item_size;
}

Which leads to involving imul operation in this pointer arithmetic:
3
just to get pointer to array element.

code http://goo.gl/zyLA8w


  1. I suggest to replace self->item_size with defined value. To use #define function, like this:
#define vector_get(self, index, size) \
    return (char *) self->items + size;        // or +sizeof(type), whatever you like more

size/type is known when you call for get (at least in your cases).

OR

  1. As you write cross platform library, you should target on OpenGL ES 2.0. Thus you can work ONLY with GL_FLOAT arrays. Nothing more it does not accept. So, you may just hardcore self->item_size as sizeof(GL_FLOAT). [Personally I use this variant in my project]

OR

  1. Wrap your whole vector class in "define",
#define CAT1(A, B) A ## B
#define CAT(A, B) CAT1(A, B)

#define make_vector(type) \
struct CAT(vector_, type) { \
   // your class here \
}

// in some startup place ...
make_vector(float)
make_vector(int)

so you can have : vector_float, vector_int, etc... And use them.
In addition you can make :

define vector(type) CAT(vector_, type)

And use it like templated vector in C++ :
vector(float).get(12) ...

Compile problems with freetype-gl on windows 7 64-bit

1.) I've downloaded a zip file of freetype-gl-master.zip and uncompressed it to a directory
2.) Then i launched a command line prompt (cmd) and navigated to the directory where i've uncompressed the zip file
3.) then i typed the following in order

mkdir build
cd build
cmake ..
make

but when i typed "cmake .." i get these errors from the console

Determining if the C compiler works failed with the following output:
Change Dir: C:/Users/Lely/Downloads/freetype-gl-master/freetype-gl-master/build/CMakeFiles/CMakeTmp

Run Build Command:c:\PROGRA2\MICROS2.0\Common7\IDE\devenv.com CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec2741211043

Microsoft (R) Visual Studio Version 10.0.30319.1.

Copyright (C) Microsoft Corp. All rights reserved.

1>------ Build started: Project: cmTryCompileExec2741211043, Configuration: Debug Win32 ------

1>Build started 12/27/2013 5:51:25 PM.

1>PrepareForBuild:

1> Creating directory "C:\Users\Lely\Downloads\freetype-gl-master\freetype-gl-master\build\CMakeFiles\CMakeTmp\Debug".

1>InitializeBuildStatus:

1> Creating "cmTryCompileExec2741211043.dir\Debug\cmTryCompileExec2741211043.unsuccessfulbuild" because "AlwaysCreate" was specified.

1>ClCompile:

1> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86

1> Copyright (C) Microsoft Corporation. All rights reserved.

1>

1> cl /c /Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR="Debug"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"cmTryCompileExec2741211043.dir\Debug" /Fd"cmTryCompileExec2741211043.dir\Debug\vc100.pdb" /Gd /TC /analyze- /errorReport:prompt testCCompiler.c

1>

1> testCCompiler.c

1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

1>

1>Build FAILED.

1>

1>Time Elapsed 00:00:00.51

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

so i didn't get any chance to type in "make" at all

Hope someone can help me out.

God bless,
Eisen Sy

Outline color?

I've looked through the documentation, but I cannot find the means of setting the outline color. The outline demo just shows a white outline, but I need to know how to control the outline color separate from the text color. (Aiming for solid white text with a black outline.)

Something like this: logo

How do I compile static library with FREETYPE_GL_USE_VAO?

Hi.

I'm unfamiliar to cmake, so I'm unsure how I should do this. Just SET( FREETYPE_GL_USE_VAO ) in the make file?

Thanks.

Also, additional note / bonus quesiton:
Is there really no other documentation than this? It is not really helpful; to get started, I'm looking only at an example and the source code, which is not the most time-efficient way to learn how to use a library... The documentation also omits important details like the format string used in vertex_buffer_new(), and which directives you can actually set: I found out of this one when I had to debug my code and figured I'd have to set FREETYPE_GL_USE_VAO when looking at the source.

texture_font_load_glyphs problem: useless texture glyphs

Hi,

Thanks a lot for developping/maintaining this library, it's a real pleasure to use it.

The problem in screens (the black/red texture is the atlas texture of the font loaded: Vera.ttf) :

  1. with texture_font_load_glyphs call in my own write function (call texture_font_load_glyphs once, texture_font_get_glyph and texture_glyph_get_kerning).

pb_freetype_gl

  1. without texture_font_load_glyphs call:

bizarre

The string displayed is "test" concatenated 68 times.

  1. With "test" concatenated 34 times and with texture_font_load_glyphs call:

bug2

OSX El Capitan makefont build error

When I try to build freetype on OSX El Capitan, it seems to build most of the project, but fails on linking the makefont executable.

Output:

[ 1%] Building C object CMakeFiles/freetype-gl.dir/mat4.c.o
[ 3%] Building C object CMakeFiles/freetype-gl.dir/texture-atlas.c.o
[ 5%] Building C object CMakeFiles/freetype-gl.dir/texture-font.c.o
[ 7%] Building C object CMakeFiles/freetype-gl.dir/vertex-buffer.c.o
[ 9%] Building C object CMakeFiles/freetype-gl.dir/vertex-attribute.c.o
[ 11%] Building C object CMakeFiles/freetype-gl.dir/font-manager.c.o
[ 12%] Building C object CMakeFiles/freetype-gl.dir/text-buffer.c.o
[ 14%] Building C object CMakeFiles/freetype-gl.dir/shader.c.o
[ 16%] Building C object CMakeFiles/freetype-gl.dir/vector.c.o
[ 18%] Building C object CMakeFiles/freetype-gl.dir/utf8-utils.c.o
[ 20%] Building C object CMakeFiles/freetype-gl.dir/platform.c.o
[ 22%] Building C object CMakeFiles/freetype-gl.dir/edtaa3func.c.o
[ 24%] Linking C static library libfreetype-gl.a
[ 24%] Built target freetype-gl
[ 25%] Building C object CMakeFiles/makefont.dir/makefont.c.o
[ 27%] Linking C executable makefont
Undefined symbols for architecture x86_64:
"_CFArrayAppendValue", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
_getElementsCFArrayHandler in libglfw3.a(iokit_joystick.m.o)
"_CFArrayApplyFunction", referenced from:
_matchCallback in libglfw3.a(iokit_joystick.m.o)
"_CFArrayCreateMutable", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
_matchCallback in libglfw3.a(iokit_joystick.m.o)
"_CFArrayGetCount", referenced from:

...

All of the errors seem to be glfw3 referencing undefined OSX framework symbols in CoreFoundation, CoreVideo, and IOKit. I'm not sure if this is an error with glfw3 or freetype-gl, but its not compiling. I tried adding the missing frameworks via -framework compiler flags in CMakeLists.txt, but it didn't help.

Compile to DLL?

I would like to make a binding of freetype-gl for .NET to use with the SFML .NET bindings and I'm a bit stumped as to how to get started. The only interop method I know of is through a DLL but freetype-gl builds a .lib by default. Any advice on where to get started or if I'm even pointed in the right direction?

Instead of wchar_t...

For some reason I missed earlier similar issue, even though I checked them through. But I strongly suggest to to do this change anyway.

GLSL version 1.50 fails

Hello,

I've been trying to get your library running with OpenGL Core Profile 3.2 and GLSL 1.50, but unfortunately without any success. I'm building it on Mac and everything runs well with the previous versions of OpenGL, but when I give it a try with my converted shaders that are ver. 1.50 compatible and add the GLUT_3_2_CORE_PROFILE option to GLUT, it shows me a blank screen. (it actually sets the clear color and doesn't show the texture at all) I've adjusted the easiest shaders there were. The pair is named v3f-t2f-c4f.vert and v3f-t2f-c4f.frag. The rest of the code is exactly the same. I will post the converted shaders here, please tell me if I should be missing something, cause I've been trying everything for the past week.

#version 150

uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

in vec3 vertex;
in vec2 tex_coord;
in vec4 color;

out vec2 vTexCoord;
out vec4 vColor;

void main()
{
    vTexCoord= tex_coord.xy;
    vColor = color;
    gl_Position = projection*(view*(model*vec4(vertex,1.0)));
}
#version 150

uniform sampler2D tex;

in vec2 vTexCoord;
in vec4 vColor;

out vec4 outColor;

void main()
{
    float a = texture(tex, vTexCoord.st).r;
    outColor = vec4(vColor.rgb, vColor.a*a);
}

Compiling instructions?

Are there any compiling instructions anywhere? I've been ripping my hair out trying to figure everything out. I've tried using CMake, but it produces an .sln that won't compile.

Please remove the MSVC version of stdint.h from the repository

Most compilers (probably all) have their own versions of stdint.h in their include packages. I use mingw and clang, and i can confirm that by simply deleting freetype-gl\windows\include\stdint.h there are no other compatibility issues.

so as a small FYI, using #ifdef _MSC_VER cant be used to regulate this include.
under mingw and clang, stdint.h is included by inittypes.h which is included by glut which isnt gated by a _MSC_VER, and as you know the compiler with prefer the project local version of stdint.h over the compiler local version.

Thankyou for your time, keep up the good work.

Width and height params are switched for distance field calculation

In the demo-distance-field-* files, one of the function calls in the method that does the signed distance calculation passes width and height in the wrong order. There's no noticeable effect because the textures used in the demos for the atlas are square.

Specifically in the make_distance_map method used in each demo,

edtaa3(data, gx, gy, height, width, xdist, ydist, inside);

should read

edtaa3(data, gx, gy, width, height, xdist, ydist, inside);

makefont produce error file header

print wide chars using char* parameters,
makefont.c:285 wprintf( L"Font filename : %s\n", font_filename );

I don't know how to create a pull request, so just paste my solution here for reference(need C++11 support):

std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> utf16conv;
std::u16string wfont_filename = utf16conv.from_bytes(font_filename);
std::u16string wheader_filename = utf16conv.from_bytes(header_filename);
std::u16string wvariable_name = utf16conv.from_bytes(variable_name);

wprintf( L"Font filename              : %s\n", wfont_filename.data());
wprintf( L"Header filename            : %s\n", wheader_filename.data() );
wprintf( L"Variable name              : %s\n", wvariable_name.data() );

Instructions for using this project

I'm having a bit of trouble trying to figure out how to use this library in my own project, the examples are okay, but it would be nice with some build instructions. Exs: does this build and install the library on my computer? Is there a CMakeModule for this library I can include in my own project? Can I build this without building the demoes? Do I need AntTweekBar to build this when I'm not using it in my own project? Can I add this project as a submodule on git and reference the CMakeList in some way? Would it be best to copy paste the source code and write my own buildfile? And how would this work if I'm trying to create a reproducible build working across several platform?

The demoes is okay for showing how to use the product, but I'm having a few problems trying to figure out how to use this with my own project. So it would be nice with some instructions in the Readme-file on how to build and best reference the library.

In the need of better documentation

I was told this should be a separate issue so here goes.

Is this the only documentation there is? It is not really helpful. To get started, I'm looking only at a demo and the source code, trying to assemble something that might work, which is not the most time-efficient way to learn how to use a library... The documentation also omits important details like the format string used in vertex_buffer_new(), which I am still clueless about!
It should also include, for example, instructions on how to configure freetype-gl by setting directives.
It should include (at least some brief) tutorials to get started (take freetype as a good example). Documentation on each function separately is a good step but not sufficient, as it does not let you see the big picture of how these functions are supposed to work together. Now that's my opinion.

I'm just writing this in the hope that someone will do something about it and make freetype-gl more accessible.

Thanks!

glsl version 330+

Is it possible to use a shader version 330 or higher? In the examples, version 120-150. My program for all versions of the 330. Also where the font.

................

Separation of Glew from Library

Hi, just looking at using freetype-gl in a project of mine, looks like great work, thanks.

Looking through the the code and it seems that the glew library is only used by the demos (correct me if I'm wrong) but is nevertheless included in the main "opengl.h" header. I'd like to use freetype-gl without being forced to compile or link with glew...Just my $.02 in case it's possible to remove the dependency from the basic freetype-gl lib.

(I know I could remove it myself but then would need to maintain for future updates.)

Freetype-GL crashes for unknown reason.

Here's my code:

bigfont_atlas = texture_atlas_new(1024, 1024, 3);
bigfont_markup.font = texture_font_new_from_file(bigfont_atlas, 48, "SYSTEM/fonts/crillee.otf");
bigfont_textbuf = text_buffer_new(3);

Upon calling text_buffer_new, it kills the GPU, causing a crash in nvogl32.dll.

I'm not sure why. Did I do something wrong?

Link Error from texture-font.obj

Good day,

I tried setting up freetype-gl for my project. and i'm getting a link error

platform.obj : error LNK2005: _round already defined in kernel.cu.obj
texture-font.obj : error LNK2019: unresolved external symbol _FT_Library_SetLcdFilterWeights referenced in function _texture_font_load_glyphs

My project is setup so that all headers and c source codes are included in my project.
1.) Is this a good approach?
2.) If not do i need to link to freetype-gl.lib only or do i need to link to all individual obj files (i.e. text-buffer.obj, shader.obj, font-manager.obj, etc.)?
3.) I'm using CUDA 5.5 to run my main function inside a source.cu file, is this a problem for freetype-gl?

Thanks in advance.

God bless,
Eisen Sy

Multiple errors on Visual Studio compilation

I have a new setup of the lib (my previous got deleted ) and when compiling I am getting tons of errors in texture-font.c I am not sure if my project settints are right.I set "compile as C" and use Unicode as encoding .But also tried to compile as C++ project.Still the same.

Some of the errors:

e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(430): error C2143: syntax error : missing ';' before 'type'
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(437): error C2065: 'pass' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(443): error C2065: 'pass' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(448): error C2065: 'pass' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(451): error C2143: syntax error : missing ';' before 'type'
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(452): error C2143: syntax error : missing ';' before 'type'
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(453): error C2143: syntax error : missing ';' before 'type'
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(460): error C2065: 'flags' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(464): error C2065: 'flags' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(469): error C2065: 'flags' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(473): error C2065: 'flags' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(480): error C2065: 'flags' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(486): error C2065: 'flags' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(501): error C2065: 'ft_glyph_top' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(502): error C2065: 'ft_glyph_left' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(584): error C2065: 'ft_glyph_top' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(585): error C2065: 'ft_glyph_left' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(614): error C2065: 'ft_glyph_left' : undeclared identifier
1>e:\documents\visual studio 2012\projects\gltextexp\freetypegldemos\texture-font.c(615): error C2065: 'ft_glyph_top' : undeclared identifier

Issue with building on Mac OS X

Building on OS X is giving me the same problems shown in this bugreport of another project.

The (admittedly hacky) solution is to simply add "/usr/local/include/freetype2/" before ${FREETYPE_INCLUDE_DIRS} in include_directories. This makes it build fine.

The use of an absolute path is justified by the notion that folder paths on Windows and OS X barely (or never) change.

Is this worth merging in master branch?

Conflict with GLM

GLM uses identically named types for the matrix and vector types created by freetype-gl. All of the glm types are protected by namespaces, but not so in freetype-gl, so it can cause issues for files which have previous "using glm::vec4" etc declarations.

What's the possibility of renaming those data types to something which will have fewer name conflicts, since names like mat4, vec4, etc are common enough to cause headaches for more than just myself?

Trying to recreate demo-font example (different context)

Hi. I'm writing in C++ but I don't think it matters. I'm also using GLFW. This is the demo that I'm looking at and copying (modified) code from. I'm trying to implement this in another small test case I made some time ago which will be explained shortly. I have freetype-gl compiled with -DFREETYPE_GL_USE_VAO, so that it does not ruin the creatively named VAO in my code.
main.cpp
glwrapper.h, glwrapper.cpp (don't pay too much attention to these)

Brief explanation of the functions in main.cpp:
ortho2D and viewMatrix2D just create projection and view matrices that I don't really use to render the font. (ortho2D is very similar to mat4_set_orthographic, but makes (0, 0) the center of the window, and viewMatrix2D just makes a view matrix that offsets coordinates).

Setting up the font starts at line 102, and rendering of the text starts at line 152. I have the directories shaders and fonts copied from this repository.

The result is a triangle rotating in a relatively small circle. To make the text rendering more straight-forward, I use the same model, view and projection matrices as in the demo, with only the projection matrix slightly different, analogous to the projection matrix of the triangle itself. (I tested this matrix directly in the demo, and it worked as expected: [0, 0] is at the center of the window.) Model and view are identity matrices.

My problem is that the text does not get rendered at all. It appears to me like I do pretty much the same as in the demo itself but it still does not work. I would really appreciate of someone could look through my code and try to spot eventual errors!

Thanks!

vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" ); throws heap exceptions in C++ project on calling free

Hi.I first posted it on googlecode repo .So here it is again:

What steps will reproduce the problem?
1.Use freetype as external lib in VC10 or VC11 project.
2.
3.

Throws _BLOCK_TYPE_IS_INVALID on line 90 (free(desc))

in vertex-buffer.c

What is the expected output? What do you see instead?
It doesn't happen when running it in freetype-gl C examples.

What version of the product are you using? On what operating system?
Win7 64bit ,VisualStudio2012 .VC10 ,VC11

Btw,I debugged the block in vertex-buffer. c (lines 78- 90) and found that the free(desc) crashes only on the last attribute "color:4f" which in turn the only one which sets desc with strup(start),the previous two set desc with strnup.Maybe usage of strup somehow causes location being freed by free() to get invalid?

Ok,I fixed it.it becomes obvious if setting the lib to compile to C++ and not to C.In such a case the compiler throws error:

" The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup

"

So I replaced all strdup with _strdup and free() doesn't throw errors anymore.Do you want to make this fix in the repo?

glfw3 not found

CMake Error at CMakeLists.txt:78 (FIND_PACKAGE):
By not providing "Findglfw3.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "glfw3", but
CMake did not find one.

Could not find a package configuration file provided by "glfw3" with any of
the following names:

glfw3Config.cmake
glfw3-config.cmake

Add the installation prefix of "glfw3" to CMAKE_PREFIX_PATH or set
"glfw3_DIR" to a directory containing one of the above files. If "glfw3"
provides a separate development package or SDK, be sure it has been
installed.

-- Configuring incomplete, errors occurred!

Circular dependecies in CMake ?

When compiling, I now get:

...
[ 61%] Built target distance-field-3
make[2]: *** No rule to make target `demos/makefont', needed by `demos/vera-16.h'.  Stop.
make[1]: *** [demos/CMakeFiles/generate-embedded-font.dir/all] Error 2
make: *** [all] Error 2

and makefont is not yet build, any idea ?

Space char rendering

Is it true that spaces are still inserted into vertex buffer even though their dimensions are zero?It is quite a waste of memory and GPU processing time.Is it possible to filter those during rendering or even while building the VBO?

Multi-line text rendering

Does the lib supports multiline text by default?I mean all the lines are in the same vertex buffer.

Support shader files as embedded resources

It's difficult to build self-contained things on freetype-gl with shader loading relying on the filesystem. It would be great if we could embed shaders at build time, and free text-buffer.c from filesystem dependency.

In my working copy I handled it by adding shader_load_resource, which is essentially a copy of shader_load, except it takes the shader source as strings rather than file names:

GLuint
shader_load_resource( const char * vert_source,
                      const char * frag_source );

I use xxd -i to generate shader resource files (along with some sed tweaks, also the shader sources are run through the C preprocessor to strip out comments). Here's what the resource files look like:

> cat shaders/cube.frag.h 

#ifndef __shader_resource_cube_frag__
#define __shader_resource_cube_frag__
#ifdef __cplusplus
extern "C" {
#endif
char shader_resource_cube_frag[] = {
  0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a,
  0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61,
  0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x67, 0x6c, 0x5f,
  0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x7d, 0x0a
,0x00};

#ifdef __cplusplus
}
#endif
#endif

Then in text-buffer.c I have something like this:

#include "shaders/text.vert.h" // defines shader_resource_text_vert
#include "shaders/text.frag.h" // defines shader_resource_text_frag
...
self->shader = shader_load_resource(shader_resource_text_vert,
                                    shader_resource_text_frag);

This frees text-buffer.c from being filesystem-dependent. The same thing could be done with the demos.

Here's the script I'm using to generate the resource files. It's quick and dirty, but could be a starting point for something that would integrate with the build system.

for file in ?(*.vert|*.frag); do
prefix="shader_resource_"
guard="__$prefix$(echo -n $file | sed 's/[^a-z0-9]/_/gi')__"

echo "#ifndef $guard
#define $guard
#ifdef __cplusplus
extern \"C\" {
#endif" > $file.h

cpp -P $file > $prefix$file

xxd -i $prefix$file | sed '
  s/}\;/,0x00}\;/ ; 
  s/unsigned int.*// ;
  s/unsigned // ' >> $file.h

echo "#ifdef __cplusplus
}
#endif
#endif" >> $file.h

rm $prefix$file
done

cube-demo is so sloooowwwww

Not critical but something happened to the cube demo that now use clock instead of glutTimer and the animation is very slow on my machine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.