Răsfoiți Sursa

Add 1 pixel padding to generated font atlas

This avoids artifacts when using SDF fonts with some characters that
happen to be on the first column of the texture atlas.
Üstün Ergenoglu 11 ani în urmă
părinte
comite
cba0d00f38
1 a modificat fișierele cu 2 adăugiri și 2 ștergeri
  1. 2 2
      tools/encoder/src/TTFFontEncoder.cpp

+ 2 - 2
tools/encoder/src/TTFFontEncoder.cpp

@@ -316,7 +316,7 @@ int writeFont(const char* inFilePath, const char* outFilePath, std::vector<unsig
         // Allocate temporary image buffer to draw the glyphs into.
         unsigned char* imageBuffer = (unsigned char*)malloc(imageWidth * imageHeight);
         memset(imageBuffer, 0, imageWidth * imageHeight);
-        penX = 0;
+        penX = 1;
         penY = 0;
         row = 0;
         i = 0;
@@ -339,7 +339,7 @@ int writeFont(const char* inFilePath, const char* outFilePath, std::vector<unsig
             // If we reach the end of the image wrap aroud to the next row.
             if ((penX + advance) > (int)imageWidth)
             {
-                penX = 0;
+                penX = 1;
                 row += 1;
                 penY = row * rowSize;
                 if (penY + rowSize > (int)imageHeight)