FreeType bitmaps are zeroed after rendering a glyph










0















I've created a repository that has the most basic way to reproduce my issue. I use Cmake to build and it's set up to statically link freetype into my executable.



FreeType is a submodule, so you can clone it all at once with:



git clone --recurse-submodules https://github.com/jeffw387/freetype_minimum_test



or if you prefer just clone freetype from git into the externals directory.



I'm currently testing on Ubuntu.



I can initialize FreeType, create a face from the font, and load a glyph from a character code with the FT_LOAD_RENDER flag all without errors.



Then when I inspect the bitmap buffer, it's zero-initialized on every row. I used gdb from within VS Code in order to inspect the buffer, but before that I also tried copying out the data line by line.



The font I'm testing with is a free font I found online, but I was able to test it in Libre Office and it seems to work just fine.



Can anyone spot a problem with the code? If anyone is willing I'd love to know if this repo creates the same issue on their machine.



Here's my cpp file for easy viewing:



#include <ft2build.h>
#include FT_FREETYPE_H
#include <iostream>
#include <vector>

int main()
FT_Library library;
if (FT_Init_FreeType(&library))
std::cout << "Error initializing FreeType.";


FT_Face face;
auto faceResult = FT_New_Face(library, "Anke.ttf", 0, &face);
if (faceResult)
std::cout << "Error creating face.";


if ((face->face_flags & FT_FACE_FLAG_SCALABLE) != FT_FACE_FLAG_SCALABLE)
std::cout << "Error: font is not scalable.";


if (FT_Set_Pixel_Sizes(face, 0, 50))
std::cout << "Error setting font pixel size.";


if (FT_Load_Char(face, 'P', FT_LOAD_RENDER))
std::cout << "Error loading or rendering glyph.";

auto bmp = face->glyph->bitmap;

return 0;










