PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

PdfSharpCore.Utils.FontResolver code cleanup, refactor

Open MichelMichels opened this issue 2 years ago • 1 comments

As I was working on the previous support for the local AppData fonts in Windows, I noticed that the code was a bit 'old'. Things I changed:

  • Swapped the static constructor with a default constructor and make use of a static _isInitialized field to check if another instance already has loaded the fonts
  • Swapped the Dictionary<string, FontFamilyModel> with a List<FontFamilyModel> and make use of LINQ to lookup the fonts
  • Extracted the struct FontFileInfo to its own file in PdfSharpCore.Utils
  • Renaming of a lot of properties/fields
  • Style fixes

There were no tests, so I couldn't check if this breaks something. I did do a quick check with the font families from the issue in PR #267 and this worked like expected.

MichelMichels avatar Jun 08 '22 19:06 MichelMichels

Codecov Report

Merging #268 (91c7cd5) into master (2828a90) will increase coverage by 0.00%. The diff coverage is 56.80%.

@@           Coverage Diff           @@
##           master     #268   +/-   ##
=======================================
  Coverage   26.62%   26.63%           
=======================================
  Files         238      239    +1     
  Lines       23336    23360   +24     
  Branches     2809     2811    +2     
=======================================
+ Hits         6214     6221    +7     
- Misses      16629    16643   +14     
- Partials      493      496    +3     
Impacted Files Coverage Δ
PdfSharpCore/Internal/FontFamilyModel.cs 40.00% <ø> (ø)
PdfSharpCore/Utils/FontResolver.cs 46.93% <49.53%> (-9.80%) :arrow_down:
PdfSharpCore/Utils/FontFileInfo.cs 100.00% <100.00%> (ø)

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 2828a90...91c7cd5. Read the comment docs.

codecov-commenter avatar Jun 08 '22 19:06 codecov-commenter