Skip to content

Conversation

@charlesroddie
Copy link
Collaborator

@charlesroddie charlesroddie commented Aug 4, 2020

Initial simplification in preparation for adding Font Styles

  • DoNothingFontChanger was removed was only used in tests.

For subsequent PR:

  • UnicodeFontChanger uses "mathematical bold/italic" ranges to use a single font for normal/bold/italic. To preserve existing functionality without deploying additional fonts, this logic needs to be kept when using standard fonts.
  • Allow users to add bold and italic fonts, for use in TextPainter. This PR will not address MathAtom fonts. If these fonts are present, they will be used instead of UnicodeFontChanger for rendering bold/italic fonts.

@charlesroddie charlesroddie changed the title Font styles [WIP] Font styles Aug 4, 2020
@Happypig375
Copy link
Collaborator

ancient LaTeX approach of using "mathematical bold/italic" ranges

Actually, LaTeX predates Unicode so it looks up font files of different styles. WpfMath does this: they have different fonts for the same codepoint that contain different styles. However, iosMath uses Latin Modern Math by default which combines all these fonts together into the mathematical glyph ranges, so we can use Unicode from top to bottom.

@charlesroddie
Copy link
Collaborator Author

Actually, LaTeX predates Unicode so it looks up font files of different styles. WpfMath does this: they have different fonts for the same codepoint that contain different styles. However, iosMath uses Latin Modern Math by default which combines all these fonts together into the mathematical glyph ranges, so we can use Unicode from top to bottom.

Interesting. WpfMath then ends up with a more convenient approach with fewer special cases but I think this PR can go ahead without changing that. We'll just need to preserve some degree of "font changing" for TextAtoms.

@charlesroddie
Copy link
Collaborator Author

Can you understand the test failures, or do you remember why there was a DoNothingFontChanger in the tests (before the changes in the cleanup so far) @Happypig375 ?

It would be nice to remove test failures before pushing the real work. I can't see any stated meaning of the tests so cannot evaluate. Presumably the tests were not testing actual behavior (since they required DoNothingFontChanger to pass) and so removing DoNothingFontChanger is a matter of hygiene so that the tests test real behaviour.

@Happypig375
Copy link
Collaborator

Can you understand the test failures, or do you remember why there was a DoNothingFontChanger in the tests (before the changes in the cleanup so far) @Happypig375 ?

It's just a mock for UnicodeFontChanger in TypesettingContext. It's a leftover from @verybadcat.

I can't see any stated meaning of the tests so cannot evaluate.

Yes, there are some tests that test the mocks themselves.

@Happypig375
Copy link
Collaborator

The test failures are related to using UnicodeFontChanger instead of DoNothingFontChanger. Since the text now have characters outside of the BMP, the difference in UTF16 length leads to different IndexRanges. Might have to check iosMath on its behaviour.

@Happypig375
Copy link
Collaborator

This anomaly can be traced all the way back here:

var innerRange = new Range(index, run.Length);
var textRun = new TextRunDisplay(
run,
innerRange,
table,
boundsProvider
);
textRuns.Add(textRun);

As far as I understand, ranges represent locations of atoms before finalization. However, here, it is not used in this way. Hmmm... Is this unintentional?

@Happypig375
Copy link
Collaborator

Definitely not correct. CSharpMath.Editor uses Ranges as input to constructing MathListIndexes. Ranges must represent locations of atoms and using text length instead is a logic error.

@charlesroddie
Copy link
Collaborator Author

charlesroddie commented Aug 29, 2020 via email

@Happypig375
Copy link
Collaborator

You mean UnicodeFontChangerTests?

@charlesroddie
Copy link
Collaborator Author

UnicodeFontChanger/Range tests.

@Happypig375
Copy link
Collaborator

Range tests are important since they are part of the atom output. Not part of the intermediate steps in creating atoms.

@Happypig375
Copy link
Collaborator

Alright, all tests now pass.

@Happypig375
Copy link
Collaborator

@charlesroddie I've changed UnicodeFontChangerTests so that they also test LaTeX->Display conversion instead of only testing UnicodeFontChanger.

@Happypig375 Happypig375 marked this pull request as ready for review September 6, 2020 06:41
@Happypig375
Copy link
Collaborator

@charlesroddie 2 outstanding reviews should be resolved for this to be mergable

@charlesroddie
Copy link
Collaborator Author

charlesroddie commented Sep 29, 2020

@Happypig375 Are the two things to be resolved the questions I asked about the tests?

@charlesroddie
Copy link
Collaborator Author

Can this be merged?

@Happypig375
Copy link
Collaborator

There are 2 unresolved conversations

@charlesroddie
Copy link
Collaborator Author

You understand the remaining conversation so can you mark if you consider it resolved?

@codecov-io
Copy link

Codecov Report

Merging #156 into master will decrease coverage by 24.98%.
The diff coverage is 98.34%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #156       +/-   ##
===========================================
- Coverage   86.81%   61.82%   -24.99%     
===========================================
  Files         157      254       +97     
  Lines       11275    20793     +9518     
===========================================
+ Hits         9788    12856     +3068     
- Misses       1487     7937     +6450     
Impacted Files Coverage Δ
CSharpMath.CoreTests/_Helpers/FrontEnd/TestFont.cs 100.00% <ø> (ø)
...th.CoreTests/_Helpers/FrontEnd/TestFontMeasurer.cs 100.00% <ø> (ø)
CSharpMath.Editor.Tests/IndexForPointTests.cs 99.86% <ø> (ø)
CSharpMath.Rendering/BackEnd/Glyph.cs 100.00% <ø> (+14.28%) ⬆️
CSharpMath.Rendering/BackEnd/Typefaces.cs 83.33% <ø> (+52.29%) ⬆️
CSharpMath.Rendering/BackEnd/TypesettingContext.cs 100.00% <ø> (ø)
CSharpMath/Atom/Range.cs 75.00% <ø> (ø)
CSharpMath/Display/FrontEnd/TypesettingContext.cs 100.00% <ø> (ø)
...reTests/_Helpers/FrontEnd/TestGlyphNameProvider.cs 81.81% <80.00%> (-18.19%) ⬇️
CSharpMath.CoreTests/FontChangingTests.cs 100.00% <100.00%> (ø)
... and 120 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 789b861...20f03b9. Read the comment docs.

@charlesroddie charlesroddie merged commit ed72190 into master Oct 21, 2020
@Atlantis433
Copy link

Charlie and whomever pay attention to the master here and I am here to tell you both that the house is due to be cleaned of the filth and chaos that you have done. You have many incorrect coding and you're not even close to be verified. The mit license doesn't belong to you at all it's mine. Your hatred is a terrible thing to have and I didn't do anything wrong for you to do this.

@Happypig375
Copy link
Collaborator

@Atlantis433 Do you have some problems that are unresolved? Especially the "The mit license doesn't belong to you at all it's mine.". Please write in a calm and understandable way so that we can resolve these issues separately.

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

Labels

Type/Housekeeping This includes internal only changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants