Printed Font Size in TextArea Different from Same Text from Microsoft Word

Yes, and now it’s been confirmed. Thank you! :slight_smile:

FWIW, I just did a quick test and the text printed from Word and Xojo is exactly the same size. Line spacing is different…

I think our OP has not understood yet that a TextArea is not a word processor… Neither is the RichTextBox in VB. NET BTW.

If one needs a word processor in Xojo, go to http://bkeeney.com/ and get the Formatted Text Control class. It is a great word processor that can be added to any Xojo app.

Uh. That’s exactly what it is. If it’s not a word processor, what is it?

Or do you differentiate between “Notepad” from “WordPad?” Both are word processors; one is more functional than the other.

[quote=217166:@Christopher Lester]Uh. That’s exactly what it is. If it’s not a word processor, what is it?

Or do you differentiate between “Notepad” from “WordPad?” Both are word processors; one is more functional than the other.[/quote]

Style TextArea (WinAPI RichTextBox) is a Text Editor control with word wrap. In other words, which can show a subset of RTF that shows most styles (not subscript and superscript, not Overstrike). No line spacing, no margins, no tabs. The printing routine simply copies to the printer the content of the control, not unlike Graphics.DrawInto.

At the core, it has the same basic functionalities as something like Notepad, but with styling. Notepad is a great example of Text Editor as opposed to Word Processor.

To obtain the same functionalities as a full fledged word processor, you would need to program yourself line spacing, tabs, margins, etc. You would also need to create your own printing routines so you have precise line spacing.

Incidentally, I just checked the Wikipedia page you refer to. I believe it confuses terminology. Leading is NOT line spacing. A font is designed with an ascender and a descender. Schematically, the height of such characters as A, or N, and the length of the lower part of characters that go below the baseline, such as j or p.

Ascender and descender form an X-Box that sums up the total height of the character. But for aesthetic reasons, a font designer may decide that the actual drawing will start below the ascender line. Case in point, accents. So most of the time, the height of the taller character does not match the ascender.

As a result, the space above and below vary sensibly. That means the baseline on the screen or the printer will also move up and down. For the computer, who only works from what the font contains as instructions and does not see the design, all it has is the code of the font.

In order to have precise line spacing, the computer must detect the baseline, based on the Ascender, information you get in Xojo through TextAscent. Then line spacing as typographers define it can be calculated, making all characters vertically aligned, and lines straight no matter the font size or design.

All that requires complex programming, just from the screen stage. Printing is even more intricate.

It took years for Microsoft to perfect printing in Windows. I should know a thing or two about it as well. One of my friends, Bertrand Hartman, designed most of the Windows printer drivers back in the late eighties. What appears as simple as can be in Word is a very complex piece of engineering.

So is Formatted Text Control by Bob Keeney.

If you want the same features as Word, go FTC. You will spare yourself a lot of headaches.

Some will argue that that is still yet to occur :slight_smile:

How did you do your printing? I’m not seeing the difference and Bob’s control doesn’t produce a difference, so I have to conclude that Xojo is capable of printing “correctly”. What did you do to produce the incorrect result?

You should have seen the ■■■■ Microsoft 1 was printing. To be fair, at the time, Apple dotmatrix and laser printer had square pixels, while on Windows they had to support all sorts of printers with all sorts of pixel shape and strange protocols. At the time I was producing a universal driver for Dos application and still remember the nightmare. Bertrand succeeded making printing pretty transparent.

Today the same kind of difference occurs. Apple has a strict policy where only very few printers have been certified, and the number of drivers is pretty limited. Windows supports whatever kitchen sink around. It is bound to have some glitches here and there. It has been my observation that out of HP, one enters a strange world where transparent printing sometimes becomes a tad difficult.

I bet he is imposing precise spacing in Word that Xojo’s TextArea is incapable of emulating.

Tim, I’m guessing this is directed at me (OP). I am loading an RTF file into a TextArea and printing it with a StyledTextPrinter.

Tim, does your printer print at 72dpi? I’m using an HP LaserJet 2200d. From a quick search, it prints “up to 1,200 dpi.”

Let me know if you need any more data!

ADD: What happens when you print an RTF document from Xojo and from a different word processor? Is that how you tested?

Nope. I’m only concerned with character size, not line-height/line spacing/leading. :smiley:

Whatever you say. Good luck.

[quote=217258:@Christopher Lester], does your printer print at 72dpi? I’m using an HP LaserJet 2200d. From a quick search, it prints “up to 1,200 dpi.”
[/quote]

by default all printers print at 72dpi… UNLESS you tell XOJO to TELL the printer something different…
And if you DO, then you MUST tell it a resolution that the printer supports, or it will either round it to the nearest supportable resolution OR back to the default of 72dpi depending on the printer driver.

I used a simple DrawString command. And yes, I used the default of 72dpi. Otherwise, I would have to scale the font to get the same size. (12 point printed at 72dpi = 24 point printed at 144dpi, etc.) If I get a chance later, I’ll check it with StyledTextPrinter.

Cursory testing shows that StyledTextPrinter produces different results than the equivalent DrawString commands. Since I long ago wrote my own printing routines for styled text, I never noticed this before. Of course, I may be using the commands wrong, since I am not very familiar with StyledTextPrinter.

Xojo support told me, “Are you taking into account that the printer dpi is higher and Word may be taking that into account. Drawrect does that but DrawString doesn’t. So, you have to scale the font when you draw the string so it draws at the right size.” I think you are just confirming that fact. Now, the question is, 1) how do we obtain the DPI of the selected printer? and 2) how do we use that information to scale our output?

I don’t want this information for myself, as I’m going to be using FTC from BKeeney. But it might be good for the community to know.