diff --git a/src/stratagus/stratagus.cpp b/src/stratagus/stratagus.cpp index 56c3f641f..ab39b572b 100644 --- a/src/stratagus/stratagus.cpp +++ b/src/stratagus/stratagus.cpp @@ -862,28 +862,38 @@ local void DebugDrawFonts(void) VideoFillRectangle(ColorWhite,0,0,40,VideoHeight-1); VideoDrawTextClip(8, 0+ 10,SmallFont,"FreeCraft"); -// VideoDrawTextClip(8, 0+ 20,SmallFont, -// "~00~11~22~33~44~55~66~77~88~99~aa~bb~cc~dd~ee~ff"); + VideoDrawTextClip(8, 0+ 20,SmallFont, + "~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7" + "~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C" + "~light-magenta~D~light-cyan~E~light-grey~F"); VideoDrawTextClip(8, 0+ 30,SmallFont,"abdefgABCDEFQ"); VideoDrawTextClip(8, 40+ 10,GameFont,"FreeCraft"); -// VideoDrawTextClip(8, 40+ 25,GameFont, -// "~00~11~22~33~44~55~66~77~88~99~aa~bb~cc~dd~ee~ff"); + VideoDrawTextClip(8, 40+ 25,GameFont, + "~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7" + "~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C" + "~light-magenta~D~light-cyan~E~light-grey~F"); VideoDrawTextClip(8, 40+ 40,GameFont,"abdefgABCDEFQ"); VideoDrawTextClip(8, 100+ 10,LargeFont,"FreeCraft"); -// VideoDrawTextClip(8, 100+ 25,LargeFont, -// "~00~11~22~33~44~55~66~77~88~99~aa~bb~cc~dd~ee~ff"); + VideoDrawTextClip(8, 100+ 25,LargeFont, + "~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7" + "~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C" + "~light-magenta~D~light-cyan~E~light-grey~F"); VideoDrawTextClip(8, 100+ 40,LargeFont,"abdefgABCDEFQ"); VideoDrawTextClip(8, 160+ 10,SmallTitleFont,"FreeCraft"); -// VideoDrawTextClip(8, 160+ 35,SmallTitleFont, -// "~00~11~22~33~44~55~66~77~88~99~aa~bb~cc~dd~ee~ff"); + VideoDrawTextClip(8, 160+ 35,SmallTitleFont, + "~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7" + "~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C" + "~light-magenta~D~light-cyan~E~light-grey~F"); VideoDrawTextClip(8, 160+ 60,SmallTitleFont,"abdefgABCDEFQ"); VideoDrawTextClip(8, 260+ 10,LargeTitleFont,"FreeCraft"); -// VideoDrawTextClip(8, 260+ 55,LargeTitleFont, -// "~00~11~22~33~44~55~66~77~88~99~aa~bb~cc~dd~ee~ff"); + VideoDrawTextClip(8, 260+ 55,LargeTitleFont, + "~black~0~red~1~green~2~yellow~3~blue~4~magenta~5~cyan~6~white~7" + "~grey~8~light-red~9~light-green~A~light-yellow~B~light-blue~C" + "~light-magenta~D~light-cyan~E~light-grey~F"); VideoDrawTextClip(8, 260+ 100,LargeTitleFont,"abdefgABCDEFQ"); PopClipping(); diff --git a/src/video/font.cpp b/src/video/font.cpp index 3d6385009..7c0b14d94 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -483,6 +483,8 @@ local int DoDrawText(int x,int y,unsigned font,const unsigned char* text, int widths; const ColorFont* fp; const VMemType* rev; + char* color; + const char* p; void (*DrawChar)(const Graphic*,int,int,int,int,int,int); #ifdef USE_OPENGL @@ -505,13 +507,6 @@ local int DoDrawText(int x,int y,unsigned font,const unsigned char* text, return widths; case '~': break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - fprintf(stderr,"Not supported: ~%c\n",*text); - ExitFatal(1); - break; case '!': rev=FontPixels; FontPixels=ReverseTextColor; @@ -528,7 +523,21 @@ local int DoDrawText(int x,int y,unsigned font,const unsigned char* text, continue; default: - DebugLevel0Fn("oops, format your ~\n"); + p=text; + while( *p && *p!='~' ) { + ++p; + } + if( !*p ) { + DebugLevel0Fn("oops, format your ~\n"); + return widths; + } + color=malloc(p-text+1); + memcpy(color,text,p-text); + color[p-text]='\0'; + text=p; + LastTextColor=FontPixels; + FontPixels=GetFontColorMapping(color); + free(color); continue; } }