share|improve this question


























    0















    I've created a repository that has the most basic way to reproduce my issue. I use Cmake to build and it's set up to statically link freetype into my executable.



    FreeType is a submodule, so you can clone it all at once with:



    git clone --recurse-submodules https://github.com/jeffw387/freetype_minimum_test



    or if you prefer just clone freetype from git into the externals directory.



    I'm currently testing on Ubuntu.



    I can initialize FreeType, create a face from the font, and load a glyph from a character code with the FT_LOAD_RENDER flag all without errors.



    Then when I inspect the bitmap buffer, it's zero-initialized on every row. I used gdb from within VS Code in order to inspect the buffer, but before that I also tried copying out the data line by line.



    The font I'm testing with is a free font I found online, but I was able to test it in Libre Office and it seems to work just fine.



    Can anyone spot a problem with the code? If anyone is willing I'd love to know if this repo creates the same issue on their machine.



    Here's my cpp file for easy viewing:



    #include <ft2build.h>
    #include FT_FREETYPE_H
    #include <iostream>
    #include <vector>

    int main()
    FT_Library library;
    if (FT_Init_FreeType(&library))
    std::cout << "Error initializing FreeType.";


    FT_Face face;
    auto faceResult = FT_New_Face(library, "Anke.ttf", 0, &face);
    if (faceResult)
    std::cout << "Error creating face.";


    if ((face->face_flags & FT_FACE_FLAG_SCALABLE) != FT_FACE_FLAG_SCALABLE)
    std::cout << "Error: font is not scalable.";


    if (FT_Set_Pixel_Sizes(face, 0, 50))
    std::cout << "Error setting font pixel size.";


    if (FT_Load_Char(face, 'P', FT_LOAD_RENDER))
    std::cout << "Error loading or rendering glyph.";

    auto bmp = face->glyph->bitmap;

    return 0;










    share|improve this question
























      0












      0








      0








      I've created a repository that has the most basic way to reproduce my issue. I use Cmake to build and it's set up to statically link freetype into my executable.



      FreeType is a submodule, so you can clone it all at once with:



      git clone --recurse-submodules https://github.com/jeffw387/freetype_minimum_test



      or if you prefer just clone freetype from git into the externals directory.



      I'm currently testing on Ubuntu.



      I can initialize FreeType, create a face from the font, and load a glyph from a character code with the FT_LOAD_RENDER flag all without errors.



      Then when I inspect the bitmap buffer, it's zero-initialized on every row. I used gdb from within VS Code in order to inspect the buffer, but before that I also tried copying out the data line by line.



      The font I'm testing with is a free font I found online, but I was able to test it in Libre Office and it seems to work just fine.



      Can anyone spot a problem with the code? If anyone is willing I'd love to know if this repo creates the same issue on their machine.



      Here's my cpp file for easy viewing:



      #include <ft2build.h>
      #include FT_FREETYPE_H
      #include <iostream>
      #include <vector>

      int main()
      FT_Library library;
      if (FT_Init_FreeType(&library))
      std::cout << "Error initializing FreeType.";


      FT_Face face;
      auto faceResult = FT_New_Face(library, "Anke.ttf", 0, &face);
      if (faceResult)
      std::cout << "Error creating face.";


      if ((face->face_flags & FT_FACE_FLAG_SCALABLE) != FT_FACE_FLAG_SCALABLE)
      std::cout << "Error: font is not scalable.";


      if (FT_Set_Pixel_Sizes(face, 0, 50))
      std::cout << "Error setting font pixel size.";


      if (FT_Load_Char(face, 'P', FT_LOAD_RENDER))
      std::cout << "Error loading or rendering glyph.";

      auto bmp = face->glyph->bitmap;

      return 0;










      share|improve this question














      I've created a repository that has the most basic way to reproduce my issue. I use Cmake to build and it's set up to statically link freetype into my executable.



      FreeType is a submodule, so you can clone it all at once with:



      git clone --recurse-submodules https://github.com/jeffw387/freetype_minimum_test



      or if you prefer just clone freetype from git into the externals directory.



      I'm currently testing on Ubuntu.



      I can initialize FreeType, create a face from the font, and load a glyph from a character code with the FT_LOAD_RENDER flag all without errors.



      Then when I inspect the bitmap buffer, it's zero-initialized on every row. I used gdb from within VS Code in order to inspect the buffer, but before that I also tried copying out the data line by line.



      The font I'm testing with is a free font I found online, but I was able to test it in Libre Office and it seems to work just fine.



      Can anyone spot a problem with the code? If anyone is willing I'd love to know if this repo creates the same issue on their machine.



      Here's my cpp file for easy viewing:



      #include <ft2build.h>
      #include FT_FREETYPE_H
      #include <iostream>
      #include <vector>

      int main()
      FT_Library library;
      if (FT_Init_FreeType(&library))
      std::cout << "Error initializing FreeType.";


      FT_Face face;
      auto faceResult = FT_New_Face(library, "Anke.ttf", 0, &face);
      if (faceResult)
      std::cout << "Error creating face.";


      if ((face->face_flags & FT_FACE_FLAG_SCALABLE) != FT_FACE_FLAG_SCALABLE)
      std::cout << "Error: font is not scalable.";


      if (FT_Set_Pixel_Sizes(face, 0, 50))
      std::cout << "Error setting font pixel size.";


      if (FT_Load_Char(face, 'P', FT_LOAD_RENDER))
      std::cout << "Error loading or rendering glyph.";

      auto bmp = face->glyph->bitmap;

      return 0;







      c++ git cmake freetype






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 1:49









      Jeff WrightJeff Wright

      286




      286






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I've done some further testing and it seems like there was a problem with my freetype fork. I haven't gone to the trouble of figuring out what it was, but in any case now that I've tried it with a fresh clone from https://github.com/aseprite/freetype2 it works.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292050%2ffreetype-bitmaps-are-zeroed-after-rendering-a-glyph%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I've done some further testing and it seems like there was a problem with my freetype fork. I haven't gone to the trouble of figuring out what it was, but in any case now that I've tried it with a fresh clone from https://github.com/aseprite/freetype2 it works.






            share|improve this answer



























              0














              I've done some further testing and it seems like there was a problem with my freetype fork. I haven't gone to the trouble of figuring out what it was, but in any case now that I've tried it with a fresh clone from https://github.com/aseprite/freetype2 it works.






              share|improve this answer

























                0












                0








                0







                I've done some further testing and it seems like there was a problem with my freetype fork. I haven't gone to the trouble of figuring out what it was, but in any case now that I've tried it with a fresh clone from https://github.com/aseprite/freetype2 it works.






                share|improve this answer













                I've done some further testing and it seems like there was a problem with my freetype fork. I haven't gone to the trouble of figuring out what it was, but in any case now that I've tried it with a fresh clone from https://github.com/aseprite/freetype2 it works.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 16 '18 at 2:16









                Jeff WrightJeff Wright

                286




                286



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292050%2ffreetype-bitmaps-are-zeroed-after-rendering-a-glyph%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3

                    Museum of Modern and Contemporary Art of Trento and Rovereto