brechtm / rinohtype

The Python document processor
http://www.mos6581.org/rinohtype
GNU Affero General Public License v3.0
504 stars 61 forks source link

Improve Unicode support #308

Closed jemrobinson closed 2 years ago

jemrobinson commented 2 years ago

Allow for fonts using Unicode ID 4 (Unicode 2.0 or later semantics with non-BMP characters allowed)

Closes #307

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

codecov[bot] commented 2 years ago

Codecov Report

Merging #308 (f280556) into master (a4396a7) will decrease coverage by 0.00%. The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #308      +/-   ##
==========================================
- Coverage   76.39%   76.38%   -0.01%     
==========================================
  Files          92       92              
  Lines       14417    14421       +4     
  Branches     2025     2025              
==========================================
+ Hits        11014    11016       +2     
- Misses       2973     2975       +2     
  Partials      430      430              
Flag Coverage Δ
3.10.0-alpha 75.94% <50.00%> (-0.01%) :arrow_down:
3.6 75.47% <50.00%> (-0.01%) :arrow_down:
3.7 75.47% <50.00%> (-0.01%) :arrow_down:
3.8 75.89% <50.00%> (-0.01%) :arrow_down:
3.9 76.35% <50.00%> (-0.01%) :arrow_down:
Linux 75.91% <50.00%> (-0.01%) :arrow_down:
Windows 75.78% <50.00%> (-0.01%) :arrow_down:
macOS 76.24% <50.00%> (+<0.01%) :arrow_up:
pypy-3.7 75.51% <50.00%> (-0.01%) :arrow_down:
regression-3.10 74.29% <50.00%> (-0.01%) :arrow_down:
regression-3.6 73.79% <50.00%> (-0.01%) :arrow_down:
regression-3.7 73.79% <50.00%> (-0.01%) :arrow_down:
regression-3.8 74.25% <50.00%> (-0.01%) :arrow_down:
regression-3.9 74.71% <50.00%> (-0.01%) :arrow_down:
regression-pypy3 73.83% <50.00%> (-0.01%) :arrow_down:
unit-3.10 47.07% <16.66%> (-0.01%) :arrow_down:
unit-3.6 45.94% <16.66%> (-0.01%) :arrow_down:
unit-3.7 45.94% <16.66%> (-0.01%) :arrow_down:
unit-3.8 47.08% <16.66%> (-0.01%) :arrow_down:
unit-3.9 47.08% <16.66%> (-0.01%) :arrow_down:
unit-pypy3 45.96% <16.66%> (-0.01%) :arrow_down:

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

Impacted Files Coverage Δ
src/rinoh/backend/pdf/cos.py 86.66% <50.00%> (-0.22%) :arrow_down:
src/rinoh/font/opentype/__init__.py 71.23% <50.00%> (+0.19%) :arrow_up:

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 a4396a7...f280556. Read the comment docs.

brechtm commented 2 years ago

Thanks for your contribution!

Do you have a (preferably free) font that I can test this with?

jemrobinson commented 2 years ago

Sorry @brechtm - only just saw this comment. I made a typeface package for Symbola (licence: free for any use) which is available on PyPI as rinoh-typeface-symbola. If you download Symbola from this link, you will also get a PDF that lists all the available glyphs and their associated numbers.

brechtm commented 2 years ago

Sorry @brechtm - only just saw this comment. I made a typeface package for Symbola (licence: free for any use)

Thanks! I've been trying to get some emoji fonts working, but there were some additional issues with those. I'll try the Symbola font.

I should note that the official home for that font says: Free use of UFAS is strictly limited to personal use. The site you linked to offers version 9 for download, which is indeed free for any use. The included PDF doesn't mention anything about distribution though, so perhaps you should check with the author whether it's ok to package the font for distribtion on PyPI.

If you would want to create a package for the latest version, you could print the terms of the license when the font module is loaded by adding print calls in the font's __init__.py. This will be printed when rinohtype renders the document. For example

print('----------------------------------------------------------------------')
print('Symbola, version 13.00, march 2020 by George Douros\n'
      'free strictly for personal, non-commercial use\n'
      'available under the general ufas licence\n'
      'Unicode Fonts for Ancient Scripts')
print('----------------------------------------------------------------------')

It could be interesting to offer both versions on PyPI (provided the author is ok with distribution on PyPI). Perhaps even in the same package? However, I'm not sure how we would differentiate between them in rinohtype.