Recent

Author Topic: Paragraph Formatting and Syriac fonts  (Read 8837 times)

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Paragraph Formatting and Syriac fonts
« on: March 25, 2017, 03:58:15 pm »
skalogryz,

I am still having trouble with Syriac vowels that are printed too high, as in the case of a very tall consonant. With them the vowel is set above the consonant. The result is that the upper portion of the vowel is clipped off.

If I change the line height by paragraph formatting, it has no change for the problem because it applies all of the height (actually a descent) to the bottom of the line base.

If I increase the top space for the entire paragraph it resolves the problem for the first line of the paragraph. But the problem remains for the rest of the lines within the paragraph.

My question is ... Can a parameter to formatting (TParaMetric) be added that will increase the space above a line base height, so that all of the paragraph lines will have a height above it? Perhaps it could be called "LinesHeader", and be a points value (as opposed to LineSpacing that has a multiplier).

I suspect that this additional parameter might even help to suppress Font Binding.

Rick
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2289
    • havefunsoft.com
Re: Paragraph Formatting and Syriac fonts
« Reply #1 on: March 26, 2017, 01:45:13 am »
Unfortunately, LineSpacing is the only option. There no APIs exposed to control the characters layout.

What you could try is inserting a character of a different height into the line.
That would cause the line to get some extra height.

It's a hacky way of doing things, but it is something to try.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Paragraph Formatting and Syriac fonts
« Reply #2 on: March 28, 2017, 03:56:42 pm »
I can see that it would work, but you are correct, it would be both unsightly and impractical. Is this another limitation of the RichEdit driver? I have an editor that has a function for a LineHeader, and it operates throughout a paragraph.

Rick
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2289
    • havefunsoft.com
Re: Paragraph Formatting and Syriac fonts
« Reply #3 on: March 28, 2017, 04:41:40 pm »
I can see that it would work, but you are correct, it would be both unsightly and impractical. Is this another limitation of the RichEdit driver?
Yes. There's no LineHeader parameter available for RichEdit.
You can review all available options in PARAFORMAT2 structure description.
The only thing that controls the spacing between lines is LineSpacing.

I have an editor that has a function for a LineHeader, and it operates throughout a paragraph.
what name?
I'd think that any application that's designed to text processing, would not be based on the RichEdit, due to its limitations.

...and thus I'd consider investing time/efforts/money into KMemo, or any other not RichEdit based solution.
« Last Edit: March 28, 2017, 04:44:13 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2289
    • havefunsoft.com
Re: Paragraph Formatting and Syriac fonts
« Reply #4 on: March 28, 2017, 05:08:47 pm »
hmm... dyLineSpacing and bLineSpacingRule...

RichMemo is forcing LineSpacing to use style 5 - and thus the extact line spacing. (this has to happen for cross-platform compatibility)

Now, I'm thinking what if it's causing the issue for you.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Paragraph Formatting and Syriac fonts
« Reply #5 on: March 28, 2017, 10:18:43 pm »
skalogryz,

I set all numerals to superscript which elevated the base height. It works when a verse number is in the line. Yet lines without are are still suffering from clipping.

Whatever you can do remedy the problem would be appreciated.

The editor is DavkaWriter. A PNG of their paragraph formatting is attached (noname.png). Their history is that they started with RTF, but now are proprietary. I don't know what they currently use, but it is still based on RTF modelling.

In the lower portion they have PTS before a line and after. It is separate from Paragraph before and after. Their WebSite is http://davka.com/index.php?route=product/product&product_id=67

I have used it for decades, and it is the best editor I have ever used. But they do not do Unicode, and have no provision for Syriac.

Rick

« Last Edit: March 28, 2017, 10:21:22 pm by rick2691 »
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Paragraph Formatting and Syriac fonts
« Reply #6 on: March 28, 2017, 10:31:08 pm »
OK. I said I have used it for decades... my perception of their doing HEADER height was wrong. It is a HEADER to the paragraph. It has been decades since I worried about being able to do it. I only thought that they did it.

