SixLabors / Fonts

:black_nib: Font loading and layout library.
https://sixlabors.com/products/fonts
Other
308 stars 71 forks source link

Implement UAX 50 to allow Vertical Mixed layout of text. #327

Closed JimBobSquarePants closed 1 year ago

JimBobSquarePants commented 1 year ago

Prerequisites

Description

Provides an implementation of Unicode Standard Annex #50 Unicode Vertical Text Layout

There's a lot going on here.

Here's some of the output.

Note. I performed various comparisons across different browsers and Microsoft Word. As expected, they all had their own slight twist on where exactly the decorators should be rendered for vertical fonts. It seems the ones in the font themselves are ignored. I based my implementation on the Chromium implementation however I am using the horizontal metrics for rotated horizontal fonts as they are still correctly relative to the baseline.

I had to do a local update to ImageSharp.Drawing to update the renderers there to handle vertical decorators but I will do a follow up PR to handle that.

Mixed English and Japanese using Segoi UI and Microsoft YaHei (TTF)

Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese

Mixed English and Emoji using Segoe UI and Segoe UI Emoji

The quick👩🏽‍🚒 brown fox jumps over the lazy dog

Mixed English and Japanese using Source Sans ProI and Microsoft YaHei (CFF)

Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese 日本語 Japanese

codecov[bot] commented 1 year ago

Codecov Report

Merging #327 (33186a2) into main (2a7c8a9) will decrease coverage by 1%. The diff coverage is 72%.

@@          Coverage Diff           @@
##            main    #327    +/-   ##
======================================
- Coverage     83%     83%    -1%     
======================================
  Files        224     227     +3     
  Lines      12437   12838   +401     
  Branches    1792    1844    +52     
======================================
+ Hits       10420   10734   +314     
- Misses      1597    1663    +66     
- Partials     420     441    +21     
Flag Coverage Δ
unittests 83% <72%> (-1%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/SixLabors.Fonts/FontMetrics.cs 100% <ø> (ø)
src/SixLabors.Fonts/FontRectangle.cs 95% <ø> (+5%) :arrow_up:
src/SixLabors.Fonts/Glyph.cs 100% <ø> (ø)
...nts/Tables/AdvancedTypographic/GPos/AnchorTable.cs 33% <0%> (-2%) :arrow_down:
src/SixLabors.Fonts/TextRenderer.cs 100% <ø> (ø)
...ode/Resources/VerticalOrientationTrie.Generated.cs 100% <ø> (ø)
src/SixLabors.Fonts/GlyphMetrics.cs 60% <13%> (-13%) :arrow_down:
src/SixLabors.Fonts/Font.cs 53% <33%> (-1%) :arrow_down:
...bors.Fonts/Tables/AdvancedTypographic/GPosTable.cs 84% <50%> (+<1%) :arrow_up:
src/SixLabors.Fonts/GlyphRendererParameters.cs 60% <60%> (+1%) :arrow_up:
... and 24 more

... and 1 file with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more