[fpc-devel] Unicodestring branch, please test and help fixing

Martin Schreiber fpmse at bluewin.ch
Thu Sep 11 22:56:49 CEST 2008


On Thursday 11 September 2008 22.33:32 listmember wrote:
>  >> procedure TLabel.Paint(...)
>  >> begin
>  >>   if *Caption.IsRTL *then
>  >>     DrawCaptionRTL(0,0,*Caption.AsUTF8*, flags)
>  >> else
>  >>     DrawCaption(0,0,*Caption.AsUTF8*, flags);
>  >> end;
>  >>
>  >> Is not that enough?
>  >
>  > What is the gain as opposed to
>  >
>  >   procedure TLabel.Paint(...)
>  >   begin
>  >    if IsRTL(Caption) then
>  >      DrawCaptionRTL(0,0,AsUTF8(Caption), flags)
>  >   else
>  >      DrawCaption(0,0,AsUTF8(Caption), flags);
>  >   end;
>  >
>  > In other words where is the benefit from OOP in this ?
>
> IMO, both are deficient as they both assume that a string block (text)
> is either RTL or LTR.
>
> Doesn't that mean we will be --by design-- unable to write something
> like 'Yom Kippur (יוֹם כִּפּוּר)' on a caption?
>
> This is why I keep asking that the 'TCharacter' or 'TChar' needs to have
> a language attribute.
>
MSEgui has a richstringty type, a combination of a widestring and a dynamic 
array of formatting info. There are formatting infos for the changes only, a 
richstringty without formatting info has a nil pointer for the dynamic array. 
See lib/common/kernel/mserichstring.pas
http://sourceforge.net/projects/mseide-msegui/

"
type
 newinfoty = (ni_bold=ord(fs_bold),ni_italic=ord(fs_italic),
              ni_underline=ord(fs_underline),ni_strikeout=ord(fs_strikeout),
              ni_selected=ord(fs_selected),
              //same order as in fontstylety
                 ni_fontcolor,ni_colorbackground,ni_delete);
 newinfosty = set of newinfoty;

const
 fonthandleflags = [ni_bold,ni_italic];
 fontstyleflags = [ni_bold,ni_italic,ni_underline,ni_strikeout,ni_selected];

type
 charstylety = record
  fontcolor,colorbackground: pcolorty;
  fontstyle: fontstylesty;
 end;
 pcharstylety = ^charstylety;

 charstylearty = array of charstylety;

 formatinfoty = record
  index: integer;            //0-> from first char
  newinfos: newinfosty;
  style: charstylety;
 end;

 pformatinfoty = ^formatinfoty;
 formatinfoarty = array of formatinfoty;
 pformatinfoarty = ^formatinfoarty;

 richstringty = record
  text: msestring;
  format: formatinfoarty;
 end;
"

It was designed for fast processing in MSEide source code editor.

Martin



More information about the fpc-devel mailing list