ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Text Setting
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AndNit

Brazil
81 Posts

Posted - Jul 18 2024 :  19:40:17  Show Profile  Reply
Hey...

I have a text layer that I automatically fill with words that I take from HTML. However, when starting the text with Bold Italic, for example, and then inserting new text with another formatting, the previous formatting is replaced by the new formatting.

I need each word to be written on the text layer, with the formatting indicated when filling it out and that the formatting, already applied to the previous words, remains unchanged.

I'm doing it this way:


var
  Texto, TextoApoio, Inicio, Fim, InicioTxt, FimTxt: string;
  De, Ate, DeTxt, AteTxt, a, b, Letras: integer;
begin
  mTag.Clear;
  Texto  := SL[0];
  Inicio := '<';
  Fim    := '>';
  while Pos(Inicio, Texto) > 0 do begin
    De := Pos( Inicio, Texto );
    Ate := Pos( Fim, Texto ) - 1;
    if  Ate < 0 then
        Ate := Length( Texto );

    mTag.Lines.Add( Copy(Texto, De, (Ate+1)) );
    TextoApoio := TextoApoio + Copy(Texto, De, (Ate+1));
    Delete( Texto, De, 1 );
    Delete( Texto, De, Ate );
    AteTxt := Pos( Inicio, Texto );
    if Copy(Texto, (1), 1) <> '<' then begin
        TIETextLayer( image.CurrentLayer ).ActivateEditor;
        TIETextLayer( image.CurrentLayer ).EnableFormatting := True;
        Letras := TIETextLayer(image.CurrentLayer).RichText.Length;
        TIETextLayer( image.CurrentLayer ).RichText.Insert( letras ,Copy(Texto, 1, AteTxt-1 ));
        TIETextLayer( image.CurrentLayer ).Font.Name  := 'Courier New';
        a := (pos('strong', TextoApoio));
        b := (pos('underline', TextoApoio));
        if (a > 0) and (b > 0)  then
           TIETextLayer( image.CurrentLayer ).Font.Style := [fsBold, fsUnderline]
        else
           if (a > 0) then
              TIETextLayer( image.CurrentLayer ).Font.Style := [fsBold]
           else
              if (b > 0)  then
                 TIETextLayer( image.CurrentLayer ).Font.Style := [fsUnderline]
              else
                 TIETextLayer( image.CurrentLayer ).Font.Style := [];
        TIETextLayer( image.CurrentLayer ).Font.Size  := 18;
        //image.MouseInteractLayers := [mlCreateTextLayers, mlMoveLayers, mlResizeLayers, mlRotateLayers ];
        //image.LayerOptions := image.LayerOptions + [ loPreventOutOfBounds  ];
        image.Update();
        mTexto.Lines.Add( Copy(Texto, 1, AteTxt-1 ) );
        Delete( Texto, 1, 1 );
        Delete( Texto, 1, AteTxt-2 );
        TextoApoio := '';
    end;
  end;
end;


Thanks

xequte

38613 Posts

Posted - Jul 20 2024 :  16:27:40  Show Profile  Reply
Yes, that is correct. The Font property has no effect if rich formatting is used:

http://www.imageen.com/help/TIETextLayer.Font.html

To add formatted text you would need to update the RichText Property:

http://www.imageen.com/help/TIETextLayer.RichText.html

Which would require you to build a rich text string, e.g. using TIERichEdit:

http://www.imageen.com/help/TIERichEdit.AddFormattedText.html


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

AndNit

Brazil
81 Posts

Posted - Jul 23 2024 :  17:14:39  Show Profile  Reply
Hello,

I'm still having trouble finding a solution.

I couldn't do it based on the instructions you brought me.

I need to insert text, automatically in a text layer, word by word and when I'm writing (automatically, without user interaction), I need to say that that first word is BOLD, UNDERLINED, that the next word is just BOLD and or that has no configuration. I can do almost this, it turns out that when he configures the last word, he applies the changes to the entire layer, I need each word to continue with the configuration that was written
Go to Top of Page

xequte

38613 Posts

Posted - Jul 24 2024 :  05:13:20  Show Profile  Reply
Hi

There is no built-in functionality for that. You can only programmatically format text in as much as it is supported by TRichEdit or TIERichEdit.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

AndNit

Brazil
81 Posts

Posted - Jul 24 2024 :  08:28:36  Show Profile  Reply
and how can I assign the formatted text of a TRichEdit, within a text layer or a RichEdit bed, on the image?

Can I, after writing the text, select the characters I need and configure them the way I want them? I need the text to be written on the image, in a specific place on it.

