FreeType bitmaps are zeroed after rendering a glyph
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
add a comment |
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
add a comment |
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
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
c++ git cmake freetype
asked Nov 14 '18 at 1:49
Jeff WrightJeff Wright
286
286
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 16 '18 at 2:16
Jeff WrightJeff Wright
286
286
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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