Sorry, Rick
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Paragraph Formatting and Syriac fonts
« Reply #7 on: March 29, 2017, 06:20:57 pm »
OK again... I knew that I used to do this. It was with Polyedit. They are at http://polyedit.com

Attached is their format screen. It has a dialogue for lines that is called "At Least", and you enter a point height. It raises the base height. I used to use it for Syriac Unicode.
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Paragraph Formatting and Syriac fonts
« Reply #8 on: March 29, 2017, 07:18:11 pm »
By the document you referenced it looks like bLineSpacingRule does what PolyEdit does...

bLineSpacingRule
Type: BYTE

Type of line spacing. To use this member, set the PFM_LINESPACING flag in the dwMask member. This member can be one of the following values.

Value Meaning

0 Single spacing. The dyLineSpacing member is ignored.

1 One-and-a-half spacing. The dyLineSpacing member is ignored.

2 Double spacing. The dyLineSpacing member is ignored.

3 The dyLineSpacing member specifies the spacing from one line to the next, in twips. However, if dyLineSpacing specifies a value that is less than single spacing, the control displays single-spaced text.

4 The dyLineSpacing member specifies the spacing from one line to the next, in twips. The control uses the exact spacing specified, even if dyLineSpacing specifies a value that is less than single spacing.

5 The value of dyLineSpacing / 20 is the spacing, in lines, from one line to the next. Thus, setting dyLineSpacing to 20 produces single-spaced text, 40 is double spaced, 60 is triple spaced, and so on.

==================================

I found an example of using it with C#... https://www.gemboxsoftware.com/document/examples/word-paragraph-formatting/602

It has the following for the AtLeast function...
                    ParagraphFormat = new ParagraphFormat
                    {
                        LeftIndentation = 25,
                        RightIndentation = 25,
                        SpecialIndentation = -25,
                        LineSpacing = 10,
                        LineSpacingRule = LineSpacingRule.AtLeast
                    }

==================================

Rick
« Last Edit: March 29, 2017, 07:20:12 pm by rick2691 »
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Paragraph Formatting and Syriac fonts
« Reply #9 on: March 29, 2017, 08:48:07 pm »
Here is one that makes it easier. It is RichEdit and Pascal...

Code: Pascal  [Select]
  1. //set the paragraph line spacing in a TRichedit?
  2. //Title: set the paragraph line spacing in a TRichedit?
  3.  
  4. uses
  5.   RichEdit;
  6.  
  7. procedure RE_SetLineSpacing(ARichEdit: TRichEdit; lineSpacing: Byte);
  8. var
  9.   pf2: ParaFormat2;
  10. begin
  11.   FillChar(pf2, SizeOf(pf2), 0);
  12.   pf2.cbSize := SizeOf(PARAFORMAT2);
  13.   pf2.dwMask := PFM_LINESPACING;
  14.   pf2.bLineSpacingRule := lineSpacing;
  15.   SendMessage(ARichEdit.Handle, EM_SETPARAFORMAT, 0, Longint(@pf2));
  16. end;
  17.  
  18. //Example: Setlinespacing to 1:
  19. procedure TForm1.Button1Click(Sender: TObject);
  20. begin
  21.   RE_SetLineSpacing(RichEdit1, 1);
  22. end;
  23.  
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2289
    • havefunsoft.com
Re: Paragraph Formatting and Syriac fonts
« Reply #10 on: March 29, 2017, 09:32:45 pm »
Here is one that makes it easier. It is RichEdit and Pascal...
This is how you would use it for rich memo. :D

