FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

FONTS

Increase/decrease fontsize by one point


I suspect what you are looking for are these toolbox calls:
CALL TEGETSTYLE (byte%,txtStyleRec,lineH%,ascent%,teH&)
CALL TESETSTYLE (mode%,txtStyleRec,redraw%,teH&)
The txtStyleRec is an indeterminate-length record, so I'm guessing that FB probably wants a handle here, rather than the actual record--you'd have to experiment unless someone else can tell us.

The format of txtStyleRec is this, if I translated IM correctly:
DIM RECORD styleRun
  DIM startChar%   'starting char pos
  DIM styleIndex%  'index in style table
DIM END RECORD .styleRunSize

DIM RECORD txtStyleRec
  DIM nRuns%       'number of style runs
  DIM nStyles      'number of distinct styles in table
  DIM styleTabH&   'handle to style table
  DIM lhTabH&      'handle to line-height table
  DIM teRefCon&    'reserved for application use
  DIM nullStyleH&  'handle to style set at null selection
DIM END RECORD .runsOffset
The txtStyleRec is followed by an array of styleRuns, which you could access with
  DIM stylH&, stylPtr&
  DIM  styleRuns&
  XREF styleRuns.styleRunSize(99)

  stylRecH&    = TeH&..txFont&  'handle takes place of txFont% & txFace%
  stylRecPtr&  = [stylRecH&]    'should probably lock first
  styleRuns&   = stylRecPtr&+.runsOffset
I'm beginning to realize you really need all the IM info to do this right. It's complex, but not really difficult. If you have IM, I'm sure you can manage it. As I recall, you originally asked for quick, but not easy. Good luck.
Jay

The following code will discriminate between styled and regular EF using TEHANDLE and change the font, size of selected text in the styled EF:
COMPILE 0, _caseInsensitive

LOCAL FN buildWnd
  WINDOW#1,"styledEFChngFont.demo",(0,0)-(500,200)
  PRINT%(30,30)"Select text in EF."
  TEXT _geneva,14
  EDIT FIELD#-1,"",(100,80)-(400,100),2,2         'negative ID
  EDIT$(1)="Styled EF containing multiFonts,styles."
  EDIT FIELD#2,"",(100,130)-(300,150),2,2
  EDIT$(2)="Regular EF, positive ID."
  EDIT FIELD(0)
END FN

LOCAL FN doDialog
  evnt=DIALOG(0)
  id=DIALOG(evnt)
  SELECT evnt
    CASE _wndClose
      END
    CASE _efClick
      efH&=TEHANDLE(id)
      size%=efH&..teSize%
      LONG IF size% < 0
        EDIT TEXT _sysFont,13
      END IF
      EDIT FIELD(0)
  END SELECT
END FN

FN buildWnd
ON DIALOG FN doDialog
DO
  HANDLEEVENTS
UNTIL 0
Steve Van Voorst

You got me curious, so I wrote the FN you requested. Turns out to be much simpler than either of us expected, although it took me 3 hours to get it working.
CLEAR LOCAL FN changeSize(teH&,chngAmt)
  'This FN changes the size of text selected 
  'in teH& by chngAmt points: + = larger, - = smaller

  DIM newStyle.styleSize                  'text style record
  newStyle.tsSize = chngAmt
  CALL TESETSTYLE(_addSize,#@newStyle,_false,teH&)
  CALL INVALRECT(teH&..teViewRect%)
END FN
Try using
  CALL TECALTEXT(teH&)
after TESETSTYLE. I haven't tried it, but I think it will solve your problem.

I thought it might be useful to point out that the main reason it took me 3 hours to get this working is that the FB documentation fails to indicate that the second parameter of CALL TESETSTYLE is a _pointer_ to the 12-byte text style record. It should be:
  CALL TESETSTYLE(mode,txtStylePtr&,redraw,teH&)
I did it by using #@:
  CALL TESETSTYLE(_addSize,#@txtStyleRec,_false,teH&)
Do yourselves a favor and make a note on Reference Manual p. 279 about the error.

Do the same on the 'Text Edit' page in the online Toolbox Help file. Save it by choosing 'Save Subject' from the Help menu in the menu bar (not Apple menu).

Then someday when you want to use CALL TESETSTYLE, you won't have to spend the 3 hours that I did.

Strangely enough, the corollary, CALL TEGETSTYLE, accepts the record variable directly!
  CALL TEGETSTYLE(byte,txtStyleRec,lineH,ascent,teH&)
Jay