Hello Leroy
[..]
> I think I haven't make my problem clear enough for you. What I need is
> not how to get the MS Word work better but the mechanism which MS Word
> uses to justify the spaces in a line. The layout model the MS Word
> uses. Just like Tex uses glue mechanism to justity the space between
> words, what does Word use?
Nah, your description was fine.
It's just that nobody in here has come upon a clear _authorized_
description (that only MSFT could give). Doesn't mean there isn't one,
but it's a strong indicator. microsoft.com is a huge place, though.
Maybe you find something (and hopefully share it with us if you do :-)).
The default justification algorithm's workings are pretty simply,
though: it adds words after each other, with whatever standard space
width is in a font, until one word is too long to fit on the page. Word
then brings the whole word (or parts of it, if it can through hyphens or
hyphenation) to the new page. And expands the remaining spaces on the
line, equally.
Very simple. And brings pretty bad results if you don't hyphenate a lot!
The compatibility option Peter mentions [BTW: I'm not sure it's needed
anymore in Word 2007] does it a lot better, IMHO. If you activate it,
then upon noting a Word doesn't fit anymore on the line, Word starts to
_reduce_ the space width in the whole line to make it fit. I have no
idea what the threshold is (how thin it will make it, I suspect
something around 2/3 of a normal space width, but that's a really wild
guess). When the word suddenly fits like this, the next word starts the
new line. If the threshold is met, the whole word jumps to the next
line, and Word spacing expands as before.
Not much more intelligent, but the results are far better IMHO.
Now, it's still a very "dumb" algorthm, sort of, since it doesn't look
back and forth in the paragraph. And the automatic hyphenation approach
is not cleverer.
I have no idea how LaTeX does it, but it usually looks better.
That's why, in Word, I prefer to manually hyphenate texts where I can
justify the time for a proper pagination. [This includes texts w/o
horizontal justification, btw.]
2cents
Robert

Signature
/"\ ASCII Ribbon Campaign | MS
\ / | MVP
X Against HTML | for
/ \ in e-mail & news | Word
LeroyLi - 05 Nov 2007 14:06 GMT
On Nov 5, 8:32 pm, "Robert M. Franz (RMF)" <robert.fr...@mvps.org>
wrote:
> Hello Leroy
>
[quoted text clipped - 51 lines]
> X Against HTML | for
> / \ in e-mail & news | Word
Thanks for your replying.
I agree that Word will expand the remaining space equally. Yet there
remains a problem: how dose Word determin the original spaces between
two words when there is no need to expand spaces?
I have worked on this these days, and guessed that these original
spaces is defined in the TrueType font which is the MS' default font.
Now I need to read the Times New Roman font file to find the original
spaces. Oh, God! I need to find some introduction or specification to
help me. This is really a heavy work.
Jonathan West - 05 Nov 2007 15:01 GMT
> I agree that Word will expand the remaining space equally. Yet there
> remains a problem: how dose Word determin the original spaces between
> two words when there is no need to expand spaces?
> I have worked on this these days, and guessed that these original
> spaces is defined in the TrueType font which is the MS' default font.
Not quite. It is defined by the space character of whatever font is
presently in use. So unexpanded space varies according to the font face and
size.
> Now I need to read the Times New Roman font file to find the original
> spaces. Oh, God! I need to find some introduction or specification to
> help me. This is really a heavy work.
Not just TNR. Whichever font is in use.
You can get the width of a space relatively easily in Word. You can use the
Selection.Information(wdHorizontalPositionRelativeToPage) property to get
the position of the cursor when positioned to the left of the space, and
again with the cursor positioned to the right of the space. The difference
between the two values is the width of the space in points. You will find
that the space width does differ depending on which font the text is
formatted with.
You could build a library of space widths for various fonts and use that
rather then calculate every time. You could also get the width of space for
a large font size (e.g. 72pt) and divide down for smaller sizes of the same
font.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
macropod - 06 Nov 2007 02:04 GMT
Hi all,
FWIW, I posted some code recently in microsoft.public.word.printingfonts to extract the (standard) character widths for the ASCII
character set.
Cheers

Signature
macropod
[MVP - Microsoft Word]
-------------------------
>> I agree that Word will expand the remaining space equally. Yet there
>> remains a problem: how dose Word determin the original spaces between
[quoted text clipped - 18 lines]
> You could build a library of space widths for various fonts and use that rather then calculate every time. You could also get the
> width of space for a large font size (e.g. 72pt) and divide down for smaller sizes of the same font.