Recent

Author Topic: Paragraph Widows/Orphans  (Read 6960 times)

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Paragraph Widows/Orphans
« on: October 13, 2016, 03:27:46 pm »
I have been trying to activate the PFM_NOWIDOWSCONTROL for paragraphs by the same method that was previously supplied: MakeRTLPara.

Code: Pascal  [Select][+][-]
  1. procedure SetParaNoWidows(isWidow: Boolean);
  2. var
  3.   p: ParaFormat2;
  4. const
  5.   WidowFlag: array [Boolean] of word=(0, PFE_NOWIDOWCONTROL);
  6. begin
  7.   FillChar(p, SizeOf(p), 0);
  8.   p.cbSize:= SizeOf(p);
  9.   p.dwMask:= p.dwMask or PFM_NOWIDOWCONTROL;
  10.   p.wEffects:= p.wEffects or WidowFlag[isWidow];
  11.   SendMessage(PageMemo.Handle, EM_SETPARAFORMAT, 0, LPARAM(@p));
  12. end;
  13.      
  14.  

Can anyone help on making it work?

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #1 on: October 13, 2016, 09:01:03 pm »
I was able to make it work by invoking RichEdit with the EM_SETPARAFORMAT command... it appears that RichMemo is missing the function, but RichEdit has it.

Code: Pascal  [Select][+][-]
  1. procedure SetParaNoWidows(isWidow: Boolean);
  2. var
  3.   p: ParaFormat2;
  4.   res: Integer;
  5. const
  6.   WidowFlag: array [Boolean] of word=(0, PFE_NOWIDOWCONTROL);
  7. begin
  8.   FillChar(p, SizeOf(p), 0);
  9.   p.cbSize:= SizeOf(p);
  10.   p.dwMask:= p.dwMask or PFM_NOWIDOWCONTROL;
  11.   p.wEffects:= p.wEffects or WidowFlag[isWidow];
  12.   res:= SendMessage(PageMemo.Handle, richedit.EM_SETPARAFORMAT, 0, LPARAM(@p));
  13. end;    
  14.  

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Paragraph Widows/Orphans
« Reply #2 on: October 13, 2016, 09:09:52 pm »
I was able to make it work by invoking RichEdit with the EM_SETPARAFORMAT command.
That's the right way to do that.

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #3 on: October 13, 2016, 09:18:59 pm »
Sorry, it was false hope. I had edited the document, changing its structure (because it is my operational manual), and I forgot about it. It still has the issue. It didn't help.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #4 on: October 13, 2016, 11:29:11 pm »
I have done a lot of refinements to the editor. It now does Greek, as well as English, Hebrew, and Syriac. But I am not doing Greek accents. Every Unicode font for Greek employs an archaic method for typing accents. It is because they had engineered them before Unicode was fully developed. Consequently they built multiple characters for every vowel. Each character has a unique combination of accents. There are only 7 vowels, but each vowel can be capital character, making 14. The result is that there 285 characters to display those 7 vowels. It is inane, but the industries are too invested to change it. Therefore I am only doing the alphabet without accents. It doesn't need the accents. They only tell you how to talk. The words still mean the same without them.

It is evidence of Greek being a young language. Languages become simplified with age. In fact it was developed from Phoenician... the first tonally written language. Hebrew and Syriac had also developed from Phoenician, but they had done it earlier than Greece. That is why I went ahead and did the Greek. I set it up with the same keyboard characters as I had done for the others. They each have some unique keys, but they are probably 90% unified. I was happy to see that.

But as I mentioned, I have made many refinements to the program. Things that make the editor comfortable for writing. It is nearly complete. I really wanted to have widow and orphan control for paragraphs. Anyone expects that much these days. They also expect to have word wrapping around images. They want to do newsletters, manuscripts, pamphlets, and books. We have lost image wrapping... if there is any way to accomplish widow control, it will serve to make the editor credible. Writing in four languages isn't really enough.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #5 on: October 14, 2016, 05:03:24 pm »
OK, it looks like it is another dead horse. Programmers have said that Widow Control has never worked.

So I went to the RTF codes. It has WidowCtrl for document, and WidCtlPar for paragraphs. Programmers have also said that the RTF WidowCtrl has never worked but WidCtlPar has.