Another solution would be to mirror TRichEdit in the position I need in the image, how can I do that?
Go to Top of Page

xequte

38613 Posts

Posted - Jul 25 2024 :  01:56:25  Show Profile  Reply
Hi

If you use TIERichEdit (which is just an enhanced TRichEdit) then you can assign its Rich text:

http://www.imageen.com/help/TIERichEdit.RTFText.html

To the RichText property of the layer:

http://www.imageen.com/help/TIETextLayer.RichText.html


You can add formatting to a selection in TTIERichEdit using:

http://www.imageen.com/help/TIERichEdit.SelAttributes.html

Or, as mentioned, add formatted text using:

http://www.imageen.com/help/TIERichEdit.AddFormattedText.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

AndNit

Brazil
81 Posts

Posted - Jul 25 2024 :  14:00:21  Show Profile  Reply
Sorry, you've helped me a lot here, but I'm not able to move forward with the solution.

How would I write this text, using the code below, with these formatting in a text layer:

Text:

PROPERTY: Residential building (under construction) located in Praia da Guanabara, nš 1371, former nš 433, belonging to the parish of Nossa Senhora d'Ajuda, useful domain of the land, outside the Federal Union.

Code: (I can't understand the configuration parameters of the "URL" sent in TIETextLayer( ImageEnView1.CurrentLayer ).RichText)


   TIETextLayer( ImageEnView1.CurrentLayer ).EnableFormatting := True;
   TIETextLayer( ImageEnView1.CurrentLayer ).RichText := 
   #123'\rtf1\ansi\ansicpg1252\deff0'#123'\fonttbl'#123'\f0\fnil\fcharset0 
   Tahoma;'#125#125'\viewkind4\uc1\ pard\lang1033\b\f0\fs24 ImageEn!\b0\par'#125;
   ImageEnView1.Update();


Thank you very much for your attention, I've been stuck with this problem for almost a month
Go to Top of Page

xequte

38613 Posts

Posted - Jul 26 2024 :  21:49:24  Show Profile  Reply
Hi

If you run the demo:

\Demos\Other\RichEdit\RichEdit.dpr

You will see the RTF for your text is:

{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang5129\deflangfe5129{\fonttbl{\f0\fswiss\fprq2\fcharset0 Aptos;}}
{\*\generator Riched20 10.0.22621}{\*\mmathPr\mnaryLim0\mdispDef1\mwrapIndent1440 }\viewkind4\uc1 
\pard\widctlpar\sa160\sl276\slmult1\kerning2\ul\b\f0\fs24 PROPERTY:\ulnone\b0  \b Residential building (under construction)\b0  located in \b Praia da Guanabara, n\'ba 1371\b0 , former n\'ba 433, belonging to the parish of Nossa Senhora d'Ajuda, useful domain of the land, \b outside the Federal Union.\b0\par
}


Which you can use to insert a formatted text layer as follows:

  ImageEnView1.LayersAdd( ielkText );
  TIETextLayer( ImageEnView1.CurrentLayer ).EnableFormatting := True;
  TIETextLayer( ImageEnView1.CurrentLayer ).RichText :=
    '{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang5129\deflangfe5129{\fonttbl{\f0\fswiss\fprq2\fcharset0 Aptos;}}' +
    '{\*\generator Riched20 10.0.22621}{\*\mmathPr\mnaryLim0\mdispDef1\mwrapIndent1440 }\viewkind4\uc1' +
    '\pard\widctlpar\sa160\sl276\slmult1\kerning2\ul\b\f0\fs24 PROPERTY:\ulnone\b0  \b Residential building (under construction)\b0  located in \b Praia da Guanabara, n\''ba 1371\b0 , former n\''ba 433, belonging to the parish of Nossa Senhora d''Ajuda, useful domain of the land, \b outside the Federal Union.\b0\par}';
  TIETextLayer( ImageEnView1.CurrentLayer ).SizeToText();
  ImageEnView1.Update();


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

AndNit

Brazil
81 Posts

Posted - Jul 27 2024 :  16:40:45  Show Profile  Reply
Thanks Nigel,

Is there a manual I can use to build this "URL" that explains the general settings? I'm pretty lost in the configuration parameters, although your example has cleared up some of my doubts.

Thanks
Go to Top of Page

xequte

38613 Posts

Posted - Jul 27 2024 :  23:07:36  Show Profile  Reply
Hi

Do you mean a manual for the RTF standard?

Please see: https://latex2rtf.sourceforge.net/rtfspec.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: