Another Mystery Model

Saturday, July 1, 2023

How an App Displays Text

I'm not a professional computer scientist, but I've taken a number of courses on computer science, and I can, as they say, read between the lines.

Most computers today have the basic capability to display text characters built into the hardware.  So there is a "word" in memory that remembers where, on the screen, the active location is.   Unless you touch the mouse, or press the arrow keys, the next whatever: character, or word, or symbol will be right here.  Whatever font is desired is also put into another "word" of memory; it's easier to number all the fonts available on the computer (or phone,  or whatever) 1, 2, 3 ... and just note down which number font is wanted.  If it isn't one of the fonts that was shipped with the device, then the computer has to look up how to draw each character as it comes up.  (This is nothing; every minute, the device has to look up a vast number of things, so it does it without complaint.)

Suppose it's displaying a line of text.  If it's starting a new word, it has to see whether there's space for the whole word on the present line.  (You can imagine that it's keeping track of how far along the line it is.  Each character could be a different width, so it's been adding these widths to the width-counter as it prints them.)  If there's space for the whole word, it proceeds to start the word, otherwise it pops down to the next line (unless it's the end of the page, which is a small problem!)  All this sounds painstaking and slow, but we know computers are fast. 

A slightly different procedure takes place if the variable called "hyphenation on" has the value "true" placed in it.  "True" is represented by 1, "False" by a zero.  Hyphenation can be done in two ways: automatic hyphenation, and manual hyphenation.  (Manual hyphenation can be done two ways, too, but we'll just do it one way for the moment.)

The app keeps its finger at the space just before the word, and starts looking through the word for a hyphenation suggestion.  This is a little invisible "character", what it is exactly does not matter.  There are literally hundreds of invisible characters the app could use.  If there is one, then here's what it does. 

It considers the portion of the word just up to that invisible character, and decides whether there's space for that portion, plus a hyphen.  If there is, it puts that portion on the screen, and a hyphen,  and pops down to the next line, puts in another hyphen, and the remainder of the word, and continues with the next word!  As always, every character's appearance has to be looked up, but that's really not done by the app, but by the Android system. 

So the life of a device consists of a lot of lookups, and lighting up a lot of pixels, and calculation to decide whether a word will fit. 

The other manual method of Hyphenation is, instead of the author putting in these invisible hyphenation suggestions, the editor (not a person, but the word-processor) beeping when it comes to a long word, and waiting for the author to approve a place to break the word.

Not everyone will find this post interesting, but it's good to have an idea how devices really work, than to think of it as magic!


I was re-reading Galactic Voyager just now, and I have to agree that the Table of Contents (TOC) is not as useful as it should be.  I have to get into the original Word document, and create a new, improved TOC, at least for my use.  I don't think too many individuals have read the story all the way through---and it's a fearsome achievement, just because of its size.  I doubt whether I will ever write something so substantial.  But being incognito, I can't even enjoy the pride of having written it.

Kay H. B.

No comments:

Post a Comment