Can not subset embed fonts for a epub with "wide" Unicode char

Bug #1811224 reported by lishuode
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

When I try to subset a embed a epub file, it failed. The problem is that the epub file contains a character which is U+22FF1, not in the Unicode 0 plane, but in the 2 plane. Thus the ord() function in Python2 can not handle it, which documented at https://docs.python.org/2/library/functions.html#ord .
I raised two idea here,
1. Use a special calibre_ord function(if we have) to instead the ord, this calibre_ord can handle the 1-17 plane of Unicode specially.
2. According to https://www.python.org/dev/peps/pep-0261/ , we can use python bits which complied with --enable-unicode=ucs4.

What's your idea?

Thanks,
Shuode Li

Here is the error details.

calibre, version 3.37.0
ERROR: Unhandled exception: <b>TypeError</b>:ord() expected a character, but string of length 2 found

calibre 3.37 [64bit] embedded-python: True is64bit: True
Windows-10-10.0.17763-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.17763')
Python 2.7.12+
Windows: ('10', '10.0.17763', 'SP0', u'Multiprocessor Free')
Interface language: None
Traceback (most recent call last):
  File "site-packages\calibre\gui2\tweak_book\boss.py", line 562, in polish
  File "site-packages\calibre\ebooks\oeb\polish\main.py", line 284, in tweak_polish
  File "site-packages\calibre\ebooks\oeb\polish\main.py", line 215, in polish_one
  File "site-packages\calibre\ebooks\oeb\polish\subset.py", line 69, in subset_all_fonts
  File "site-packages\calibre\utils\fonts\sfnt\subset.py", line 111, in subset
TypeError: ord() expected a character, but string of length 2 found

Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
Revision history for this message
lishuode (lishuode) wrote :

Awesome for the response time. Thanks so much Kovid

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.