Code: Pascal  [Select]
  1. uses
  2.   RichMemo;
  3.  
  4. procedure RE_SetLineSpacing(ARichEdit: TRichMemo; lineSpacing: Byte);
  5. var
  6.   pf2: ParaFormat2;
  7. begin
  8.   FillChar(pf2, SizeOf(pf2), 0);
  9.   pf2.cbSize := SizeOf(PARAFORMAT2);
  10.   pf2.dwMask := PFM_LINESPACING;
  11.   pf2.bLineSpacingRule := lineSpacing;
  12.   SendMessage(ARichEdit.Handle, EM_SETPARAFORMAT, 0, Longint(@pf2));
  13. end;
  14.  
  15. //Example: Setlinespacing to 1:
  16. procedure TForm1.Button1Click(Sender: TObject);
  17. begin
  18.   RE_SetLineSpacing(RichMemo1, 1);
  19. end;
  20.  
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Paragraph Formatting and Syriac fonts
« Reply #11 on: March 29, 2017, 10:33:46 pm »
Thanks. I'll see if it works. I'll use the AtLeast or Exact method instead of LineSpacing.

Rick
« Last Edit: March 29, 2017, 10:36:49 pm by rick2691 »
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Paragraph Formatting and Syriac fonts
« Reply #12 on: March 30, 2017, 08:03:14 pm »
I was able to get it to work. It does both: Get and Set the parameter.

It also achieves my goal: The elevated Syriac vowels are not chopped.

Thanks for the help.

Rick
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2289
    • havefunsoft.com
Re: Paragraph Formatting and Syriac fonts
« Reply #13 on: March 30, 2017, 09:03:06 pm »
so, what settings did you use?
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Paragraph Formatting and Syriac fonts
« Reply #14 on: March 31, 2017, 01:56:39 pm »
The following are the codes that I adapted...

Getting paragraph parameters:
Code: Pascal  [Select]
  1. procedure TCmdForm.MnuFormatClick(Sender: TObject);
  2. var m: TParaMetric;
  3.     s: string;
  4.     FParaProps: TParaFormat2;
  5.     Result: boolean;
  6.     z: extended;
  7. begin
  8.   PopTop:= PageControl1.top;
  9.   PopMid:= CmdForm.width div 2;
  10.   FormatOfs.top:= PopTop;
  11.   FormatOfs.left:= PopMid - (FormatOfs.width div 2);
  12.   if FormatOfs.left<0 then FormatOfs.left:= 0;
  13.  
  14.   // get paragraph offset metrics
  15.   PageMemo.GetParaMetric(PageMemo.SelStart, m);
  16.   OfsTop.Text:= IntToStr(round(m.SpaceBefore));
  17.   OfsInd.Text:= IntToStr(round(m.FirstLine));
  18.   OfsLft.Text:= IntToStr(round(m.HeadIndent));
  19.   OfsRht.Text:= IntToStr(round(m.TailIndent));
  20.   OfsBtm.Text:= IntToStr(round(m.SpaceAfter));
  21.   Str(m.LineSpacing:0:2,s); OfsLns.Text:= s;
  22.  
  23.   // get paragraph LTR/RTL flow
  24.   FillChar(FParaProps, SizeOf(TParaFormat2), 0);
  25.   FParaProps.cbSize:= SizeOf(TParaFormat2);
  26.   PageMemo.Perform(EM_GetParaFormat, 0, LParam(@FParaProps));
  27.   if (FParaProps.dwMask and PFM_RTLPARA)=0
  28.       then Result:= False
  29.       else Result:= (FParaProps.wEffects and PFE_RTLPARA)<>0;
  30.   if Result then btnRTL.checked:= true else btnLTR.checked:= true;
  31.  
  32.   // get paragraph line metrics
  33.   if (FParaProps.dwMask and PFM_LINESPACING)<>0 then
  34.      begin
  35.         LnsMultiply.checked:= true;
  36.         if (FParaProps.bLineSpacingRule=0) then // single
  37.            begin
  38.            LnsMult.caption:= 'Multiplier Factor';
  39.            LnsMultiply.checked:= true; OfsLns.Text:= '1.2';
  40.            end;
  41.         if (FParaProps.bLineSpacingRule=1) then // one&half
  42.            begin
  43.            LnsMult.caption:= 'Multiplier Factor';
  44.            LnsMultiply.checked:= true; OfsLns.Text:= '1.5';
  45.            end;
  46.         if (FParaProps.bLineSpacingRule=2) then // double
  47.            begin
  48.            LnsMult.caption:= 'Multiplier Factor';
  49.            LnsMultiply.checked:= true; OfsLns.Text:= '2.0';
  50.            end;
  51.  
  52.         if (FParaProps.bLineSpacingRule=3) then // minimum
  53.            begin
  54.            LnsMult.caption:= 'Minimum Points';
  55.            LnsAtLeast.checked:= true;
  56.            z:= FParaProps.dyLineSpacing/20;
  57.            Str(z:0:0,s); OfsLns.Text:= s;
  58.            end;
  59.         if (FParaProps.bLineSpacingRule=4) then // maximum
  60.            begin
  61.            LnsMult.caption:= 'Maximum Points';
  62.            LnsExactly.checked:= true;
  63.            z:= FParaProps.dyLineSpacing/20;
  64.            Str(z:0:0,s); OfsLns.Text:= s;
  65.            end;
  66.      end;
  67.  
  68.   FormatOfs.Visible:= true;
  69. end;
  70.  

