Hi,
We used to load HTML то TRichView THtmlViewer component.
It has such properties as DefBackground, DefFontName, DefFontSize.
Now we try to use new method LoadHTMLFromStream.
Is there any possibility to specify default style for LoadHTMLFromStream?
LoadHTMLFromStream question
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: LoadHTMLFromStream question
There is a global singleton object in RVDefReadProps unit (or fmxRVDefReadProps in FireMonkey version): RVDefaultLoadProperties.
It defines default properties for reading HTML and Markdown, for all TRichView and ScaleRichView controls.
Font names
RVDefaultLoadProperties has properties DefaultFontName and DefaultMonoSpacedFontName.
You can define more default fonts using GenericFontNames[] array property.
An index of this property can be one of values: rvgffRVDefault, rvgffSerif, rvgffSansSerif, rvgffMonospace, rvgffCursive, rvgffFantasy, rvgffSystemUI, rvgffUISerif, rvgffUISansSerif,r vgffUIMonospace, rvgffUIRrounded, rvgffEmoji, rvgffMath, rvgffFangsong, rvgffRVSymbols, rvgffRVBullets.
Most these values correspond to values of CSS font-family.
DefaultFontName simply provides access to GenericFontNames[rvgffRVDefault], DefaultMonoSpacedFontName to GenericFontNames[rvgffMonospace].
Font sizes
RVDefaultLoadProperties has property DefaultFontSizeDouble measured in half-points (default value is 24 meaning 12pt).
You can define more sizes using DefaultFontSizesDouble[] array property.
An index of this property can be one of values:
DefaultFontSizeDouble simply provides access to DefaultFontSizesDouble[rvfstDefault].
Background color
The default background color is hard-coded, clWindow (or white for FireMonkey).
Should I add a property?
It defines default properties for reading HTML and Markdown, for all TRichView and ScaleRichView controls.
Font names
RVDefaultLoadProperties has properties DefaultFontName and DefaultMonoSpacedFontName.
You can define more default fonts using GenericFontNames[] array property.
An index of this property can be one of values: rvgffRVDefault, rvgffSerif, rvgffSansSerif, rvgffMonospace, rvgffCursive, rvgffFantasy, rvgffSystemUI, rvgffUISerif, rvgffUISansSerif,r vgffUIMonospace, rvgffUIRrounded, rvgffEmoji, rvgffMath, rvgffFangsong, rvgffRVSymbols, rvgffRVBullets.
Most these values correspond to values of CSS font-family.
DefaultFontName simply provides access to GenericFontNames[rvgffRVDefault], DefaultMonoSpacedFontName to GenericFontNames[rvgffMonospace].
Font sizes
RVDefaultLoadProperties has property DefaultFontSizeDouble measured in half-points (default value is 24 meaning 12pt).
You can define more sizes using DefaultFontSizesDouble[] array property.
An index of this property can be one of values:
Code: Select all
VALUE HTML SIZE CSS SIZE
rvfstDefault, // (used if unspecified)
rvfstXXSmall, // 1 xx-small
rvfstXSmall, // - x-small
rvfstSmall, // 2 small
rvfstMedium, // 3 medium
rvfstLarge, // 4 large
rvfstXLarge, // 5 x-large
rvfstXXLarge, // 6 xx-large
rvfstXXXLarge); // 7 xxx-large
Background color
The default background color is hard-coded, clWindow (or white for FireMonkey).
Should I add a property?
Re: LoadHTMLFromStream question
Sergey, thank you for your prompt reply!
Your advice helped me, but not completely.
I try set
but in some cases after loading the html the font still stay 'Times New Roman'.
I tried to see what was going on under the debugger and I think I found the problem.
In method TRVHTMLLoader.GetCurrentRVTextStyle (unit RVHtmlLoad) there are these lines:
and HTMLStyle.FontFamilies always set 'Times New Roman'.
I may be doing something wrong and would appreciate your help.
Referring to background color, clWindow colour for background is fine with me.
Your advice helped me, but not completely.
I try set
Code: Select all
RVDefaultLoadProperties.DefaultFontName := 'Arial';
RVDefaultLoadProperties.DefaultMonoSpacedFontName := 'Arial';
I tried to see what was going on under the debugger and I think I found the problem.
In method TRVHTMLLoader.GetCurrentRVTextStyle (unit RVHtmlLoad) there are these lines:
Code: Select all
begin
HTMLStyle := FReader.CurrentStyle;
.......
Result.FontName := RVDefaultLoadProperties.GetFontName(HTMLStyle.FontFamilies);
end;
I may be doing something wrong and would appreciate your help.
Referring to background color, clWindow colour for background is fine with me.
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: LoadHTMLFromStream question
Answered here: viewtopic.php?p=42350#p42350
Re: LoadHTMLFromStream question
Thank you very much!
The fix solved my problem
The fix solved my problem
Re: LoadHTMLFromStream question
Good evening!
Everything is working fine, but there are a few minor remarks.
Previously, when using TRVHTMLViewImporter it was possible to call AppendHtmlViewer, which added data to the end of the document and worked with ReadOnly documents.
Now there is only InsertHTMLFromStreamEd method, which requires calling Format and MoveCaret methods and also scrolls the editor window down.
It would be nice to have an AppendHTMLFromStream method which would work like AppendRVFFromStream.
Everything is working fine, but there are a few minor remarks.
Previously, when using TRVHTMLViewImporter it was possible to call AppendHtmlViewer, which added data to the end of the document and worked with ReadOnly documents.
Now there is only InsertHTMLFromStreamEd method, which requires calling Format and MoveCaret methods and also scrolls the editor window down.
It would be nice to have an AppendHTMLFromStream method which would work like AppendRVFFromStream.
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: LoadHTMLFromStream question
Actually, LoadHTMLFromStream and LoadHTML append data to the end of the existing document (like similar methods for RTF, DocX, Markdown)
Re: LoadHTMLFromStream question
Thank you very much!
No further questions.
No further questions.