Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in texture_font_load_glyphs #207

Open
ltqsoft opened this issue Jan 24, 2019 · 9 comments
Open

Bug in texture_font_load_glyphs #207

ltqsoft opened this issue Jan 24, 2019 · 9 comments

Comments

@ltqsoft
Copy link

ltqsoft commented Jan 24, 2019

Program crashed with access violation error when I set texture atlas depth to 3, it worked fine with depth=1.
The other depth settings are yet to be checked so I don't know it also works or not.

@rougier
Copy link
Owner

rougier commented Jan 25, 2019

Do you have more information, like a working/non working example ?

@ltqsoft
Copy link
Author

ltqsoft commented Jan 28, 2019

Here is my example code:

#include "freetype-gl.h"
#include <stdio.h>

#define ALLCHARS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+| ,./<>?[]{}"

int main()
{
texture_atlas_t* atlas = texture_atlas_new(512, 512, 3);
texture_font_t* font = texture_font_new_from_file(atlas, 32, "Arial.ttf");
font->rendermode = RENDER_SIGNED_DISTANCE_FIELD;
printf("Loaded %d glyphs\n", texture_font_load_glyphs(font, ALLCHARS));
getchar();
}

I built the project without using cmake this time (just manually add source files), and at the second time the exception has been thrown at a different line.
If those works on your machine, may be I should rebuild FreeType, or I did messed something up with source files.

@rougier
Copy link
Owner

rougier commented Feb 1, 2019

Do you know which line is faulty?

@ltqsoft
Copy link
Author

ltqsoft commented Feb 1, 2019

The program stopped at texture_atlas.c, line 98. And here are some content in my own source file, is it different?

94 for( i=0; i<height; ++i )
95 {
96 memcpy( self->data+((y+i)self->width + x ) * charsize * depth,
97 data + (i
stride) * charsize, width * charsize * depth );
98 }

@rougier
Copy link
Owner

rougier commented Feb 2, 2019

From these information it is difficult to identify the problem. You should print all information (x,y,i,charsize,depth,etc.) to see if there's weird values.

@ltqsoft
Copy link
Author

ltqsoft commented Feb 2, 2019

I think there's a problem with loading the NULL glyph, if I comment it out, the program runs successfully (but I yet don't know if it works correctly).

@rougier
Copy link
Owner

rougier commented Feb 5, 2019

Why do you get a NULL glyph?

@ltqsoft
Copy link
Author

ltqsoft commented Feb 5, 2019

Oops, I mean the glyph represent the NULL character ('\0'), it was loaded first of all by the texture_font_init(...) function.

@rougier
Copy link
Owner

rougier commented Feb 5, 2019

Can you track (e.g. using printf) what is the faulty line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants