pgaskin / NickelMenu

The easiest way to launch scripts, change settings, and run actions on Kobo e-readers.
https://pgaskin.net/NickelMenu
MIT License
555 stars 28 forks source link

Formatting of the cmd_output for Cyrilic symbols #134

Open degiz opened 1 year ago

degiz commented 1 year ago

Hey @pgaskin

When I use cmd_output to run a command that returns Cyrillic symbols, the formatting looks different than for Latin ones (attached photo). To me, it looks like there's a space inserted after every letter.

My use case is to print translations received from DeepL, and all the available screen real estate matters 😅

Is it possible to display the Cyrillic symbols without offsets?

IMG_8952

NiLuJe commented 1 year ago

UTF-16 shenanigans?

degiz commented 1 year ago

You can reproduce that using a UTF-8 encoded config file

menu_item :selection_search :Test Cyrillic :cmd_output :9999:echo 'Привет'

If that's a shenanigan issue, then I'm not sure what to do with it.

pgaskin commented 1 year ago

Can you upload (i.e., drag and drop into the attachment area) the syslog showing the execution of that item? Also, run the command manually, redirecting (not copy-pasting) the output into a file, and upload that too.

degiz commented 1 year ago

Hey @pgaskin

My config:

menu_item :main :Test russian :cmd_output :9999:echo 'Привет'
menu_item :main :Dump Syslog :cmd_spawn :logread > /mnt/onboard/.adds/syslog_bug.log

What I did:

Attaching the syslog_bug.log, I only stripped the first lines with book names.

Thanks a lot for looking into this!

syslog_bug.log

jackiew1 commented 1 year ago

This looks very similar to problems we've seen before when Cyrillic is used as part of the GUI. I think it's caused when the GUI is trying to use Cyrillic in a widget which is expecting to use the built-in default sans-serif font, Avenir.

I'm not sure whether it's because the Cyrillic glyphs in Kobo's version of Avenir are useless or whether it's because the Kobo can't find any Cyrillic glyphs and uses a fallback font instead, which will probably by one of the built-in CJK fonts.

Whatever the reason, one way it can be "fixed" is by replacing the default system 'Avenir Next' with a font better suited to Cyrillic. On my own devices I've replaced Avenir with a copy of Calibri masquerading as 'Avenir Next'. I didn't do this because I need Cyrillic but I have just tested menu_item :main :Test russian :cmd_output :9999:echo 'Привет' in NickelMenu and the output looks fine to me, i.e. no "double spacing" effect.

ETA: If NickelMenu could (optionally???) force the cmd_output widget to use Georgia instead, that might also work.

n3w6i3 commented 1 year ago

Hey @pgaskin

When I use cmd_output to run a command that returns Cyrillic symbols, the formatting looks different than for Latin ones (attached photo). To me, it looks like there's a space inserted after every letter.

My use case is to print translations received from DeepL, and all the available screen real estate matters 😅

Is it possible to display the Cyrillic symbols without offsets?

IMG_8952

Hi, would you be so kind and share the line you used to get this output of translation. Are you using KOreader or anything similar or is this a device native reader?

degiz commented 1 year ago

Hey @n3w6i3 I'm using the following command:

menu_item :selection_search :DeepL Translation :cmd_output :9999:/usr/bin/wget --header='Authorization: DeepL-Auth-Key $MY_KEY' --post-data='target_lang=RU&text={1|S|%}' -qO - https://api-free.deepl.com/v2/translate | jq '.translations[0].text' | fold -s -w 55

No KOreader, pure Kobo + nickelmenu

n3w6i3 commented 1 year ago

Hey @n3w6i3 I'm using the following command:

menu_item :selection_search :DeepL Translation :cmd_output :9999:/usr/bin/wget --header='Authorization: DeepL-Auth-Key $MY_KEY' --post-data='target_lang=RU&text={1|S|%}' -qO - https://api-free.deepl.com/v2/translate | jq '.translations[0].text' | fold -s -w 55

No KOreader, pure Kobo + nickelmenu

I tried it (used my api key) but i get the following message instead of translation: /bin/sh: jq: not found... any idea how to solve it?

NiLuJe commented 1 year ago

I ship it as part of my KoboStuff bundle of tools, so I imagine @degiz has that installed ;).

n3w6i3 commented 1 year ago

I ship it as part of my KoboStuff bundle of tools, so I imagine @degiz has that installed ;).

Thank you all, it works like a charm 😁

EdNanda commented 1 year ago

I ship it as part of my KoboStuff bundle of tools, so I imagine @degiz has that installed ;).

Thank you all, it works like a charm 😁

Wait, so how did you fix it?

n3w6i3 commented 1 year ago

I ship it as part of my KoboStuff bundle of tools, so I imagine @degiz has that installed ;).

Thank you all, it works like a charm 😁

Wait, so how did you fix it?

By installing the whole package from NiLuJe.

EdNanda commented 1 year ago

By installing the whole package from NiLuJe.

Ahhh I get it, rookie mistake. Now it works, this is very cool! Thanks :D

Eikthyrnir commented 8 months ago

@degiz Hi! Have you fixed it? Does replacing the default system 'Avenir Next' with something like 'Calibri' helped you? If so, how can I do it? Even after fixing 'double spacing' effect I still have a problem: Cyrillic (latin works as should) symbols at the end of the line are disappearing sometimes (pretty often but not always). E.g. with the longer text: echo "\"Давай сходим в парк,\" - предложил Даниил, улыбаясь. \"Почему бы и нет,\" - согласилась Наташа, радостно кивнув. Они вышли из дома и направились к парку, наслаждаясь свежим воздухом. \"Какой замечательный день,\" - восхищенно вздохнула Наташа, глядя на яркое солнце. \"А вот и городское озеро,\" - указал Даниил, указывая на водную гладь. Они прогуливались, наслаждаясь природой и обществом друг друга. \"Скоро будем здесь снова,\" - обещала Наташа, улыбаясь своему другу. \"Да, это было замечательно,\" - согласился Даниил, чувствуя прилив счастья." | fold -s -w 50 @jackiew1 maybe you can also test it in your enviroment

P.S. if you replace spaces (" ") with "_" for example, no characters will be missing

photo_2024-01-27_01-28-42