update font.h, rename to kfont.h, fix Eolite font bug in prior rev

git-svn-id: svn://kolibrios.org@6805 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2016-12-21 15:40:39 +00:00
parent bc40aab5af
commit aa8338809f
6 changed files with 98 additions and 125 deletions

View File

@ -1,6 +1,6 @@
#define MEMSIZE 4096*60
#include "../lib/font.h"
#include "../lib/kfont.h"
#include "../lib/io.h"
#include "../lib/gui.h"
#include "../lib/list_box.h"

View File

@ -14,7 +14,7 @@
#include "..\lib\gui.h"
#include "..\lib\list_box.h"
#include "..\lib\random.h"
#include "..\lib\font.h"
#include "..\lib\kfont.h"
#include "..\lib\collection.h"
#include "..\lib\obj\libini.h"
#include "..\lib\obj\box_lib.h"
@ -724,9 +724,9 @@ void Line_ReDraw(dword bgcol, filenum){
else
{
strcpy(#label_file_name, file_name_off);
if (label.getsize(#label_file_name) + 141 + 26 > files.w)
if (label.getsize(label.size.pt, #label_file_name) + 141 + 26 > files.w)
{
while (label.getsize(#label_file_name) + 141 + 26 > files.w) {
while (label.getsize(label.size.pt, #label_file_name) + 141 + 26 > files.w) {
ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
}
strcpy(#label_file_name+strlen(#label_file_name)-2, "...");

View File

@ -1,6 +1,6 @@
#define MEMSIZE 0x2EE80
#include "../lib/font.h"
#include "../lib/kfont.h"
#include "../lib/gui.h"
#define PANELH 30
@ -64,7 +64,7 @@ void DrawPreviewPhrase()
label.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line);
}
if (label.smooth) label.ApplySmooth();
label.show_buf(0, PANELH);
label.ShowBuffer(0, PANELH);
}
void DrawPreviewChars()
@ -84,5 +84,5 @@ void DrawPreviewChars()
}
}
if (label.smooth) label.ApplySmooth();
label.show_buf(0, PANELH);
label.ShowBuffer(0, PANELH);
}

View File

@ -41,14 +41,14 @@
int WriteIntoWindow();
int WriteIntoWindowCenter();
void WriteIntoBuffer();
void show_buf();
void ShowBuffer();
} label;
:bool LABEL::changeSIZE()
{
dword file_size;
dword ofs;
if(size.pt<9) size.pt = 8;
if(size.pt<9) size.pt = 9;
font = font_begin;
ofs = DSDWORD[calc(size.pt-8<<2+font_begin)];
if(ofs==-1)return false;
@ -59,10 +59,11 @@
block = math.ceil(height*width/32);
return true;
}
:dword LABEL::getsize(dword text1)
:dword LABEL::getsize(byte fontSizePoints, dword text1)
{
size.height = size.width = 0;
size.offset_x = size.offset_y = -1;
size.pt = fontSizePoints;
if(size.pt)if(!changeSIZE())return 0;
WHILE(DSBYTE[text1])
{
@ -77,6 +78,7 @@
}
:byte LABEL::symbol_size(byte s)
{
//return symbol_size(s);
dword xi,yi;
dword tmp,_;
dword iii = 0;
@ -177,7 +179,6 @@ inline fastcall Cp866ToAnsi(AL) {
return false;
}
font_begin = label_io.buffer_data;
size.pt = 9;
changeSIZE();
smooth = true;
return true;
@ -220,51 +221,6 @@ inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; }
}
}
:int LABEL::WriteIntoWindowCenter(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword txt)
{
size.pt = fontSizePoints;
getsize(txt);
return WriteIntoWindow(w-size.width/2+x,y, _background, _color, fontSizePoints, txt);
}
:int LABEL::WriteIntoWindow(int x,y; dword _background, _color; byte fontSizePoints; dword text1)
{
signed len=0;
if(!text1)return false;
if(size.pt)if(!changeSIZE())return false;
size.pt = fontSizePoints;
getsize(text1);
color = _color;
background = _background;
y -= size.offset_y;
EDX = size.width*size.height*3;
if(!raw_size)
{
raw_size = EDX;
raw = malloc(raw_size);
}
else if(raw_size<EDX)
{
raw_size = EDX;
raw = realloc(raw,raw_size);
}
// Fill background color {
EBX = background;
EAX = raw_size+raw;
for (EDI=raw; EDI<EAX; EDI+=3) ESDWORD[EDI] = EBX;
// }
len = size.offset_x;
WHILE(DSBYTE[text1])
{
len+=symbol(len,0,DSBYTE[text1], raw);
if(bold)len+=math.ceil(size.pt/17);
text1++;
}
IF (smooth) ApplySmooth();
show_buf(x,y);
return len;
}
:void LABEL::WriteIntoBuffer(int x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1)
{
dword new_raw_size;
@ -272,8 +228,7 @@ inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; }
if(size.pt)if(!changeSIZE())return;
if (size.pt != fontSizePoints) {
size.pt = fontSizePoints;
getsize(text1);
getsize(fontSizePoints, text1);
y -= size.offset_y;
}
color = _color;
@ -302,7 +257,25 @@ inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; }
return;
}
:void LABEL::show_buf(dword x, y){
:int LABEL::WriteIntoWindow(int x,y; dword _background, _color; byte fontSizePoints; dword text1)
{
if(!text1)return 0;
getsize(fontSizePoints, text1);
raw_size = NULL;
WriteIntoBuffer(0, -size.offset_y, size.width-size.offset_x,
size.height-size.offset_y, _background, _color, fontSizePoints, text1);
if (smooth) ApplySmooth();
ShowBuffer(x,y);
return size.offset_x + size.width;
}
:int LABEL::WriteIntoWindowCenter(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1)
{
getsize(fontSizePoints, text1);
return WriteIntoWindow(w-size.width/2+x,y, _background, _color, fontSizePoints, text1);
}
:void LABEL::ShowBuffer(dword x, y){
_PutImage(x, y, size.width, size.height, raw);
}

View File

@ -11,7 +11,7 @@ SOFTWARE CENTER v2.8
#include "..\lib\obj\libio_lib.h"
#include "..\lib\obj\libimg_lib.h"
#include "..\lib\obj\libini.h"
#include "..\lib\font.h"
#include "..\lib\kfont.h"
#include "..\lib\list_box.h"
#include "..\lib\collection.h"
#include "..\lib\patterns\libimg_load_skin.h"

View File

@ -1,6 +1,6 @@
#define MEMSIZE 4096*25
#include "../lib/font.h"
#include "../lib/kfont.h"
#include "../lib/io.h"
#include "../lib/gui.h"
#include "../lib/list_box.h"