hedgewars/uStore.pas
changeset 2681 dcbb5e98afc7
parent 2679 b61d25fa6c53
child 2684 04c086d8d9d4
equal deleted inserted replaced
2680:c925dec40d32 2681:dcbb5e98afc7
   754 FreeTexture(HHTexture)
   754 FreeTexture(HHTexture)
   755 end;
   755 end;
   756 
   756 
   757 
   757 
   758 function CheckCJKFont(s: string; font: THWFont): THWFont;
   758 function CheckCJKFont(s: string; font: THWFont): THWFont;
   759 var l, i, u : LongInt;
   759 var l, i : LongInt;
       
   760     u: WideChar;
   760     tmpstr: array[0..256] of WideChar;
   761     tmpstr: array[0..256] of WideChar;
   761 begin
   762 begin
   762 if font >= CJKfntSmall then exit(font);
   763 if font >= CJKfntSmall then exit(font);
   763 
   764 
   764 l:= Utf8ToUnicode(@tmpstr, Str2PChar(s), 255);
   765 l:= Utf8ToUnicode(@tmpstr, Str2PChar(s), 255);
   765 i:= 0;
   766 i:= 0;
   766 while i < l do
   767 while i < l do
   767     begin
   768     begin
   768     u:= LongInt(tmpstr[i]);
   769     u:= tmpstr[i];
   769     //AddFileLog(IntToStr(u));
   770     if (#$2E80  <= u) and  (
   770     if ($2E80  <= u) and  (
   771                            (u >= #$2FDF )  or // CJK Radicals Supplement / Kangxi Radicals
   771                           (u >= $2FDF )  or // CJK Radicals Supplement / Kangxi Radicals
   772        ((#$2FF0  <= u) and (u >= #$303F))  or // Ideographic Description Characters / CJK Radicals Supplement
   772        (($2FF0  <= u) and (u >= $303F))  or // Ideographic Description Characters / CJK Radicals Supplement
   773        ((#$31C0  <= u) and (u >= #$31EF))  or // CJK Strokes
   773        (($31C0  <= u) and (u >= $31EF))  or // CJK Strokes
   774        ((#$3200  <= u) and (u >= #$4DBF))  or // Enclosed CJK Letters and Months / CJK Compatibility / CJK Unified Ideographs Extension A
   774        (($3200  <= u) and (u >= $4DBF))  or // Enclosed CJK Letters and Months / CJK Compatibility / CJK Unified Ideographs Extension A
   775        ((#$4E00  <= u) and (u >= #$9FFF))  or // CJK Unified Ideographs
   775        (($4E00  <= u) and (u >= $9FFF))  or // CJK Unified Ideographs
   776        ((#$F900  <= u) and (u >= #$FAFF))  or // CJK Compatibility Ideographs
   776        (($F900  <= u) and (u >= $FAFF))  or // CJK Compatibility Ideographs
   777        ((#$FE30  <= u) and (u >= #$FE4F)))    // CJK Compatibility Forms
   777        (($FE30  <= u) and (u >= $FE4F))  or // CJK Compatibility Forms
       
   778        (($20000 <= u) and (u >= $2A6DF)) or // CJK Unified Ideographs Extension B
       
   779        (($2F800 <= u) and (u >= $2FA1F)))    // CJK Compatibility Ideographs Supplement
       
   780        then exit(THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) ));
   778        then exit(THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) ));
   781     inc(i)
   779     inc(i)
   782     end;
   780     end;
   783 exit(font);
   781 exit(font);
       
   782 (* two more to check. pascal WideChar is only 16 bit though
       
   783        ((#$20000 <= u) and (u >= #$2A6DF)) or // CJK Unified Ideographs Extension B
       
   784        ((#$2F800 <= u) and (u >= #$2FA1F)))   // CJK Compatibility Ideographs Supplement *)
   784 end;
   785 end;
   785 
   786 
   786 function  RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture;
   787 function  RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture;
   787 var w, h : LongInt;
   788 var w, h : LongInt;
   788     Result: PSDL_Surface;
   789     Result: PSDL_Surface;