nothings
Repos
8
Followers
2314

Events

issue comment
Support implicit r and rg channel loading, only convert to luma then explicitly done.

Yes, I think adding new enum values without changing the old would be okay on the API front. The only other question is how much code needs to change, and how much extra maintenance overhead that might induce.

E.g., ignoring the API issue, I don't know if the submitted patch is actually correct. IIRC, PNG and maybe JPG will do some channel conversions automatically without ever calling stbi__convert_format. So it will be necessary to check those and make sure the new cases are handled (either as-you-go, or by loading normally and relying on stbi__convert_format; to be explicit, the point is that, again IIRC, PNG loader looks at desired_channels and tries to fix things up to fit, and it may expect only those 4 specific values to be present, and to be able to e.g. compare to the number of channels in the file. Note that the 1,2,3,4 convention in the API exactly matches how PNG's internal code for what channels are present, and the code probably relies on that. I don't know for sure, I wrote it 15 years ago.)

Created at 1 week ago
issue comment
Support implicit r and rg channel loading, only convert to luma then explicitly done.

This would break everyone using 1 & 2 currently. Not acceptable.

Created at 1 week ago
issue comment
stb_c_lexer: Adding support for octal and hexadecimal chars

Note that it looks like STB_C_LEXER_SELF_TEST just prints back the input string for string literals and char literals, which means you can't tell from that test that they're computing the wrong value in those cases. If the end location of a char literal is misparsed, that may or may not be recognized, but getting the end of the char literal wrong inside of a string literal will not be visible as well.

Created at 1 week ago
issue comment
stb_c_lexer: Adding support for octal and hexadecimal chars

if I'm reading the code right, there are multiple problems that should be straightforward to fix

  • in octal parsing, the first if() statement doesn't update *q, so a one-character octal value won't be parsed properly (e.g. "\1foo")
  • in octal parsing, the if()s aren't nested so digits later in a string can mess it up (e.g. try "\1f2")
  • in hex parsing, the if()s aren't nested so digits later in a string can mess it up (e.g. try "\x1z1")
  • hex character size is implementation-defined in C, so parsing isn't limited to 3 characters. should just do a full-sized hex parse, error if it overflows. The overflow size is the size of the literal used; for character literals that's long int_number and for string literals it's sizeof(char) so check the result fits in 8-bits (but use the full parse). Note that this overflow checking is NOT done elsewhere in stb_c_lexer, but we should improve that, so this is a good place to start.

style improvements:

  • should only write to *q once at end for clarity in both octal and hex constants, might be clearest by advancing p as you read and then doing *q = p.
  • although it's inconsistent with the value types, should probably parse the initial hex value in an unsigned type, since that's a more natural fit for hex constants
Created at 1 week ago
closed issue
PackFontRanges() creates a sigsegv crash

Describe the bug On file: stb_truetype.h Before execution of line #4118, access to spc->pixels works normally After execution of the loop, the address stops being accesible, and code that needs to access the pixel buffer just segfaults the application.

STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
{
   stbtt_fontinfo info;
   int i,j,n, return_value = 1;
   //stbrp_context *context = (stbrp_context *) spc->pack_info;
   stbrp_rect    *rects;

// <---- spc->pixels memory is readable correctly, and zeroed as expected
   // flag all characters as NOT packed
   for (i=0; i < num_ranges; ++i)
      for (j=0; j < ranges[i].num_chars; ++j)
         ranges[i].chardata_for_range[j].x0 =
         ranges[i].chardata_for_range[j].y0 =
         ranges[i].chardata_for_range[j].x1 =
         ranges[i].chardata_for_range[j].y1 = 0;
// <---- spc->pixels memory is not accessible anymore
   n = 0;

The line that crashes with SIGSEGV is at #3192

result->pixels[j*result->stride + i] = (unsigned char) m;

Code in between this line, and the previously mentioned for loop, works correctly without crashing.

To Reproduce

  • Follow the Font Packing documentation in stb_truetype
  • Try to pack font LiberationMono-Bold.ttf, with charset range 0x20 to 0x7F
  • Compile on linux, with gcc -ggdb
  • Execution will end with a Segmentation Fault, during the call to stbtt_PackFontRange

Expected behavior If the spc->pixels buffer is accessible correctly right before the loop to flag all characters as not packed, code that doesn't modify that pixel buffer shouldn't break access to the buffer either.

Screenshots image

Created at 1 week ago
issue comment
PackFontRanges() creates a sigsegv crash

The loop in question only processes ranges. ranges is a user-supplied array of structs. It sounds like you haven't initialized ranges correctly in your code.

Created at 1 week ago
issue comment
stb_image_write: Support writing BMPs with alpha

The weird thing is that the documentation says it converts 1-channel bmp to 3-channel bmp, so I didn't realize there was anything wrong with it. But if it used to work correctly, it should probably be fixed.

Created at 1 week ago
issue comment
stb_image_write: Support writing BMPs with alpha

is the image output by v1.15 actually valid, i.e. if you load it in another program is it correct?

Created at 1 week ago
issue comment
Update stb_truetype.h to make it usable for IoT/embedded devices as well

This is the kind of robust complexity that I generally try to avoid in the stb libraries. For example, libjpg supports streaming image, whereas stb_image requires the whole image to be loaded at once. I generally leave it to the more robust, official libraries to support these sorts of things, and the stb libraries are meant to be simpler to use, to not worry too much about memory management, etc.

Created at 2 weeks ago
issue comment
Update stb_truetype.h to make it usable for IoT/embedded devices as well

Don't worry about it, the tests are mostly for my purpose, not for your testing. (The details is they are standalone and require a -D on the commandline to determine which one to have a main. And in some cases the data required to run them isn't in the report.)

