2015-03-25 14:46:22 +03:00
|
|
|
|
#ifndef AUTOBUILD
|
|
|
|
|
#include "lang.h--"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define MEMSIZE 397113
|
|
|
|
|
#include "..\lib\strings.h"
|
|
|
|
|
#include "..\lib\mem.h"
|
|
|
|
|
#include "..\lib\file_system.h"
|
|
|
|
|
#include "..\lib\gui.h"
|
|
|
|
|
#include "..\lib\obj\truetype.h"
|
|
|
|
|
#include "..\lib\obj\proc_lib.h"
|
|
|
|
|
|
|
|
|
|
#include "simple_open_dialog.h"
|
|
|
|
|
char default_dir[] = "/rd/1";
|
|
|
|
|
od_filter filter2 = {"TTF",0};
|
|
|
|
|
|
|
|
|
|
dword font_data;
|
|
|
|
|
stbtt_fontinfo font_info;
|
|
|
|
|
dword font_mem;
|
|
|
|
|
|
|
|
|
|
proc_info Form;
|
|
|
|
|
char test_text[] = "The quick brown fox jumps over the lazy dog";
|
|
|
|
|
char win_title[4096] = "TTF Viewer v0.1 - ";
|
|
|
|
|
|
|
|
|
|
#ifdef LANG_RUS
|
|
|
|
|
?define T_INTRO "<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ணࠬ<E0AEA3><E0A0AC> <20><><EFBFBD> <20><><EFBFBD>ᬮ<EFBFBD><E1ACAE><EFBFBD> <20><><EFBFBD><EFBFBD>⮢ <20><>ଠ<EFBFBD><E0ACA0> TTF"
|
|
|
|
|
?define T_INTRO_BUTTON_TEXT "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
#else
|
|
|
|
|
?define T_INTRO "This is simple program to view TTF fonts."
|
|
|
|
|
?define T_INTRO_BUTTON_TEXT "Open font"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
int id, key;
|
|
|
|
|
|
2015-07-29 23:43:05 +03:00
|
|
|
|
load_dll(libtruetype, #truetype, 1);
|
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
2015-03-25 14:46:22 +03:00
|
|
|
|
OpenDialog_init stdcall (#o_dialog);
|
|
|
|
|
|
|
|
|
|
if (param[0]) OpenFont(#param);
|
|
|
|
|
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
switch(WaitEvent())
|
|
|
|
|
{
|
|
|
|
|
case evButton:
|
|
|
|
|
id=GetButtonID();
|
|
|
|
|
if (id==1) ExitProcess();
|
|
|
|
|
if (id==10)
|
|
|
|
|
{
|
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
|
|
|
|
OpenFont(#openfile_path);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evKey:
|
|
|
|
|
key = GetKey();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evReDraw:
|
|
|
|
|
draw_window();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void draw_window()
|
|
|
|
|
{
|
2015-08-04 17:36:07 +03:00
|
|
|
|
system.color.get();
|
2015-03-25 14:46:22 +03:00
|
|
|
|
DefineAndDrawWindow(30, 100, 800, 250+GetSkinHeight(), 0x34, 0xFFFfff, #win_title);
|
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
|
|
|
|
DrawFonts();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
word DrawFonts()
|
|
|
|
|
{
|
|
|
|
|
if (!font_data)
|
|
|
|
|
{
|
|
|
|
|
WriteTextCenter(0,85,Form.cwidth,0x555555, T_INTRO);
|
2015-08-04 17:36:07 +03:00
|
|
|
|
DrawCaptButton(Form.cwidth - 140 / 2, Form.cheight - 30 / 2, 140, 30, 10, system.color.work_button, system.color.work_button_text, T_INTRO_BUTTON_TEXT);
|
2015-03-25 14:46:22 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
text_out stdcall (#test_text, #font_info, 10, 0x000000, 0xFFFfff, 3, 4);
|
|
|
|
|
text_out stdcall (#test_text, #font_info, 12, 0x000000, 0xFFFfff, 3, 18);
|
|
|
|
|
text_out stdcall (#test_text, #font_info, 24, 0x000000, 0xFFFfff, 3, 35);
|
|
|
|
|
text_out stdcall (#test_text, #font_info, 36, 0x000000, 0xFFFfff, 3, 60);
|
|
|
|
|
text_out stdcall (#test_text, #font_info, 48, 0x000000, 0xFFFfff, 3, 110);
|
|
|
|
|
text_out stdcall (#test_text, #font_info, 58, 0x000000, 0xFFFfff, 3, 170);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OpenFont(dword font_path)
|
|
|
|
|
{
|
|
|
|
|
BDVK FontFile_atr;
|
|
|
|
|
GetFileInfo(font_path, #FontFile_atr);
|
|
|
|
|
font_data = malloc(FontFile_atr.sizelo);
|
|
|
|
|
ReadFile(0, FontFile_atr.sizelo, #font_data, font_path);
|
|
|
|
|
init_font stdcall (#font_info, #font_data);
|
|
|
|
|
if (EAX==0)
|
|
|
|
|
{
|
|
|
|
|
font_data = 0;
|
|
|
|
|
notify("'Can\096t open font: init_font failed' - E");
|
|
|
|
|
}
|
|
|
|
|
strcpy(#win_title + 18, font_path);
|
|
|
|
|
draw_window();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stop:
|