Font Styles Don't Display

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
ThisIsMeAndIAmHere
Level 2
Level 2
Posts: 70
Joined: Thu Oct 01, 2020 1:21 pm

Font Styles Don't Display

Post by ThisIsMeAndIAmHere »

When I run a JavaFX program, the font styles in the HTMLEditor control (like a rich text box formatted with HTML) doesn't display italic text (and I know it's supposed to be italic because if I click in it the "I" button is selected), but it displays other styles like bold and underline.

If I run a .NET Win Forms using Mono a rich text box won't even display bold or italic text (though it will still underline).

What could be wrong? I've written these programs, so I can edit the code if necessary.
User avatar
Welcome
Level 5
Level 5
Posts: 508
Joined: Wed Aug 19, 2020 11:38 am

Re: Font Styles Don't Display

Post by Welcome »

In my experience, most programming languages require you to load fonts.
https://www.tutorialspoint.com/javafx/javafx_text.htm
Position and Font of the Text

By default, the text created by text class is of the font…, size…, and black in color.

You can change the font size and color of the text using the setFont() method. This method accepts an object of the Font class.

The class named Font of the package javafx.scene.text is used to define the font for the text. This class contains a static method named font().

This method accepts four parameters namely −

family − This is of a String type and represents the family of the font that we want to apply to the text.

weight − This property represents the weight of the font. It accepts 9 values, which are − FontWeight.BLACK, FontWeight.BOLD, FontWeight.EXTRA_BOLD, FontWeight.EXTRA_LIGHT, LIGHT, MEDIUM, NORMAL, SEMI_BOLD, THIN.

posture − This property represents the font posture (regular or italic). It accepts two values FontPosture.REGULAR and FontPosture.ITALIC.

size − This property is of type double and it represents the size of the font.
I assume you've checked and the font you're using DOES have an Italic variation. I know, I shouldn't assume....
ThisIsMeAndIAmHere
Level 2
Level 2
Posts: 70
Joined: Thu Oct 01, 2020 1:21 pm

Re: Font Styles Don't Display

Post by ThisIsMeAndIAmHere »

I'll look into that. I thought pretty much all standard fonts allow for italic (and bold, for that matter, because Mono doesn't seem to be showing that either), but the thing is that I'm formatting the text individually (with <i> tags or with \i in the case of RTF), not as a general font format to apply to the whole string of text. And when I run the exact same programs in Windows they work fine (I'm sorry if I forgot to mention that).

EDIT: Also, I just checked your link and it's talking about a Text object, so I don't know whether the same things apply to an HTMLEditor object, but that's something to keep in mind. Anyway, I'll read it in case it's applicable. I'll try the FontPosture stuff, etc. though.
Last edited by ThisIsMeAndIAmHere on Fri Oct 16, 2020 1:52 pm, edited 1 time in total.
User avatar
Welcome
Level 5
Level 5
Posts: 508
Joined: Wed Aug 19, 2020 11:38 am

Re: Font Styles Don't Display

Post by Welcome »

ThisIsMeAndIAmHere wrote:
Fri Oct 16, 2020 1:37 pm
EDIT: Also, I just checked your link and it's talking about a Text object, so I don't know whether the same things apply to an HTMLEditor object, but that's something to keep in mind. Anyway, I'll read it in case it's applicable.
Might not apply. I'm not familiar with the HTMLEditor object; I've just learned the hard way to always check the loading the fonts.
User avatar
Welcome
Level 5
Level 5
Posts: 508
Joined: Wed Aug 19, 2020 11:38 am

Re: Font Styles Don't Display

Post by Welcome »

I had one other thought. Have you installed MS fonts? Does the HTMLEditor control list MS fonts or Linux fonts? The examples I've seen online all show MS fonts. If it's looking for MS fonts, it might be having a hard time translating that into Linux fonts.
ThisIsMeAndIAmHere
Level 2
Level 2
Posts: 70
Joined: Thu Oct 01, 2020 1:21 pm

Re: Font Styles Don't Display

Post by ThisIsMeAndIAmHere »

Well I did install them actually, but it didn't seem to have any effect. I did it because of another problem that I was having in which the fonts are a different size in Windows than in Linux, so it was cutting off text labels in Linux because they were too long.

Anyway, I fixed the font style problem by wrapping the text in a font tag to always display everything in Arial, which seems to show the styles fine.

At least that's what I did for JavaFX. I have another idea for .NET/Mono but I haven't tried it yet.
User avatar
Welcome
Level 5
Level 5
Posts: 508
Joined: Wed Aug 19, 2020 11:38 am

Re: Font Styles Don't Display

Post by Welcome »

ThisIsMeAndIAmHere wrote:
Sat Oct 17, 2020 1:00 pm
I fixed the font style problem by wrapping the text in a font tag to always display everything in Arial, which seems to show the styles fine.

At least that's what I did for JavaFX. I have another idea for .NET/Mono but I haven't tried it yet.
Great news! I'd be interested in what you do for .NET/Mono ... please update when you can!
ThisIsMeAndIAmHere
Level 2
Level 2
Posts: 70
Joined: Thu Oct 01, 2020 1:21 pm

Re: Font Styles Don't Display

Post by ThisIsMeAndIAmHere »

I've been looking into Mono, and frankly I have NO idea how to do it. I've even written text with various styles (italic, bold, underline) in LibreOffice, selected the text and set it to various common fonts including Arial and Times New Roman, copied it, pasted it in and it wouldn't preserve formatting except for the underlining (which I guess is pretty easy for it to do).

I've also saved the RTF file, then opened it in Xed, copied all of the text with formatting instructions (or whatever RTF calls that stuff), pasted it into a text area in an experimental C# program that I made to test it, and clicked a button that I programmed the copy whatever text is in that and then set it into the Rtf property of the rich text box, but when it does, it only preserves the underlining, but never the italic or bold text.

So at this point I'm totally out of ideas for Mono text formatting.
Post Reply

Return to “Newbie Questions”