Enlarge / Shrink styled Text from DesktopTextArea

I need to add a “global“ Enlarge (A) / Shrink (a) styled text displayed in TextArea.

I completely forget how to do it.

I get an eye on the documentation and it seems that is a complex task (for desktop):
copy the RTFData into a MemoryBlock
loop the MB and modify the Size value
once done, apply the new RTFData.

Is-it correct ?

PS: speed does not matter as the text is not large (1K-5k ?)

Bonjour Emile,

In my app RealCADD, I can resize (Enlarge and Shrink) styled texts.
Create a styled text, select it and call “Action” → “Redimensionner”.
Can you test and say me if it is what you want ?

Cordialement.

It’s just 75€ and you can find it here: ‎RealCADD on the Mac App Store :money_mouth_face:

Oh, how nice !

you mean the font size of selected text?

.Size(Start, Length)

Gets or sets the font size for the selected text in Text.
https://documentation.xojo.com/api/text/styledtext.html#styledtext-size

THE WHOLE DOCUMENT IN A SINGLE CLICK.

THANK YOU FOR THE DOCUMENTATION LINK :slight_smile:

1 Like

i made a knowledge-base app with xojo, it used Rich Text Format text area :slight_smile:

Sasha,

RealCADD can be dowloaded from my web pages and tried for free…
RealCADD

1 Like

I looked into my code to remember what I’d done.
It is simple.
RTFData of a StyledText looks like this :
{\rtf1\ansi\ansicpg1252{\fonttbl{\f0\fnil Helvetica;}}{\colortbl\red0\green0\blue0;\red0\green0\blue255;\red255\green0\blue0;}\uc0 \f0\fs36 Essai de \cf1\fs54 texte\cf0\fs36 avec des \fs42 tailles\fs36 \fs108 diff\u233 rentes\fs36 et des \i\cf2\fs72 styles\i0\cf0\fs36 .}
Sizes are defined by code “\fs”.
Loop into it and change the values :
For example :
ScaleRTFData(previousDATA As String, cZoom As Double)

#pragma BackgroundTasks False
#pragma BoundsChecking False
#pragma NilObjectChecking False
#pragma StackOverflowChecking False

Var mStr As String = previousDATA
Var mStr2, mStr3 As String

//Changement des tailles de caractère : code "\fs"
Var i, j, k, k2, k3, k4 As Integer
k = mStr.CountFields("\fs") - 1
for i = 1 to k
  k2 = mStr.IndexOf(k3, "\fs") + 3
  //Test si ce n'est pas //fs
  mStr3 = mStr.Middle(k2 - 4, 1)
  if mStr3 = "\" then
    //Ce n'est pas un code de taille de font
  else
    mStr2 = mStr2 + mStr.Middle(k3, k2 - k3)
    //Recherche de la fin du code de taille
    k3 = mStr.IndexOf(k2, " ")
    k4 = mStr.IndexOf(k2, "\")
    if (k4 < k3) and (k4 <> -1) then k3 = k4
    j = Val(mStr.Middle(k2, k3 - k2))
    j = Round(j * cZoom)
    mStr2 = mStr2 + Str(j)
  end if
next i
mStr2 = mStr2 + mStr.Middle(k3, mStr.Length - k3)

Return mStr2

Voilà !

1 Like