Equation font in TfrmRVMathEditor: strange behavior
Equation font in TfrmRVMathEditor: strange behavior
Hi,
a question about TfrmRVMathEditor. If I get you right, method Init after opening this form sets values of the "Font > Default values" section. But what about values in "Font > This equation" section? If I just set individual properties, then OK — these properties apply to the equation. But when I reopen form, this properties are not shown (Font, Size, Text color — empty). Also, when I save and reload RVF through the stream, equation properties are reset to the default values, and section "This equation" also empty.
I would like to better understand the logic of the form and how to save/load individual font properties of equation(s).
a question about TfrmRVMathEditor. If I get you right, method Init after opening this form sets values of the "Font > Default values" section. But what about values in "Font > This equation" section? If I just set individual properties, then OK — these properties apply to the equation. But when I reopen form, this properties are not shown (Font, Size, Text color — empty). Also, when I save and reload RVF through the stream, equation properties are reset to the default values, and section "This equation" also empty.
I would like to better understand the logic of the form and how to save/load individual font properties of equation(s).
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Equation font in TfrmRVMathEditor: strange behavior
Do you use this form separately from action? Normally, this form is called by TrvActionInsertEquation (for insertion) and TrvActionItemProperties (for changing).
TrvActionItemProperties calls form.SetItem, then shows the form, then calls form.GetItem.
SetItem/GetItem process this equation font properties.
Sorry, I cannot reproduce the problem, both with the dialog and with RVF saving. I tried with the compiled ActionTest demo from https://www.trichview.com/download/demo.html
What TRichView version do you use? If it is not the newest version, please upgrade.
If you use the newest version, please give me step-by-step instructions or a simple project to reproduce the problems.
TrvActionItemProperties calls form.SetItem, then shows the form, then calls form.GetItem.
SetItem/GetItem process this equation font properties.
Sorry, I cannot reproduce the problem, both with the dialog and with RVF saving. I tried with the compiled ActionTest demo from https://www.trichview.com/download/demo.html
What TRichView version do you use? If it is not the newest version, please upgrade.
If you use the newest version, please give me step-by-step instructions or a simple project to reproduce the problems.
Re: Equation font in TfrmRVMathEditor: strange behavior
Thanks Sergey, the situation cleared up a bit.
Indeed, instead of TrvActionItemProperties I used TrvActionInsertEquation. Action TrvActionItemProperties works fine, but there is one problem: if equation contained an error symbol, editor form will show an empty string. This happens in method SetItem, line "Memo1.Lines.Text := Item.Text;".
Is it possible to make an erroneous equation editable in this form?
P. S. Question with RVF is solved automatically)
Indeed, instead of TrvActionItemProperties I used TrvActionInsertEquation. Action TrvActionItemProperties works fine, but there is one problem: if equation contained an error symbol, editor form will show an empty string. This happens in method SetItem, line "Memo1.Lines.Text := Item.Text;".
Is it possible to make an erroneous equation editable in this form?
P. S. Question with RVF is solved automatically)
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Equation font in TfrmRVMathEditor: strange behavior
I think that disabling OK button for incorrect equations would be a better solution.
(
TRVMathItemInfo's Text provides access to TRVMathItemInfo's Equation.Text, where Equation is TMathEquation.
TMathEquation is implemented by Adit and I do not want to change it. It does not allow to assign incorrect Text. So the problem with empty text instead of incorrect text occurs when assigning from memo to math item, not from math item to memo.
)
(
TRVMathItemInfo's Text provides access to TRVMathItemInfo's Equation.Text, where Equation is TMathEquation.
TMathEquation is implemented by Adit and I do not want to change it. It does not allow to assign incorrect Text. So the problem with empty text instead of incorrect text occurs when assigning from memo to math item, not from math item to memo.
)
Re: Equation font in TfrmRVMathEditor: strange behavior
Hmm, but if the user wants to return to editing equation later? Maybe I need to create descendant class of TRVMathItemInfo, save equation text in a separate property and use it in the TfrmRVMathEditor?
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Equation font in TfrmRVMathEditor: strange behavior
Ok, in the next update, it will be possible to get and set erroneous text in TRVMathItemInfo, without exceptions.
Re: Equation font in TfrmRVMathEditor: strange behavior
it will be great!Sergey Tkachenko wrote: ↑Wed Sep 25, 2019 10:37 am Ok, in the next update, it will be possible to get and set erroneous text in TRVMathItemInfo, without exceptions.
Sergey, I want to ask also about TrvActionInsertEquation: this action does not call the methods SetItem/GetItem, only Init method? If "Font > This equation" properties are "empty" in TfrmRVMathEditor, does this mean that the equation always uses only default settings?
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Equation font in TfrmRVMathEditor: strange behavior
It does not use SetItem (because there is no existing item to set to the form), it does not use GetItem (because it uses GetNewItem instead)
Re: Equation font in TfrmRVMathEditor: strange behavior
Sergey, one more question. When loading a document from a stream using InsertRVFFromStream (not LoadRVFFromStream) equations are rolled back to the original formatting. I read the help about DocObjects and the idea is clear, but I need to use InsertRVFFromStream due to working with styles templates. What do you recommend that math equation formatting (and other DocObjects) load correctly in my case?
Now I use next scheme:
Edit.Clear;
Edit.LoadRVFFromStream(Data.RVF);
Edit.Format;
Edit.SelectAll;
Edit.DeleteSelection;
Data.RVF.Position := 0;
if Edit.InsertRVFFromStream(Data.RVF, 0) then
Edit.Format;
Maybe there is a simpler way to load doc properties, without LoadRVFFromStream?
Now I use next scheme:
Edit.Clear;
Edit.LoadRVFFromStream(Data.RVF);
Edit.Format;
Edit.SelectAll;
Edit.DeleteSelection;
Data.RVF.Position := 0;
if Edit.InsertRVFFromStream(Data.RVF, 0) then
Edit.Format;
Maybe there is a simpler way to load doc properties, without LoadRVFFromStream?
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Equation font in TfrmRVMathEditor: strange behavior
Yes, insertion methods ignore "default equation settings", inserted equation use settings of the target document.
Your code is correct.
Your code is correct.
Re: Equation font in TfrmRVMathEditor: strange behavior
Thanks, Sergey!
I try to create my own form to set default equation settings and see that in TfrmRVMathEditor.FormCreate comboboxes initiates with 'Arial' font. Is this correct or I need to set init values 'Cambria Math'?
I try to create my own form to set default equation settings and see that in TfrmRVMathEditor.FormCreate comboboxes initiates with 'Arial' font. Is this correct or I need to set init values 'Cambria Math'?
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Equation font in TfrmRVMathEditor: strange behavior
'Arial' cannot be used as font for equations. Only special math fonts can be used. See TRVMathItemInfo.FontName
Re: Equation font in TfrmRVMathEditor: strange behavior
Yeah, I know that, but the original code in RVMathEditorFrm.pas just confused me)Sergey Tkachenko wrote: ↑Fri Sep 27, 2019 7:53 pm 'Arial' cannot be used as font for equations. Only special math fonts can be used
procedure TfrmRVMathEditor.FormCreate(Sender: TObject);
begin
...
cmbFontSize.FontName := 'Arial';
cmbDefFontSize.FontName := 'Arial';
end;
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Equation font in TfrmRVMathEditor: strange behavior
This font name is assigned for combo boxes that display font sizes. If you assign any TrueType font to their FontName property, they are initialized with predefined set of font sizes. So Arial is as good as any other TT font.
All math fonts are TT fonts.
All math fonts are TT fonts.