Settings dialog crashes with Japanese fonts

Bug #1667727 reported by m4984
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
The Mnemosyne Project
Fix Released
Undecided
Unassigned

Bug Description

I'm on Arch Linux and have the Google Noto fonts as default system fonts. In the preferences window on the tab 'Card appearance' when I click on 'Preview' or 'OK' the dialog crashes with the following error message:

###---

An unexpected error has occurred.
Please forward the following info to the developers:

Traceback (innermost last):
  File "/usr/lib/python3.6/site-packages/mnemosyne/pyqt_ui/configuration_wdgt_card_appearance.py", line 211, in preview
    render_chain.renderer_for_card_type(card_type).update(card_type)
  File "/usr/lib/python3.6/site-packages/mnemosyne/libmnemosyne/renderers/html_css.py", line 94, in update
    self.card_type_css(card_type, **render_args)
  File "/usr/lib/python3.6/site-packages/mnemosyne/libmnemosyne/renderers/html_css.py", line 71, in card_type_css
    family,size,x,x,w,i,u,s,x,x = font_string.split(",")
 ValueError: too many values to unpack (expected 10)

###---

Since I use these fonts as system default they are the default option in Mnemosyne as well. Took me a while to figure out that the fonts were the culprit...

Revision history for this message
Peter Bienstman (peter-bienstman) wrote :

Could you put a print(font_string) statement in html_css.py at line 71 and let me know the output? If you don't feel comfortable tinkering in the source, I can also send you a link to a debug version.

Revision history for this message
m4984 (m4984) wrote :

I'm not a coder so if you can send me either just the modified html_css.py file or a screenshot or code tag of how the modified file should look like, I'm more than happy to help.

I do get this error with all Japanese fonts btw. not just Noto.

Revision history for this message
m4984 (m4984) wrote :

This is the current file:

 67 # Font.
 68 font_string = self.config().card_type_property(\
 69 "font", card_type, proxy_fact_key)
 70 if font_string:
 71 family,size,x,x,w,i,u,s,x,x = font_string.split(",")
 72 css += "font-family: \"%s\"; " % family
 73 css += "font-size: %spt; " % size
 74 if w == "25":
 75 css += "font-weight: light; "
 76 if w == "75":
 77 css += "font-weight: bold; "
 78 if i == "1":
 79 css += "font-style: italic; "
 80 if i == "2":
 81 css += "font-style: oblique; "
 82 if u == "1":
 83 css += "text-decoration: underline; "
 84 if s == "1":
 85 css += "text-decoration: line-through; "
 86 css += "}\n"
 87 return css

m4984 (m4984)
summary: - Settings dialog crashes with Google Noto fonts
+ Settings dialog crashes with Japanese fonts
Revision history for this message
m4984 (m4984) wrote :
Download full text (3.3 KiB)

Think I figured it out. So this is the output:

Traceback (innermost last):
  File "/usr/lib/python3.6/site-packages/mnemosyne/pyqt_ui/configuration_wdgt_card_appearance.py", line 211, in preview
    render_chain.renderer_for_card_type(card_type).update(card_type)
  File "/usr/lib/python3.6/site-packages/mnemosyne/libmnemosyne/renderers/html_css.py", line 95, in update
    self.card_type_css(card_type, **render_args)
  File "/usr/lib/python3.6/site-packages/mnemosyne/libmnemosyne/renderers/html_css.py", line 72, in card_type_css
    family,size,x,x,w,i,u,s,x,x = font_string.split(",")
 ValueError: too many values to unpack (expected 10)
XmbTextListToTextProperty result code -2
XmbTextListToTextProperty result code -2
XmbTextListToTextProperty result code -2
Noto Sans [GOOG],12,-1,5,50,0,0,0,0,0,Regular
An unexpected error has occurred.
Please forward the following info to the developers:

Traceback (innermost last):
  File "/usr/lib/python3.6/site-packages/mnemosyne/pyqt_ui/configuration_dlg.py", line 54, in accept
    self.tab_widget.widget(index).apply()
  File "/usr/lib/python3.6/site-packages/mnemosyne/pyqt_ui/configuration_wdgt_card_appearance.py", line 206, in apply
    update(card_type)
  File "/usr/lib/python3.6/site-packages/mnemosyne/libmnemosyne/renderers/html_css.py", line 95, in update
    self.card_type_css(card_type, **render_args)
  File "/usr/lib/python3.6/site-packages/mnemosyne/libmnemosyne/renderers/html_css.py", line 72, in card_type_css
    family,size,x,x,w,i,u,s,x,x = font_string.split(",")
 ValueError: too many values to unpack (expected 10)
XmbTextListToTextProperty result code -2
XmbTextListToTextProperty result code -2
XmbTextListToTextProperty result code -2
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,16,-1,5,50,0,0,0,0,0
Sans Serif,1...

Read more...

Revision history for this message
m4984 (m4984) wrote :

It's the 'Regular' part of 'Noto Sans [GOOG],12,-1,5,50,0,0,0,0,0,Regular' that causes the error, I guess?

Revision history for this message
m4984 (m4984) wrote :

Ok, throwing out the last string value works for me as a workaround:

Added:

if len(font_string.split(",")) == 11:
    a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11 = font_string.split(",")
    font_string = a1 + "," + a2 + "," + a3 + "," + a4 + "," + a5 + "," + a6 + "," + a7 + "," + a8 + "," + a9 + "," + a10

in line 70 in html_css.py and in line 43 in html_css_card_browser.py

works for me now

Revision history for this message
Peter Bienstman (peter-bienstman) wrote :

For not being a coder you did a great job fixing this bug! Thanks, I'll add this to the next release.

Revision history for this message
m4984 (m4984) wrote :

Haha, thanks. Python was pretty verbose. Just had to fight a bit with the syntax (where I got a bit of help from a friend) and indentation...
Thank you for the quick reply and great job with the program!

Changed in mnemosyne-proj:
status: New → Fix Committed
Revision history for this message
m4984 (m4984) wrote :

just realized that I can't sync to android anymore, since the android client now throws the same error ;)

Revision history for this message
Peter Bienstman (peter-bienstman) wrote :
Revision history for this message
m4984 (m4984) wrote :

works beautifully. thank you!

Changed in mnemosyne-proj:
status: Fix Committed → Fix Released
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.