jtsiomb / libdrawtext

Simple library for fast anti-aliased text rendering in OpenGL
GNU Lesser General Public License v3.0
86 stars 13 forks source link

2 features proposal #3

Closed Fetterless closed 7 years ago

Fetterless commented 7 years ago

Good evening!

Thank you for this library! I want to propose 2 commits with changes that was needed in my test project:

  1. Loading of the .ttf-file from the memory buffer
  2. Drawing the text without a glu library.
jtsiomb commented 7 years ago

Hello, and thanks for taking the time to submit this. It would be better if there where two separate pull requests each for its own issue, but it doesn't matter in this instance. Both of your suggestions are very good, and I will incorporate them into libdrawtext, but not in the form of this pull request for two different reasons:

1) Opening a font from memory is very very useful, and a feature which I should have included in the first place, if not for just being too lazy to generalize I/O when I initially wrote this. But just providing a function which only reads from memory is not the best way to do this. The proper thing to do is to add an alternative open function (to both dtx_open_font and dtx_open_glyphmap) which takes an extra pointer to a dtx_io structure, which in turn contains function pointers for read/write, and possibly seek if necessary, operations, along with a closure pointer. This could then be used to read from memory, or by using alternative I/O systems (say read directly from pack files, zip files, whathaveyou). I have something similar in my libimago library, and it's a very common construction. I think I'll implement this myself soon as time allows, but if you prefer to do it yourself, contact me through email, and we'll work on the design and naming conventions.

2) Your conditional compilation of the GLU dependency seems very reasonable, and I would merge it as is (if it was in its own pull request), if not for the fact that you introduced a number of unnecessary formatting changes to the whole file. I can apply only the relevant changes manually, or you could submit a pull request for this without the formatting changes if you prefer to have your name show on the blame. Let me know.

Cheers (closing this pull request, feel free to open another and/or mail me as I said above).

Fetterless commented 7 years ago

Thank you for such a soon answer. I'll think more about opening from memory. As for the compilation without GLU - my bad, I'll form a separate correct pull request.