00001
00002
00003
00004 #include <OFONT.H>
00005 #include <ALL.H>
00006 #include <IMGFUN.H>
00007 #include <OVGA.H>
00008 #include <OSTR.H>
00009 #include <OSYS.H>
00010 #include <ORES.H>
00011 #include <OINFO.H>
00012 #include <OGAME.H>
00013 #include <OMOUSE.H>
00014 #include <OTRANSL.H>
00015 #include <string.h>
00016 #include <Ostr.h>
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00029 struct FontHeader {
00030 unsigned short max_width;
00031 unsigned short max_height;
00032 unsigned short std_height;
00033 unsigned short first_char;
00034 unsigned short last_char;
00035 };
00036
00037
00038
00040 struct FontInfo {
00041 char offset_y;
00042 unsigned char width;
00043 unsigned char height;
00044 long bitmap_offset;
00045 };
00046
00047
00048
00049 #define HYPER_FIELD_COLOR V_BLUE
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 short Font::hyper_field_count;
00064 HyperField Font::hyper_field_array[MAX_HYPER_FIELD];
00065
00066 static int text_line_count;
00067
00068
00069
00070 Font::Font(char* fontName) {
00071 memset( this, 0, sizeof(Font) );
00072
00073 if( fontName )
00074 init(fontName);
00075 }
00076
00077
00078
00079
00080
00081 Font::~Font() {
00082 deinit();
00083 }
00084
00085
00086
00087
00101
00102 if( init_flag )
00103 deinit();
00104
00105 inter_char_space = interCharSpace;
00106
00107
00108
00109 File fontFile;
00110
00111 String str;
00112
00113 str = DIR_RES;
00114 str += "FNT_";
00115 str += fontName;
00116 str += ".RES";
00117
00118 fontFile.file_open(str);
00119
00120
00121
00122 FontHeader fontHeader;
00123
00124 fontFile.file_read( &fontHeader, sizeof(FontHeader) );
00125
00126 max_font_width = fontHeader.max_width;
00127 max_font_height = fontHeader.max_height;
00128 std_font_height = fontHeader.std_height;
00129
00130 font_height = std_font_height;
00131
00132 first_char = fontHeader.first_char;
00133 last_char = fontHeader.last_char;
00134
00135
00136
00137 int infoArraySize = sizeof(FontInfo) * (last_char-first_char+1);
00138
00139 font_info_array = (FontInfo*) mem_add( infoArraySize );
00140
00141 fontFile.file_read( font_info_array, infoArraySize );
00142
00143
00144
00145 if( italicShift ) {
00146 for( int i=0 ; i<last_char-first_char+1 ; i++ )
00147 font_info_array[i].width -= italicShift;
00148 }
00149
00150
00151
00152 int bitmapBufSize = fontFile.file_size() - sizeof(FontHeader) - infoArraySize;
00153
00154 font_bitmap_buf = mem_add( bitmapBufSize);
00155
00156 fontFile.file_read( font_bitmap_buf, bitmapBufSize );
00157
00158
00159
00160
00161
00162
00163
00164
00165 space_width = font_info_array['t'-first_char].width;
00166
00167
00168
00169 fontFile.file_close();
00170
00171 init_flag = 1;
00172 }
00173
00174
00175
00176
00177
00178 void Font::deinit() {
00179 if( font_info_array ) {
00180 mem_del( font_info_array );
00181 font_info_array = NULL;
00182 }
00183
00184 if( font_bitmap_buf ) {
00185 mem_del( font_bitmap_buf );
00186 font_bitmap_buf = NULL;
00187 }
00188
00189 init_flag = 0;
00190 }
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207 int Font::put(int x,int y,char* textPtr, char clearBack, int x2 ) {
00208 err_when( x<0 || y<0 );
00209
00210 if( !init_flag )
00211 return x;
00212
00213
00214
00215 short textChar;
00216
00217 textPtr = translate.process(textPtr);
00218
00219
00220
00221 int textPtrLen = strlen(textPtr);
00222
00223 if( x2 < 0 )
00224 x2 = x+max_font_width*textPtrLen;
00225
00226 x2 = min( x2, VGA_WIDTH-1 );
00227
00228 if( !Vga::use_back_buf )
00229 mouse.hide_area( x, y, x2, y+font_height );
00230
00231 int y2 = y+font_height-1;
00232
00233
00234
00235 FontInfo* fontInfo;
00236
00237 for( int lenCount=1 ; *textPtr && lenCount<=textPtrLen ; textPtr++, lenCount++ ) {
00238 textChar = *((unsigned char*)textPtr);
00239
00240
00241
00242
00243
00244
00245
00246 if( textChar == ' ' ) {
00247 if( x+space_width > x2 )
00248 break;
00249
00250 if( clearBack && !Vga::use_back_buf )
00251 vga.blt_buf( x, y, x+space_width-1, y+font_height-1 );
00252
00253 x += space_width;
00254 }
00255
00256
00257
00258 else if( textChar >= first_char && textChar <= last_char ) {
00259 fontInfo = font_info_array+textChar-first_char;
00260
00261 if( x+fontInfo->width > x2 )
00262 break;
00263
00264 if( fontInfo->width > 0 ) {
00265 if( clearBack && !Vga::use_back_buf ) {
00266 if( fontInfo->offset_y > 0 )
00267 vga_front.blt_buf_fast( &vga_back, x, y, x+fontInfo->width-1, y+fontInfo->offset_y-1 );
00268
00269 vga_front.join_trans( &vga_back, x, y+fontInfo->offset_y, font_bitmap_buf + fontInfo->bitmap_offset );
00270
00271 int charHeight = *(((short*)(font_bitmap_buf+fontInfo->bitmap_offset))+1);
00272
00273 if( fontInfo->offset_y+charHeight < max_font_height ) {
00274 int ty1 = y+fontInfo->offset_y+charHeight-1;
00275 int ty2 = ty1 + max_font_height - (fontInfo->offset_y + charHeight);
00276 vga_front.blt_buf_fast( &vga_back, x, ty1, x+fontInfo->width-1, ty2 );
00277 }
00278 }
00279 else {
00280 Vga::active_buf->put_bitmap_trans_fast(x, y+fontInfo->offset_y, font_bitmap_buf + fontInfo->bitmap_offset);
00281 }
00282
00283 x += fontInfo->width;
00284 }
00285 }
00286 else {
00287
00288
00289 if( textChar == '\t' )
00290 x += space_width*8;
00291 else
00292 x += space_width;
00293 }
00294
00295
00296
00297 if( clearBack && !Vga::use_back_buf )
00298 vga.blt_buf( x, y, x+inter_char_space-1, y+max_font_height-1, 0 );
00299
00300 x+=inter_char_space;
00301 }
00302
00303
00304
00305 if( clearBack && !Vga::use_back_buf )
00306 vga.blt_buf( x, y, x2, y+max_font_height-1, 0 );
00307
00308 if( !Vga::use_back_buf )
00309 mouse.show_area();
00310
00311 sys.yield();
00312 return x-1;
00313 }
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339 void Font::put_char(int x, int y, unsigned short textChar) {
00340 if( textChar >= first_char && textChar <= last_char ) {
00341 FontInfo* fontInfo = font_info_array+textChar-first_char;
00342
00343 Vga::active_buf->put_bitmap_trans( x, y + fontInfo->offset_y, font_bitmap_buf + fontInfo->bitmap_offset );
00344 }
00345 }
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 void Font::right_put(int x, int y, char* textPtr) {
00357 int textWidth = text_width(textPtr);
00358
00359 put( x-textWidth, y, textPtr );
00360 }
00361
00362
00363
00364
00378
00379 int charWidth, x=0, lenCount, maxLen=0, wordWidth=0;
00380 short textChar;
00381
00382 if( !init_flag )
00383 return x;
00384
00385 textPtr = translate.process(textPtr);
00386
00387 if( textPtrLen < 0 )
00388 textPtrLen = strlen(textPtr);
00389
00390 text_line_count=1;
00391
00392
00393
00394 for( lenCount=1 ; *textPtr && lenCount<=textPtrLen ; textPtr++, lenCount++, x+=inter_char_space ) {
00395 textChar = *((unsigned char*)textPtr);
00396
00397
00398
00399
00400
00401
00402
00403 if( maxDispWidth && x > maxDispWidth ) {
00404 maxLen = maxDispWidth;
00405 x = wordWidth;
00406 text_line_count++;
00407 }
00408
00409
00410
00411 if( textChar == '\n' ) {
00412 if( x>maxLen )
00413 maxLen=x;
00414
00415 x=0;
00416 wordWidth=0;
00417 text_line_count++;
00418 continue;
00419 }
00420
00421
00422
00423 else if( textChar == ' ' ) {
00424 x += space_width;
00425 wordWidth = 0;
00426 }
00427
00428 else if( textChar >= first_char && textChar <= last_char ) {
00429 charWidth = font_info_array[textChar-first_char].width;
00430
00431 x += charWidth;
00432 wordWidth += charWidth;
00433 }
00434 else {
00435 x += space_width;
00436 wordWidth += space_width;
00437 }
00438
00439 if( maxDispWidth && wordWidth > maxDispWidth ) {
00440 x -= wordWidth - maxDispWidth;
00441 wordWidth = maxDispWidth;
00442 }
00443 }
00444
00445
00446
00447 if( maxDispWidth && x > maxDispWidth )
00448 text_line_count++;
00449
00450 if( textPtr[-1] == '\n' )
00451 text_line_count--;
00452
00453 return max(maxLen,x);
00454 }
00455
00456
00457
00458
00468
00469 return font_height * text_line_count +
00470 lineSpace * (text_line_count-1);
00471 }
00472
00473
00474
00475
00517
00518 void Font::put_paragraph(int x1, int y1, int x2, int y2, char *textPtr,
00519 int lineSpace, int startLine, char dispFlag) {
00520 if( !init_flag || y1+font_height-1 > y2 )
00521 return;
00522
00523 textPtr = translate.process(textPtr);
00524
00525
00526
00527 int x,y,wordX;
00528 int newWord;
00529 short textChar;
00530 char *wordPtr;
00531
00532 char flag_under_line=0;
00533 char flag_large_casa=0;
00534 char flag_hyper_field=0;
00535
00536 int under_line_x1;
00537
00538 HyperField* hyper_field_ptr = hyper_field_array;
00539 FontInfo* fontInfo;
00540
00541
00542
00543 x = x1;
00544 y = y1;
00545 wordX = x1;
00546 wordPtr = textPtr;
00547 newWord = 0;
00548
00549 line_count=0;
00550
00551 hyper_field_count = 0;
00552
00553
00554
00555 if( dispFlag ) {
00556 err_when( x1>x2 || y1>y2 || x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT );
00557
00558 if( !Vga::use_back_buf )
00559 mouse.hide_area( x1,y1,x2,y2 );
00560 }
00561
00562
00563
00564 while(1) {
00565
00566 if ( newWord ) {
00567 if( x-1 > x2 ) {
00568 if( line_count >= startLine-1 ) {
00569 y += font_height + lineSpace;
00570 if ( y + font_height - 1 > y2 )
00571 break;
00572 }
00573
00574 x = x1;
00575 line_count++;
00576 }
00577 else {
00578 x = wordX;
00579 }
00580
00581
00582
00583
00584 for( ; wordPtr < textPtr && *wordPtr ; wordPtr++, x+=inter_char_space ) {
00585 textChar = *((unsigned char*)wordPtr);
00586
00587
00588
00589
00590
00591
00592
00593 if( textChar == '_' ) {
00594 if( flag_under_line ) {
00595
00596 if( dispFlag && line_count >= startLine-1 )
00597 if( flag_large_casa ) {
00598
00599 Vga::active_buf->bar_fast(under_line_x1, y+font_casa.
00600 font_height, x, y+font_casa.font_height, HYPER_FIELD_COLOR );
00601 }
00602 else
00603 Vga::active_buf->bar_fast(under_line_x1, y+font_height, x, y+font_height, HYPER_FIELD_COLOR );
00604 }
00605 else
00606 under_line_x1 = x;
00607
00608 flag_under_line = !flag_under_line;
00609 continue;
00610 }
00611
00612 if( textChar == '^' ) {
00613 flag_large_casa = !flag_large_casa;
00614 continue;
00615 }
00616
00617
00618
00619 else if( textChar == '~' ) {
00620 if( !flag_hyper_field ) {
00621 hyper_field_ptr->x1 = x;
00622 hyper_field_ptr->y1 = y;
00623
00624 hyper_field_ptr->text_ptr = (wordPtr+1);
00625 }
00626 else {
00627 hyper_field_ptr->x2 = x;
00628 hyper_field_ptr->y2 = y+font_height;
00629 hyper_field_ptr->text_len = wordPtr - hyper_field_ptr->text_ptr;
00630
00631 hyper_field_count++;
00632 hyper_field_ptr++;
00633 err_when( hyper_field_count >= MAX_HYPER_FIELD );
00634 }
00635
00636 flag_hyper_field = !flag_hyper_field;
00637 continue;
00638 }
00639
00640
00641
00642 else if( textChar == ' ' ) {
00643 if(*(wordPtr-1)!=' ')
00644 if(*(wordPtr+1)==' ')
00645 break;
00646 if( x+space_width > x2 )
00647 break;
00648
00649 x += space_width;
00650 }
00651
00652
00653
00654 else if( textChar >= first_char && textChar <= last_char ) {
00655 FontInfo* oldfontInfo = font_info_array+textChar-first_char;
00656
00657
00658
00659
00660
00661
00662 if( x2 >= 0 && x+oldfontInfo->width-1 > x2 )
00663 break;
00664
00665
00666
00667 if( oldfontInfo->width > 0 ) {
00668
00669
00670
00671 if( flag_hyper_field ) {
00672
00673 fontInfo = font_blue_san.font_info_array+textChar-first_char;
00674 if( dispFlag && line_count >= startLine-1 )
00675 font_blue_san.put_char(x,y,textChar);
00676 }
00677 else if( flag_large_casa ) {
00678
00679 fontInfo = font_casa.font_info_array+textChar-first_char;
00680 if( dispFlag && line_count >= startLine-1 )
00681 font_casa.put_char(x,y,textChar);
00682 }
00683 else {
00684 fontInfo = oldfontInfo;
00685 if( dispFlag && line_count >= startLine-1 )
00686 Vga::active_buf->put_bitmap_trans_fast(x, y+fontInfo->offset_y,
00687 font_bitmap_buf + fontInfo->bitmap_offset);
00688 }
00689
00690
00691 x += fontInfo->width;
00692
00693
00694 }
00695 }
00696 }
00697
00698
00699
00700 if( *textPtr == '\n' ) {
00701 if( line_count >= startLine-1 ) {
00702 y += font_height + lineSpace;
00703 if ( y + font_height - 1 > y2 )
00704 break;
00705 }
00706
00707 x = x1;
00708 textPtr++;
00709 line_count++;
00710 }
00711
00712 if( *textPtr == NULL )
00713 break;
00714
00715 wordPtr = textPtr;
00716 wordX = x;
00717 newWord = 0;
00718 }
00719
00720
00721
00722
00723 if( *textPtr == ' ' || *textPtr == '\n' || *textPtr == NULL )
00724 newWord = 1;
00725 else {
00726 textChar = *((unsigned char*)textPtr);
00727
00728
00729
00730
00731
00732 if( textChar >= first_char && textChar <= last_char ) {
00733 fontInfo = font_info_array+textChar-first_char;
00734
00735 if( textChar == ' ' )
00736 x+=space_width;
00737
00738 else if( fontInfo->width > 0 )
00739 x+=fontInfo->width;
00740
00741 else
00742 x+=space_width;
00743 }
00744 else {
00745 x+=space_width;
00746 }
00747
00748 x+=inter_char_space;
00749 }
00750
00751 if( *textPtr && *textPtr != '\n' )
00752 textPtr++;
00753 }
00754
00755
00756
00757 if( dispFlag ) {
00758 if( !Vga::use_back_buf )
00759 mouse.show_area();
00760 }
00761
00762
00763
00764
00765 next_text_ptr = textPtr;
00766 next_text_y = y + font_height + lineSpace;
00767 line_count++;
00768 }
00769
00770
00771
00772
00777
00778 String str=textPtr;
00779 int width_measure=0;
00780 int last_splitter=start_char;
00781 int i=start_char;
00782 while(width_measure<area_width&&str[i]!=NULL) {
00783 if(str[i]=='\n'||str[i]==' '||str[i]==NULL)
00784 last_splitter=i;
00785
00786 if( str[i] >= first_char && str[i] <= last_char ) {
00787 int charWidth = font_info_array[str[i]-first_char].width;
00788 if(str[i]==' ')charWidth=space_width;
00789 width_measure += charWidth;
00790 }
00791 i++;
00792 }
00793
00794 if(str[i]==NULL)
00795 last_splitter=i;
00796
00797 return last_splitter;
00798 }
00799
00800
00801
00802
00807
00808 int ptr1,ptr2;
00809 String str=textPtr;
00810
00811 ptr1=0;
00812
00813 for(int i=0;i<line;i++) {
00814 ptr2=find_splitter(area_width, ptr1, str.str_buf);
00815 if(i==line-1)
00816 return str.substr(ptr1,ptr2-ptr1);
00817 ptr1=ptr2+1;
00818 }
00819 return NULL;
00820 }
00821
00822
00823
00824
00828
00829 int ptr1,ptr2,line;
00830 String str=textPtr;
00831
00832 ptr1=0;
00833 ptr2=-1;
00834 line=0;
00835 while(1) {
00836 ptr2=find_splitter(area_width, ptr1, str.str_buf);
00837 if(ptr1==ptr2)break;
00838 ptr1=ptr2+1;
00839 line++;
00840 }
00841 return line;
00842 }
00843
00844
00845
00846
00859
00860 int lineSpace , int& dispLines, int& totalLines) {
00861 dispLines =0;
00862 totalLines=0;
00863
00864 while( *textPtr ) {
00865
00866 put_paragraph(x1, y1, x2, y2, textPtr, lineSpace, 1, 0);
00867
00868 if( !dispLines )
00869 dispLines = line_count;
00870
00871 totalLines += line_count;
00872 textPtr = next_text_ptr;
00873 }
00874 }
00875
00876
00877
00878
00887
00888 int marginSpace = font_height/5;
00889
00890 int x2 = x1+text_width(desStr)+marginSpace*2-1;
00891
00892 vga.active_buf->d3_panel_up( x1, y1, x2, y1+font_height+marginSpace*2-1 );
00893
00894 put( x1+marginSpace, y1+marginSpace, desStr);
00895
00896 return x2;
00897 }
00898
00899
00900
00901
00910
00911 int tx = x1 + ((x2-x1+1) - text_width(desStr))/2;
00912 int ty = y1 + ((y2-y1+1) - font_height)/2+1;
00913
00914 vga.active_buf->d3_panel_up( x1, y1, x2, y2);
00915
00916 if( tx<x1+2 )
00917 tx=x1+2;
00918
00919 put( tx, ty, desStr, 0, x2-2 );
00920 }
00921
00922
00923
00924
00936
00937 int tx = x1 + ((x2-x1+1) - text_width(desStr))/2;
00938 int ty = y1 + ((y2-y1+1) - font_height)/2;
00939
00940 if( tx<0 )
00941 tx=0;
00942
00943 if( clearBack && !Vga::use_back_buf && tx>x1 )
00944 vga.blt_buf( x1, y1, tx-1, y2 );
00945
00946 return put( tx, ty, desStr, clearBack, x2 );
00947 }
00948
00949
00950
00951
00967
00968 vga.active_buf->d3_panel_up( x1, y1, x2, y1+font_height+3 );
00969
00970 put( x1+4, y1+2, desStr);
00971 put( x2+4, y1+2, m.format(value,format) );
00972 }
00973
00974
00975
00976
00991
00992 if( x2<0 )
00993 x2 = x1+80;
00994
00995 put( x1+4, y1+2, m.format(value,format), 1, x2 );
00996 }
00997
00998
00999
01000
01020
01021 int format, int xEnd, int refreshFlag, char* helpCode) {
01022 int x2;
01023
01024 if( refreshFlag == INFO_REPAINT ) {
01025 vga.active_buf->d3_panel_up( xDes, y1, xValue, y1+font_height+3 );
01026
01027 put( xDes+4 , y1+2, desStr);
01028 x2 = put( xValue+4, y1+2, m.format(value,format) );
01029 }
01030 else {
01031 vga.active_buf->d3_panel_up( xDes, y1, xValue, y1+font_height+3 );
01032 put( xDes+4 , y1+2, desStr);
01033 x2 = put( xValue+4, y1+2, m.format(value,format), 1, xEnd );
01034 }
01035
01036
01037
01038 }
01039
01040
01041
01042
01058
01059 vga.active_buf->d3_panel_up( x1, y1, x2, y1+font_height+3 );
01060
01061 put( x1+4, y1+2, desStr);
01062 put( x2+4, y1+2, m.format(value,format) );
01063 }
01064
01065
01066
01067
01082
01083 if( x2<0 )
01084 x2 = x1+80;
01085
01086 put( x1+4, y1+2, m.format(value,format), 1, x2 );
01087 }
01088
01089
01090
01091
01111
01112 int format, int xEnd, int refreshFlag, char* helpCode ) {
01113 int x2;
01114
01115 if( refreshFlag == INFO_REPAINT ) {
01116 vga.active_buf->d3_panel_up( xDes, y1, xValue, y1+font_height+3 );
01117
01118 put( xDes+4 , y1+2, desStr);
01119 x2 = put( xValue+4, y1+2, m.format(value,format) );
01120 }
01121 else {
01122 vga.active_buf->d3_panel_up( xDes, y1, xValue, y1+font_height+3 );
01123
01124 put( xDes+4 , y1+2, desStr);
01125 x2 = put( xValue+4, y1+2, m.format(value,format), 1, xEnd );
01126 }
01127
01128
01129
01130 }
01131
01132
01133
01134
01145
01146 vga.active_buf->d3_panel_up( x1, y1, x2, y1+font_height+3 );
01147
01148 put( x1+4, y1+2, desStr);
01149 put( x2+4, y1+2, value);
01150 }
01151
01152
01153
01154
01163
01164 if( x2<0 )
01165 x2 = x1+80;
01166
01167 put( x1+4, y1+2, value, 1, x2 );
01168 }
01169
01170
01171
01172
01188
01189 int xEnd, int refreshFlag, char* helpCode ) {
01190 int x2;
01191
01192 if( refreshFlag == INFO_REPAINT ) {
01193 vga.active_buf->d3_panel_up( xDes, y1, xValue, y1+font_height+3 );
01194
01195 put( xDes+4 , y1+2, desStr);
01196 x2 = put( xValue+4, y1+2, value );
01197 }
01198 else {
01199 vga.active_buf->d3_panel_up( xDes, y1, xValue, y1+font_height+3 );
01200
01201 put( xDes+4 , y1+2, desStr);
01202 x2 = put( xValue+4, y1+2, value, 1, xEnd );
01203 }
01204
01205
01206
01207 }
01208
01209
01210
01211
01227
01228 if( x2<0 )
01229 x2 = x1+80;
01230
01231 int lastX = put( x1, y1, m.format(value,format), 1, x2 );
01232
01233 return lastX;
01234 }
01235
01236
01237
01238
01254
01255 if( x2<0 )
01256 x2 = x1+80;
01257
01258 int lastX = put( x1, y1, m.format(value,format), 1, x2 );
01259
01260 return lastX;
01261 }
01262
01263
01264
01265
01275
01276 if( x2<0 )
01277 x2 = x1+80;
01278
01279 int lastX = put( x1, y1, textPtr, 1, x2 );
01280
01281 return lastX;
01282 }
01283
01284
01285
01286
01287 void Font::put_char_to_buffer(char* dest, int destPitch, int x, int y, unsigned short textChar) {
01288 if( textChar >= first_char && textChar <= last_char ) {
01289 FontInfo* fontInfo = font_info_array+textChar-first_char;
01290 char *fontBitmap = font_bitmap_buf + fontInfo->bitmap_offset;
01291
01292 err_here();
01293
01294 }
01295 }
01296
01297
01298
01299
01300 void Font::put_to_buffer(char* dest, int destPitch, int x1, int y1, char *text) {
01301 int x2 = destPitch;
01302 while( *text != '\0' && x1 < x2) {
01303 int charSize = sizeof(unsigned char);
01304 unsigned short textChar = *(unsigned char *)text;
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319 int charWidth = textChar == ' ' ? space_width :
01320 (font_info_array+textChar-first_char)->width;
01321
01322 if( x1 + charWidth <= x2 )
01323 put_char_to_buffer( dest, destPitch, x1, y1, textChar);
01324
01325 x1 += charWidth;
01326 text += charSize;
01327 }
01328 }
01329
01330
01331
01332
01333 void Font::center_put_to_buffer(char* dest, int destPitch, int x1, int y1, int x2, int y2, char *desStr) {
01334 int tx = x1 + ((x2-x1) - text_width(desStr))/2;
01335 int ty = y1 + ((y2-y1) - font_height)/2;
01336
01337 if( tx<0 )
01338 tx=0;
01339
01340 put_to_buffer( dest, destPitch, tx, ty, desStr);
01341 }
01342
01343
01344
01345
01346 void Font::put_char_to_bufferW(short* dest, int destPitch, int x, int y, unsigned short textChar) {
01347 if( textChar >= first_char && textChar <= last_char ) {
01348 FontInfo* fontInfo = font_info_array+textChar-first_char;
01349 char *fontBitmap = font_bitmap_buf + fontInfo->bitmap_offset;
01350
01351 IMGbltTransRemap( dest, destPitch, x, y + fontInfo->offset_y, fontBitmap, vga.default_remap_table );
01352 }
01353 }
01354
01355
01356
01357
01358 void Font::put_to_bufferW(short* dest, int destPitch, int x1, int y1, char *text) {
01359 int x2 = destPitch;
01360 while( *text != '\0' && x1 < x2) {
01361 int charSize = sizeof(unsigned char);
01362 unsigned short textChar = *(unsigned char *)text;
01363
01364
01365
01366 int charWidth = textChar == ' ' ? space_width :
01367 (font_info_array+textChar-first_char)->width;
01368
01369 if( x1 + charWidth <= x2 )
01370 put_char_to_bufferW( dest, destPitch, x1, y1, textChar);
01371
01372 x1 += charWidth;
01373 text += charSize;
01374 }
01375 }
01376
01377
01378
01379
01380 void Font::center_put_to_bufferW(short* dest, int destPitch, int x1, int y1, int x2, int y2, char *desStr) {
01381 int tx = x1 + ((x2-x1) - text_width(desStr))/2;
01382 int ty = y1 + ((y2-y1) - font_height)/2;
01383
01384 if( tx<0 )
01385 tx=0;
01386
01387 put_to_bufferW( dest, destPitch, tx, ty, desStr);
01388 }
01389
01390