Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 18 in printed book and digital formats -- plus a one-year subscription (beginning with 19.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 5.2

COLUMN

Text Styling

Working with styled text

Issue: 5.2 (January/February 2007)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 15,616
Starting Page Number: 34
Article Number: 5212
Resource File(s):

Download Icon 5212.zip Updated: 2007-01-15 13:16:39

Related Link(s): None

Excerpt of article text...

For years REALbasic supported styled text in EditFields -- that is, text with various fonts, sizes, and other characteristics like bold and italic -- but there was no easy mechanism for you, the programmer, to access those details. Figuring out styled text was a complicated adventure of parsing the TextStyleData string within a memoryblock -- not for the faint of heart. That changed a few years ago when REALbasic introduced the StyledText class.

For those of you new to the whole concept of styled text, let's explore the medium for a minute. It will greatly help your understanding later.

Now plain text is easy -- it's just a string of characters:

The fast fox flounced across the flooded freeway.

With REALbasic's advanced string handling, you really don't even have to worry about text encoding, like whether some text is double-byte (i.e. Chinese, where each character is represented by a two-byte number). REALbasic's string handling routines handle all that stuff for you, so you just treat text as text and everything just works. (I'll still never get over my amazement when an early user of my Z-Write word processor, in 1999, sent me a screen shot of Z-Write working right-to-left with Hebrew text. I, of course, had done nothing extra to support Hebrew: it just worked.)

Once we get into styled text, however, our simple plain text has gotten complicated. Take a few seconds and think about how styled text must work: because the text can now be styled with various fonts, text sizes, and other characteristics, there needs to be a way to indicate the style information before each block of text. Each time a style change happens, we need new style information. Something like this (the details in brackets [ ] are the style info):

...End of Excerpt. Please purchase the magazine to read the full article.