92
100
sprintf(texturefilename, "%i", UTF32);
94
102
vw_SetTextureProp(RI_MAGFILTER_LINEAR | RI_MINFILTER_LINEAR | RI_MIPFILTER_NONE, RI_CLAMP_TO_EDGE, true, TX_ALPHA_GREYSC, false);
95
NewChar->CharTexture = vw_CreateTextureFromMemory(texturefilename, pixels, NewChar->Width, NewChar->Height, 4, false);
103
NewChar->CharTexture = vw_CreateTextureFromMemory(texturefilename, pixels, NewChar->Width, NewChar->Height, 4, 0, 0, 0, false);
207
223
/////////////////////////////////
209
// выводим в bmp файл сгенерированный DIB, если нужно проверить
212
temp = SDL_CreateRGBSurface(SDL_SWSURFACE, FontTextureWidth, FontTextureHeight, 32,
213
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
214
0x000000FF, 0x0000FF00, 0x00FF0000, 0
216
0x00FF0000, 0x0000FF00, 0x000000FF, 0
219
memcpy(temp->pixels, DIB, FontTextureWidth*FontTextureHeight*4);
220
SDL_SaveBMP(temp, "fontgenerationtest.bmp");
221
SDL_FreeSurface(temp);
225
// выводим в tga файл сгенерированный DIB, если нужно проверить
227
SDL_RWops *TgaFile = SDL_RWFromFile("fontgenerationtest.tga", "wb");
230
fprintf(stderr, "Can't open VFS file for write.\n");
234
unsigned char UselessChar = 0; // used for useless char.
235
short int UselessInt = 0; // used for useless int.
236
unsigned char ImageType = 2; // Type of image we are saving.
237
unsigned char ImageBits = 32; // Bit depth.
238
short int ImageWidth = (short int)FontTextureWidth;
239
short int ImageHeight = (short int)FontTextureHeight;
241
// пишем неиспользуемые данные
242
SDL_RWwrite(TgaFile, &UselessChar, sizeof(unsigned char), 1);
243
SDL_RWwrite(TgaFile, &UselessChar, sizeof(unsigned char), 1);
245
SDL_RWwrite(TgaFile, &ImageType, sizeof(unsigned char), 1);
246
// пишем неиспользуемые данные
247
SDL_RWwrite(TgaFile, &UselessInt, sizeof(short int), 1);
248
SDL_RWwrite(TgaFile, &UselessInt, sizeof(short int), 1);
249
SDL_RWwrite(TgaFile, &UselessChar, sizeof(unsigned char), 1);
250
SDL_RWwrite(TgaFile, &UselessInt, sizeof(short int), 1);
251
SDL_RWwrite(TgaFile, &UselessInt, sizeof(short int), 1);
252
// записываем параметры картинки
253
SDL_RWwrite(TgaFile, &ImageWidth, sizeof(short int), 1);
254
SDL_RWwrite(TgaFile, &ImageHeight, sizeof(short int), 1);
255
SDL_RWwrite(TgaFile, &ImageBits, sizeof(unsigned char), 1);
256
// пишем неиспользуемые данные
257
SDL_RWwrite(TgaFile, &UselessChar, sizeof(unsigned char), 1);
258
// пишем данные диб массива
259
SDL_RWwrite(TgaFile, DIB, FontTextureWidth*FontTextureHeight*4, 1);
262
SDL_RWclose(TgaFile);
223
264
/////////////////////////////////
226
267
// создаем текстуру
227
268
vw_SetTextureProp(RI_MAGFILTER_LINEAR | RI_MINFILTER_LINEAR | RI_MIPFILTER_NONE, RI_CLAMP_TO_EDGE, true, TX_ALPHA_GREYSC, false);
228
eTexture* FontTexture = vw_CreateTextureFromMemory(TextureName, DIB, FontTextureWidth, FontTextureHeight, 4, false);
269
eTexture* FontTexture = vw_CreateTextureFromMemory(TextureName, DIB, FontTextureWidth, FontTextureHeight, 4, 0);
229
270
// освобождаем память
231
272
if (FontTexture == 0)
298
336
if (strlen(text) == 0) return;
300
338
float Xstart = X;
301
// делаем пробел в 2/3 от размера фонта
302
float SpaceWidth = InternalFontSize * 2 / 3;
339
// сразу определяем "базовую" ширину пробела, чтобы учитывать в расчетах
340
if (vw_FindFontCharByUTF32(0x020) == 0) vw_LoadFontChar(0x020);
341
float SpaceWidth = vw_FindFontCharByUTF32(0x020)->AdvanceX*FontScale;
342
// чтобы было более читаемо - делаем пробел не менее 2/3 ширины
343
if (SpaceWidth < (InternalFontSize * 0.65f)) SpaceWidth = InternalFontSize * 0.65f;
303
344
// коэф. изменения букв по ширине
304
345
float FontWidthScale = 1.0f;