Created at 2 weeks ago
issue comment
[Suggestion] stb_vorbis: "declaration shadows a local variable" Clang errors

I don't know the answer to your question, but it's a known source of bugs (e.g. introducing an inner-scoped variable that's already being used for a different purpose inside the scope), not purely stylistic.

Created at 2 weeks ago
issue comment
[Suggestion] stb_vorbis: "declaration shadows a local variable" Clang errors

@N-R-K This is a perfectly reasonable request.

Generally stb libraries try to compile without warnings with any reasonable set of warnings (not -Wall and definitely not -Wextra) to streamline the integration. In this particular cases -Wshadow combined with warnings-as-errors (which is perfectly reasonable to turn on as well) makes the file incompilable. I have no problem with the complaint, and I may fix it at some point and will certainly accept a PR that fixes it.

Created at 2 weeks ago
issue comment
Assertion failed while loading 32bit BMP

@sharmadhiraj86

Let me be clearer. The thing you did with the list of random contributors is spam and it is not cool and it is the kind of thing that will get you banned from this repository. You get one strike, if you do something like that again you're out.

Feel free to continue participating normally, or if that makes you uncomfortable feel free to stop, whatever, but I have better things to do than police the repository issue comments.

Created at 2 weeks ago
issue comment
Assertion failed while loading 32bit BMP

dude, why are you tagging a bunch of people? that's spam.

i don't use github assignment to outsider contributors, if you want to work on it, work on it.

Created at 2 weeks ago
issue comment
Assertion failed while loading 32bit BMP

it opens correctly in mspaint and photoshop and FreeImage, so it's probably worth fixing it. it appears to have extra data in the header, and instead of skipping that data, stb_image throws an error.

Created at 2 weeks ago
reopened issue
Assertion failed while loading 32bit BMP

The following gets written to the console after calling stbi_load: Assertion failed: info.offset == s->callback_already_read + (int) (s->img_buffer - s->img_buffer_original) stb_image.h, line 5397

Here is the BMP that triggers the error example_bmp.zip.

Created at 2 weeks ago
closed issue
Restore std_perlin.h

stb_perlin.h was removed in https://github.com/nothings/stb/commit/59e7dec3e8bb0a8d4050d03c2dc32cf71ffa87c6 due to a now expired patent. Comments on the commit indicate that the header should be restored.

The lack of action on this led me to https://github.com/microsoft/vcpkg/pull/25812 which would resolve a blocker elsewhere.

Created at 2 weeks ago
issue comment
Restore std_perlin.h

done

Created at 2 weeks ago

stb_perlin.h: restore file now that patent is expired

Merge branch 'master' of https://github.com/nothings/stb

update readme

Created at 2 weeks ago
opened issue
stb_image.h: better corrupt image reporting

The function void *stbi__load_main calls test() functions for each image format. If the function succeeds, then it accepts that it is the proper image format and calls the corresponding loader function (which may itself then fail). If the test() function fails, the next image format is attempted. If all attempted image formats fail, then a new error is generated: Image not of any known type, or corrupt.

This means that any attempt to report specific corruptions in the image formats during the "test" stage are discarded and never useful except in a debugger. Probably should try to rewrite this in some way so that if a test gets sufficiently far, it wins and its error diagnostic is actually reported. This may require two stages of test, or some kind of error code reported by test() which is "how likely is it that this is actually the correct image format for this file".

Created at 3 weeks ago
issue comment
support wingding.ttf font in stb_truetype

It doesn't make sense to add API complexity for a feature that no known fonts require.

There are no plans to support bitmapped fonts.

Created at 4 weeks ago
issue comment
support wingding.ttf font in stb_truetype

You should fix it so that you can specify what encoding you want and does not have to be Unicode. (For compatibility purpose, Unicode can be selected by default, but please to fix it to allow the caller to override the choice of encoding, e.g. by adding a separate function for this purpose)

I don't think there are enough fonts with multiple encodings for this to be worth doing. Just doing Unicode if available, then whatever the font supplies if not, should address all known fonts.

Created at 4 weeks ago
issue comment
Move off of Github

It's not a decision.

There are a number of reasons to consider moving off of github:

Created at 1 month ago
opened issue
Move off of Github

There are a number of reasons to consider moving off of github:

  • (not a reason for this project: because stb is public domain, I'm not concerned about the copyright issues of Github Copilot)
  • don't support Microsoft for political reasons (e.g. embrace / extend / extinguish)
  • github's weird thing where repositories owned by "organizations" have more features than those owned by individuals, but the docs do not bother distinguishing the cases so you can waste a lot of time trying to figure out why what you're looking at doesn't match the screenshots in the documentation
  • heavy-handed content moderation
  • github not having clear explanation/descriptions of moderated content (and I mean technically, not the subjective policy part)

To address the last two, the issue I ran into is the reported post: https://github.com/nothings/stb/issues/359#issuecomment-1198716058

My best guess is that this content was reported to Github, and a Github moderator/bot looked at the post and marked it as "disruptive content", but it's impossible to know what that text means because googling for it just turns up a million similarly tagged posts, which is why I can only guess at the meaning. But I'm assuming this is the case Github describes in one of their docs as as them taking action by "downgrading the visibility of the offending content". So this is (a) moderation I don't appreciate triggered by a disruptive user having reported my post, and (b) terrible UX on Github's part at letting me understand what is even happening to the post.

Created at 1 month ago
issue comment
Package-manager-friendly releases and/or sub-projects

Some minor administrivia unrelated to the technical content:

Somebody reported my curse-word-laden reply earlier in the thread, even though I'm the owner of the repository. I'm assuming it was the guy asking questions. So, he's banned. If it wasn't him, no great loss.

Since I don't appear to be able to process the report the way the docs say (I think this might be another organization-only feature, or this abuse report is a report-to-github not report-to-project), and the fact it's reported makes it hidden by default and permanently hidden to people without an account and I can't find any way to change it, I'm copy/pasting the reported post here for better visibility. (I guess if it was somebody else who reported it, well, you can report this one as well, but I'm not sure what exactly you think this is accomplishing.)

Didn't I just tell you I wouldn't answer this specific question because it's already been addressed?

How it is adressed alredy? Which one version string I should use on packaging as version to be be able give you necessary details abot version if someone will spot for exampe some bug?

Motherfucker, read the rest of the fucking post you just quoted and stop wasting my time. You are one post away from a ban.

Created at 1 month ago
issue comment
Package-manager-friendly releases and/or sub-projects

package-managment FAQ

How do I get tagged releases or otherwise use stb with a package manager?

You don't. It's not designed to do that.

But I need it!

That's not my job, that's your job. Sorry.

But why?

Read this post for a brief summary of the issues: https://github.com/nothings/stb/issues/359#issuecomment-1198320009

The brief summary doesn't really explain things enough?

Please read the relevant parts of the whole thread for more information on the issues.

What if I have a potential solution to the problem which accounts for the issues raised in the thread

Great, please share it with us. That's why this issue remains open.

Is it ok to post in this thread if I haven't done the other things described in this FAQ?

No, your post will be ignored and deleted.

Created at 1 month ago
issue comment
Package-manager-friendly releases and/or sub-projects

Didn't I just tell you I wouldn't answer this specific question because it's already been addressed?

How it is adressed alredy? Which one version string I should use on packaging as version to be be able give you necessary details abot version if someone will spot for exampe some bug?

Motherfucker, read the rest of the fucking post you just quoted.

Created at 1 month ago
issue comment
Package-manager-friendly releases and/or sub-projects

Didn't I just tell you I wouldn't answer this specific question because it's already been addressed? It's a huge waste of my time to write a new answer to this every time somebody asks.

But okay, here is the answer as far as I can remember offhand:

There aren't tagged releases because I don't have any interest in doing tagged releases. The stb projecct is not intended to be a package-manager friendly set of libraries. I didn't put it on github in 2014 to make it package-manager friendly, I put it on github in 2014 so there'd be a system for managing issues and pull requests that wasn't just "email patches to me".

In this thread I recognized the demand for tagged releases and expressed a willingness to do tagged releases if it wouldn't be too much friction for my workflow, but because in the end each library needs its own stream of tagged releases, there doesn't seem to be a viable workflow without splitting each library into its own project, which I'm not willing to do.

Created at 1 month ago
issue comment
First release?

Please take further discussion to #359.

Created at 1 month ago
issue comment
First release?

there is no version for stb as a whole. each library has its own version number, which can be found in the file itself at the top. the versions are also listed in the table on the front page under the directory listing.

Created at 1 month ago