I manually placed the WidCtlPar command into paragraphs, and our RTF engine politely erased them from the file. I don't think it would do that if it didn't know the command. I expect that it would post the command as text within the document. Nevertheless, whether it would or not, it rejects Widow controls.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Paragraph Widows/Orphans
« Reply #6 on: October 14, 2016, 05:21:52 pm »
OK, it looks like it is another dead horse. Programmers have said that Widow Control has never worked.
Not surprising. It's a complex typesetting task, which is too much of work, for such basic control.

To be honest, I never saw Widow/Orphan control in action. In either MS Word or any other editors.  I can always see hanging paragraphs here and there, even though the control is enabled by default.


rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #7 on: October 15, 2016, 09:43:18 pm »
Davka Writer does it. But they take over everything. I don't think they use any standard functions. I expect that if I took over EM_FORMATRANGE I could make it happen, but I can't do that because I would be fighting the RTF engine. I would have to not use the RTF engine... then I would I have to reinvent RTF control. Davka Writer did that. My only issue with them is that they don't do Greek, Syriac, or Arabic... only Hebrew and English, and it isn't Unicode.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #8 on: October 15, 2016, 09:56:54 pm »
With that said, I might add, Unicode is wimpy and irregular in my opinion. I did't have a problem with Syriac and Hebrew, except that they are not consistent with each other, but once I did Greek... Windows does font substitution at every chance it gets. It will set Greek to Arial, and English to the Hebrew font's English. I format everything, save it, and when I recall the file it changes all of the fonts.

Moreover it doesn't do it consistently. Some get swapped and other do not. It will retain the font for Greek capitals, and then swap to Arial for the lower cases... then to SBL Hebrew for one English string, and not on another.

My conclusion is that Windows is arrogantly humble. They just think that we don't know what we want.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #9 on: October 15, 2016, 11:17:49 pm »
One more thing. They only do the font substitution when it is a mixed language paragraph. If it is dedicated as Greek, Syriac, or Hebrew they leave it alone. It's complete dumbness.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #10 on: October 17, 2016, 04:15:35 pm »
It tracked down the rule for Windows automatic font substitution. It is mostly about metrics. They don't like mixed metrics in a paragraph... all fonts might be set to the size of 10 pts, but they will actually have different size specifications. Windows kicks them out because they claim that the user shouldn't have to deal with that.

The follow article by Microsoft explains...

https://msdn.microsoft.com/en-us/globalization/mt662331.aspx

Furthermore, if have been testing different fonts in your document, the RTF document retains those references, and the Operating System remembers your behavior. Eventually you can have a very mangled document with irregular substitutions throughout (which only show up upon opening the file). Mine is starting to look that way, since I am trying to find fonts with similar metrics.

"Better ideas" by Microsoft.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #11 on: October 17, 2016, 04:36:20 pm »
Do you remember the vowels being copped off on Syriac writing? I found this by a Greek font developer...

Quote
Why is the line spacing greater for the Plus fonts?

   In some environments, stacked diacritics in Gentium could display as
   'chopped-off'. Gentium Plus has slightly wider default line spacing
   in order to avoid this problem. Most applications do, however, let you
   set the line spacing explicitly, so you can have the lines spaced
   precisely as you wish.

That makes him a problem for font metrics. Too bad, it was a great font. It also means that my Syriac font might give me trouble at some point.

By some substitutions, I have noticed that it isn't only the font package that has the metric issue. One or two characters might be oversized, and the substitution for the other fonts won't happen until you use that character.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Paragraph Widows/Orphans
« Reply #12 on: October 17, 2016, 08:50:55 pm »
I believe that I may have it beat. I keep the font size at one setting (it may not be necessary), and I use Calibri for English and Greek, then SBL Hebrew for Hebrew, and Estrangelo Edessa for Syriac. I have tried many fonts and combinations. This is the only set that have been compatible with each other.

It isn't true of most Unicode fonts, but Calibri has the same metrics for English and Greek (others fight with themselves), and it is small enough to match SBL Hebrew and Estrangelo Edessa. At least for now, Windows doesn't mess with them... a bonus is that the Greek actually looks good.

I shudder to think about doing additional languages. On top of most fonts doing poorly with diacritics and vowels, now I have to worry about them looking good and being the right size.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

 

TinyPortal © 2005-2018