MCPcopy Create free account
hub / github.com/MyGUI/mygui / renderGlyph

Method renderGlyph

MyGUIEngine/src/MyGUI_ResourceTrueTypeFont.cpp:1074–1139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1072
1073 template<bool LAMode, bool UseBuffer, bool Antialias>
1074 void ResourceTrueTypeFont::renderGlyph(
1075 GlyphInfo& _info,
1076 uint8 _luminance0,
1077 uint8 _luminance1,
1078 uint8 _alpha,
1079 int _lineHeight,
1080 uint8* _texBuffer,
1081 int _texWidth,
1082 int _texHeight,
1083 int& _texX,
1084 int& _texY,
1085 uint8* _glyphBuffer)
1086 {
1087 int width = (int)std::ceil(_info.width);
1088 int height = (int)std::ceil(_info.height);
1089
1090 autoWrapGlyphPos(width, _texWidth, _lineHeight, _texX, _texY);
1091
1092 uint8* dest = _texBuffer + (_texY * _texWidth + _texX) * Pixel<LAMode>::getNumBytes();
1093
1094 // Calculate how much to advance the destination pointer after each row to get to the start of the next row.
1095 ptrdiff_t destNextRow = (_texWidth - width) * Pixel<LAMode>::getNumBytes();
1096
1097 if (!mMsdfMode || !UseBuffer)
1098 {
1099 for (int j = height; j > 0; --j)
1100 {
1101 int i;
1102 for (i = width; i > 1; i -= 2)
1103 {
1104 Pixel<LAMode, UseBuffer, Antialias>::set(dest, _luminance0, _alpha, _glyphBuffer);
1105 Pixel<LAMode, UseBuffer, Antialias>::set(dest, _luminance1, _alpha, _glyphBuffer);
1106 }
1107
1108 if (i > 0)
1109 Pixel<LAMode, UseBuffer, Antialias>::set(dest, _luminance0, _alpha, _glyphBuffer);
1110
1111 dest += destNextRow;
1112 }
1113 }
1114 else
1115 {
1116 for (int y = 0; y < height; ++y)
1117 {
1118 for (int x = 0; x < width; ++x)
1119 {
1120 for (int i = 0; i < 3; ++i)
1121 {
1122 *dest++ = *_glyphBuffer++;
1123 }
1124 *dest++ = 255;
1125 }
1126
1127 dest += destNextRow;
1128 }
1129 }
1130
1131 // Calculate and store the glyph's UV coordinates within the texture.

Callers

nothing calls this directly

Calls 1

setFunction · 0.50

Tested by

no test coverage detected