diff options
| author | raysan5 <[email protected]> | 2018-05-20 00:37:16 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2018-05-20 00:37:16 +0200 |
| commit | 25d5e907ececc3930924835336a072e9ab0593ec (patch) | |
| tree | ca5526bad3b8515b91c3c7287be417e317aa1d57 /src/text.c | |
| parent | a1ec0a5bc33ab8726e55fa433ffc08fe3b42e539 (diff) | |
| download | raylib-25d5e907ececc3930924835336a072e9ab0593ec.tar.gz raylib-25d5e907ececc3930924835336a072e9ab0593ec.zip | |
Some code review (mainly comments)
Diffstat (limited to 'src/text.c')
| -rw-r--r-- | src/text.c | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -763,22 +763,23 @@ static Font LoadBMFont(const char *fileName) { Image imCopy = ImageCopy(imFont); - for (int i = 0; i < imCopy.width*imCopy.height; i++) ((unsigned char *)imCopy.data)[i] = 0xff; // WHITE pixel + for (int i = 0; i < imCopy.width*imCopy.height; i++) ((unsigned char *)imCopy.data)[i] = 0xff; ImageAlphaMask(&imCopy, imFont); font.texture = LoadTextureFromImage(imCopy); UnloadImage(imCopy); } else font.texture = LoadTextureFromImage(imFont); + + UnloadImage(imFont); + free(texPath); + + // Fill font characters info data font.baseSize = fontSize; font.charsCount = charsCount; font.chars = (CharInfo *)malloc(charsCount*sizeof(CharInfo)); - UnloadImage(imFont); - - free(texPath); - int charId, charX, charY, charWidth, charHeight, charOffsetX, charOffsetY, charAdvanceX; for (int i = 0; i < charsCount; i++) @@ -870,7 +871,7 @@ static Font LoadTTF(const char *fileName, int fontSize, int charsCount, int *fon for (int i = 0, k = 0; i < textureSize*textureSize; i++, k += 2) { - dataGrayAlpha[k] = 255; + dataGrayAlpha[k] = 0xff; dataGrayAlpha[k + 1] = dataBitmap[i]; } @@ -883,13 +884,11 @@ static Font LoadTTF(const char *fileName, int fontSize, int charsCount, int *fon image.mipmaps = 1; image.format = UNCOMPRESSED_GRAY_ALPHA; image.data = dataGrayAlpha; + font.texture = LoadTextureFromImage(image); // Load image into texture + UnloadImage(image); // Unloads image data (dataGrayAlpha) - font.texture = LoadTextureFromImage(image); - - //SavePNG("generated_ttf_image.png", (unsigned char *)image.data, image.width, image.height, 2); - - UnloadImage(image); // Unloads dataGrayAlpha - + + // Fill font characters info data font.baseSize = fontSize; font.charsCount = charsCount; font.chars = (CharInfo *)malloc(font.charsCount*sizeof(CharInfo)); |
