Rev 6803 | Rev 6806 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6803 | Rev 6805 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | 39 | ||
40 | void ApplySmooth(); |
40 | void ApplySmooth(); |
41 | int WriteIntoWindow(); |
41 | int WriteIntoWindow(); |
42 | int WriteIntoWindowCenter(); |
42 | int WriteIntoWindowCenter(); |
43 | void WriteIntoBuffer(); |
43 | void WriteIntoBuffer(); |
44 | void show_buf(); |
44 | void ShowBuffer(); |
Line 45... | Line 45... | ||
45 | } label; |
45 | } label; |
46 | 46 | ||
47 | :bool LABEL::changeSIZE() |
47 | :bool LABEL::changeSIZE() |
48 | { |
48 | { |
49 | dword file_size; |
49 | dword file_size; |
50 | dword ofs; |
50 | dword ofs; |
51 | if(size.pt<9) size.pt = 8; |
51 | if(size.pt<9) size.pt = 9; |
52 | font = font_begin; |
52 | font = font_begin; |
53 | ofs = DSDWORD[calc(size.pt-8<<2+font_begin)]; |
53 | ofs = DSDWORD[calc(size.pt-8<<2+font_begin)]; |
54 | if(ofs==-1)return false; |
54 | if(ofs==-1)return false; |
55 | font += ofs + 156; |
55 | font += ofs + 156; |
56 | file_size = DSDWORD[calc(font)]; |
56 | file_size = DSDWORD[calc(font)]; |
57 | height = DSBYTE[calc(font+file_size) - 1]; |
57 | height = DSBYTE[calc(font+file_size) - 1]; |
58 | width = DSBYTE[calc(font+file_size) - 2]; |
58 | width = DSBYTE[calc(font+file_size) - 2]; |
59 | block = math.ceil(height*width/32); |
59 | block = math.ceil(height*width/32); |
60 | return true; |
60 | return true; |
61 | } |
61 | } |
62 | :dword LABEL::getsize(dword text1) |
62 | :dword LABEL::getsize(byte fontSizePoints, dword text1) |
63 | { |
63 | { |
- | 64 | size.height = size.width = 0; |
|
64 | size.height = size.width = 0; |
65 | size.offset_x = size.offset_y = -1; |
65 | size.offset_x = size.offset_y = -1; |
66 | size.pt = fontSizePoints; |
66 | if(size.pt)if(!changeSIZE())return 0; |
67 | if(size.pt)if(!changeSIZE())return 0; |
67 | WHILE(DSBYTE[text1]) |
68 | WHILE(DSBYTE[text1]) |
68 | { |
69 | { |
Line 75... | Line 76... | ||
75 | size.width += size.offset_x+1; |
76 | size.width += size.offset_x+1; |
76 | return size.width; |
77 | return size.width; |
77 | } |
78 | } |
78 | :byte LABEL::symbol_size(byte s) |
79 | :byte LABEL::symbol_size(byte s) |
79 | { |
80 | { |
- | 81 | //return symbol_size(s); |
|
80 | dword xi,yi; |
82 | dword xi,yi; |
81 | dword tmp,_; |
83 | dword tmp,_; |
82 | dword iii = 0; |
84 | dword iii = 0; |
83 | byte rw=0; |
85 | byte rw=0; |
84 | byte X; |
86 | byte X; |
Line 175... | Line 177... | ||
175 | debugln(font_path); |
177 | debugln(font_path); |
176 | label_io.run("/sys/@notify", "'Error: KFONT is not loaded.' -E"); |
178 | label_io.run("/sys/@notify", "'Error: KFONT is not loaded.' -E"); |
177 | return false; |
179 | return false; |
178 | } |
180 | } |
179 | font_begin = label_io.buffer_data; |
181 | font_begin = label_io.buffer_data; |
180 | size.pt = 9; |
- | |
181 | changeSIZE(); |
182 | changeSIZE(); |
182 | smooth = true; |
183 | smooth = true; |
183 | return true; |
184 | return true; |
184 | } |
185 | } |
Line 218... | Line 219... | ||
218 | DSDWORD[i+3+line_w] = DSDWORD[i+3+line_w] & 0xFF000000 | dark_background; |
219 | DSDWORD[i+3+line_w] = DSDWORD[i+3+line_w] & 0xFF000000 | dark_background; |
219 | } |
220 | } |
220 | } |
221 | } |
221 | } |
222 | } |
Line 222... | Line -... | ||
222 | - | ||
223 | :int LABEL::WriteIntoWindowCenter(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword txt) |
- | |
224 | { |
- | |
225 | size.pt = fontSizePoints; |
- | |
226 | getsize(txt); |
- | |
227 | return WriteIntoWindow(w-size.width/2+x,y, _background, _color, fontSizePoints, txt); |
- | |
228 | } |
- | |
229 | - | ||
230 | :int LABEL::WriteIntoWindow(int x,y; dword _background, _color; byte fontSizePoints; dword text1) |
- | |
231 | { |
- | |
232 | signed len=0; |
- | |
233 | if(!text1)return false; |
- | |
234 | if(size.pt)if(!changeSIZE())return false; |
- | |
235 | size.pt = fontSizePoints; |
- | |
236 | getsize(text1); |
- | |
237 | color = _color; |
- | |
238 | background = _background; |
- | |
239 | y -= size.offset_y; |
- | |
240 | EDX = size.width*size.height*3; |
- | |
241 | if(!raw_size) |
- | |
242 | { |
- | |
243 | raw_size = EDX; |
- | |
244 | raw = malloc(raw_size); |
- | |
245 | } |
- | |
246 | else if(raw_size |
- | |
247 | { |
- | |
248 | raw_size = EDX; |
- | |
249 | raw = realloc(raw,raw_size); |
- | |
250 | } |
- | |
251 | // Fill background color { |
- | |
252 | EBX = background; |
- | |
253 | EAX = raw_size+raw; |
- | |
254 | for (EDI=raw; EDI |
- | |
255 | // } |
- | |
256 | len = size.offset_x; |
- | |
257 | WHILE(DSBYTE[text1]) |
- | |
258 | { |
- | |
259 | len+=symbol(len,0,DSBYTE[text1], raw); |
- | |
260 | if(bold)len+=math.ceil(size.pt/17); |
- | |
261 | text1++; |
- | |
262 | } |
- | |
263 | IF (smooth) ApplySmooth(); |
- | |
264 | show_buf(x,y); |
- | |
265 | return len; |
- | |
266 | } |
- | |
267 | 223 | ||
268 | :void LABEL::WriteIntoBuffer(int x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1) |
224 | :void LABEL::WriteIntoBuffer(int x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1) |
269 | { |
225 | { |
270 | dword new_raw_size; |
226 | dword new_raw_size; |
271 | if(!text1)return; |
227 | if(!text1)return; |
Line 272... | Line 228... | ||
272 | if(size.pt)if(!changeSIZE())return; |
228 | if(size.pt)if(!changeSIZE())return; |
273 | 229 | ||
274 | if (size.pt != fontSizePoints) { |
- | |
275 | size.pt = fontSizePoints; |
230 | if (size.pt != fontSizePoints) { |
276 | getsize(text1); |
231 | getsize(fontSizePoints, text1); |
277 | y -= size.offset_y; |
232 | y -= size.offset_y; |
278 | } |
233 | } |
Line 300... | Line 255... | ||
300 | text1++; |
255 | text1++; |
301 | } |
256 | } |
302 | return; |
257 | return; |
303 | } |
258 | } |
Line -... | Line 259... | ||
- | 259 | ||
- | 260 | :int LABEL::WriteIntoWindow(int x,y; dword _background, _color; byte fontSizePoints; dword text1) |
|
- | 261 | { |
|
- | 262 | if(!text1)return 0; |
|
- | 263 | getsize(fontSizePoints, text1); |
|
- | 264 | raw_size = NULL; |
|
- | 265 | WriteIntoBuffer(0, -size.offset_y, size.width-size.offset_x, |
|
- | 266 | size.height-size.offset_y, _background, _color, fontSizePoints, text1); |
|
- | 267 | if (smooth) ApplySmooth(); |
|
- | 268 | ShowBuffer(x,y); |
|
- | 269 | return size.offset_x + size.width; |
|
- | 270 | } |
|
- | 271 | ||
- | 272 | :int LABEL::WriteIntoWindowCenter(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1) |
|
- | 273 | { |
|
- | 274 | getsize(fontSizePoints, text1); |
|
- | 275 | return WriteIntoWindow(w-size.width/2+x,y, _background, _color, fontSizePoints, text1); |
|
- | 276 | } |
|
304 | 277 | ||
305 | :void LABEL::show_buf(dword x, y){ |
278 | :void LABEL::ShowBuffer(dword x, y){ |
306 | _PutImage(x, y, size.width, size.height, raw); |
279 | _PutImage(x, y, size.width, size.height, raw); |