Setting paragraph parameters:
Code: Pascal  [Select]
  1. procedure TCmdForm.SetOfsLns(Sender: TObject);  
  2. var
  3.   m: TParaMetric;
  4.   pf2: ParaFormat2;
  5.   x: double;
  6.   inpOK: boolean;
  7.   err: integer;
  8. begin
  9.   InitParaMetric(m);
  10.   Val(OfsLns.Text, x, Err);
  11.   InpOK:= (Err=0);
  12.   if InpOK then
  13.      begin
  14.      if (LnsMultiply.checked=true) then // descending multiplier
  15.         begin
  16.         m.LineSpacing:= x;
  17.         PageMemo.SetRangeParaParams(PageMemo.SelStart, PageMemo.SelLength, [pmm_LineSpacing], m);
  18.         end;
  19.      if (LnsAtLeast.checked=true) then  // ascending minimum
  20.         begin
  21.         FillChar(pf2, SizeOf(pf2), 0);
  22.         pf2.cbSize := SizeOf(PARAFORMAT2);
  23.         pf2.dyLineSpacing:= round(x*20);
  24.         pf2.dwMask := PFM_LINESPACING;
  25.         pf2.bLineSpacingRule := 3;
  26.         SendMessage(PageMemo.Handle, EM_SETPARAFORMAT, 0, Longint(@pf2));
  27.         end;
  28.      if (LnsExactly.checked=true) then // ascending maximum
  29.         begin
  30.         FillChar(pf2, SizeOf(pf2), 0);
  31.         pf2.cbSize := SizeOf(PARAFORMAT2);
  32.         pf2.dyLineSpacing:= round(x*20);
  33.         pf2.dwMask := PFM_LINESPACING;
  34.         pf2.bLineSpacingRule := 4;
  35.         SendMessage(PageMemo.Handle, EM_SETPARAFORMAT, 0, Longint(@pf2));
  36.         end;
  37.      end else if (length(OfsLns.Text)>0)
  38.                  then showmessage('Improper value entry.')
  39.                  else showmessage('Must enter value.')
  40. end;
  41.  

Attached is the form appearing with its altered text, which has an exaggerated Minimum Ascending Value of 20 points for demonstration.

Note:
1.  Multiplier is a descending mask from the top of the font ribbon.
2.  Minimum is an ascending mask from the bottom of the font ribbon.
     The font ribbon can be sized to greater than the minimum, and the
     minimum setting will be ignored.
3.  Maximum is an ascending mask from the bottom of the font ribbon.
     The font ribbon can be sized to greater than the maximum, but the
     ribbon will be clipped at the maximum setting.
4.  It is because the Minimum and Maximum settings are ascending that
     they assist with fonts that have high ascendance and elevated symbols.
« Last Edit: March 31, 2017, 02:01:40 pm by rick2691 »
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit