Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify applying of bold and italic fonts #180

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

bjorn
Copy link
Contributor

@bjorn bjorn commented Mar 17, 2023

We can actually use QTextCharFormat::setFont, but we need to pass QTextCharFormat::FontPropertiesSpecifiedOnly to avoid overriding all properties.

This works fine in Notes, but you may want to make sure this also works in the context of QOwnNotes before merging this.

Small follow-up to #179.

fmt.setFont(_formats[StUnderline].font());
fmt.setFontUnderline(_formats[StUnderline].fontUnderline());
} else if (_formats[Bold].font().bold())
fmt.setFontWeight(QFont::Bold);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer necessary, because this is already covered by the setFont above.

@@ -289,7 +289,6 @@ void MarkdownHighlighter::initTextFormats(int defaultFontSize) {
_formats[H5] = format;
format.setFontPointSize(defaultFontSize * 1.1);
_formats[H6] = format;
format.setFontPointSize(defaultFontSize);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was superfluous because the changed format is overridden by the next line.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the FontPointSize set?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, format = QTextCharFormat();, ok

@pbek
Copy link
Owner

pbek commented Mar 17, 2023

It would be hard to guess what side effects that has...

@bjorn
Copy link
Contributor Author

bjorn commented Mar 17, 2023

It would be hard to guess what side effects that has...

Yeah, it has the side effect that it might set more font properties apart from just the family and the bold/italic, provided those have been set on the font of the format that is being applied (which, at least in the highlighter constructor, doesn't happen). I thought it was a nice simplification of the code.

It actually brings the code back to the state just before b6bea15, with the main difference that it addresses the issues of all the changes that were made afterwards in a much simpler way.

@tim-gromeyer
Copy link
Contributor

Will this get merged? Simplifying the code seems like a good idea to me

@pbek
Copy link
Owner

pbek commented Sep 24, 2023

Yeah, it has the side effect that it might set more font properties apart from just the family and the bold/italic

I still don't want to deal with the regressions in QOwnNotes. 😅

@bjorn
Copy link
Contributor Author

bjorn commented Sep 25, 2023

I still don't want to deal with the regressions in QOwnNotes. 😅

Maybe I can deal with them, but did you notice any?

@pbek
Copy link
Owner

pbek commented Sep 25, 2023

Maybe I can deal with them, but did you notice any?

Usually they would creep up for certain fonts on certain operating systems, so it's hard to test.

@pbek
Copy link
Owner

pbek commented Sep 25, 2023

And it would need lots of testing to see if all permutations of schema settings still work with different fonts on different operating system when not parts of the font settings are set, but everything...

@pbek
Copy link
Owner

pbek commented Sep 25, 2023

But even before those tests and the need to rebase this PR on main, because it's far behind it, I already get lots of [warning] QFont::fromString: Invalid description 'Noto Sans,14,-1,5,400,0,0,0,0,0,0,0,0,0,0,1,Regular' ...

We can actually use QTextCharFormat::setFont, but we need to pass
QTextCharFormat::FontPropertiesSpecifiedOnly to avoid overriding
all properties.
@bjorn
Copy link
Contributor Author

bjorn commented Sep 25, 2023

@pbek I've rebased the patch.

Regarding the warning you're seeing, do you think this is somehow related to this PR? What are you doing to get this warning?

@pbek
Copy link
Owner

pbek commented Sep 25, 2023

@pbek I've rebased the patch.

thank you

Regarding the warning you're seeing, do you think this is somehow related to this PR? What are you doing to get this warning?

When I pull in the PR I get this warning many dozen times when I just start the application...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants