From 79a7d9885ffdae90c1ea8e2707f0c63955d247ad Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 17 May 2020 12:17:16 +0530 Subject: [PATCH] Now that there is a unicode symbol for half stars, use it --- imgsrc/calibreSymbols.spd | 40 +++++++++++++++--- resources/fonts/calibreSymbols.otf | Bin 3600 -> 3652 bytes src/calibre/ebooks/metadata/__init__.py | 2 +- .../gui2/preferences/create_custom_column.py | 2 +- src/calibre/utils/fonts/utils.py | 2 +- src/pyj/test_utils.pyj | 2 +- src/pyj/utils.pyj | 2 +- 7 files changed, 40 insertions(+), 10 deletions(-) diff --git a/imgsrc/calibreSymbols.spd b/imgsrc/calibreSymbols.spd index 391d95e509..28dac70d03 100644 --- a/imgsrc/calibreSymbols.spd +++ b/imgsrc/calibreSymbols.spd @@ -1,4 +1,4 @@ -SplineFontDB: 3.0 +SplineFontDB: 3.2 FontName: calibreSymbols FullName: calibre Symbols FamilyName: calibre Symbols @@ -22,7 +22,7 @@ OS2Version: 0 OS2_WeightWidthSlopeOnly: 0 OS2_UseTypoMetrics: 1 CreationTime: 1330331997 -ModificationTime: 1472969125 +ModificationTime: 1589697584 OS2TypoAscent: 0 OS2TypoAOffset: 1 OS2TypoDescent: 0 @@ -41,14 +41,14 @@ DEI: 91125 Encoding: UnicodeFull UnicodeInterp: none NameList: Adobe Glyph List -DisplaySize: -24 +DisplaySize: -72 AntiAlias: 1 FitToEm: 1 WidthSeparation: 150 -WinInfo: 0 152 34 +WinInfo: 11152 34 12 BeginPrivate: 0 EndPrivate -BeginChars: 1114112 4 +BeginChars: 1114112 5 StartChar: uni2605 Encoding: 9733 9733 0 @@ -177,6 +177,36 @@ SplineSet 452.702 647.221 458.162 649.834 466.134 649.834 c 4 474.454 649.834 466.134 74.71 466.134 74.71 c 1 EndSplineSet +Validated: 33 +EndChar + +StartChar: uni2BE8 +Encoding: 11240 11240 4 +Width: 979 +VWidth: -26 +Flags: W +LayerCount: 2 +Fore +SplineSet +466.134 74.71 m 1 + 320.554 -51.8184 l 2 + 274.802 -91.5547 249.758 -112.902 245.426 -115.866 c 0 + 241.092 -118.828 236.846 -120.31 232.688 -120.31 c 0 + 227.835 -120.31 223.415 -118.306 219.429 -114.297 c 0 + 215.442 -110.289 213.449 -105.844 213.449 -100.965 c 0 + 213.449 -97.8281 223.329 -71.3379 243.087 -21.4932 c 2 + 322.115 180.323 l 1 + 152.618 289.598 l 2 + 104.783 320.271 79.2217 337.176 75.9297 340.313 c 0 + 72.6357 343.45 70.9893 347.981 70.9893 353.907 c 0 + 70.9893 369.243 79.8291 376.912 97.5059 376.912 c 0 + 98.8926 376.912 123.155 374.82 170.296 370.638 c 2 + 379.825 352.862 l 1 + 427.14 555.201 l 2 + 439.271 607.834 446.811 636.764 449.757 641.992 c 0 + 452.702 647.221 458.162 649.834 466.134 649.834 c 4 + 474.454 649.834 466.134 74.71 466.134 74.71 c 1 +EndSplineSet Validated: 524321 EndChar EndChars diff --git a/resources/fonts/calibreSymbols.otf b/resources/fonts/calibreSymbols.otf index 9cb688b783b92835d89b367bde82d395884003f3..945233e1734595d1459feae5cd32521841a1529f 100644 GIT binary patch delta 697 zcmY*XO-K}B7=GSwescd@%{8S)9c*g_SzQNKI}}Cc1VQaqOQ)c=)>@<0g$%s4bScQF zn3Skn3EiYxEQut-0--$Q2G&B*p>o561O}TOrgvlyH6PFSKJWAX&G*gR)Lv_sVu?fy z9^@b)(rcP}D_x!hl#f7Fi)khf=2q_C0ICB3wEg?~Ow@z9uk84-qn*b1!|O``>Fl38 zok?axiLN<7POx?=-JeXkcE5Vcu@{W)Gz;oId4l;WBbd$%Cr5m3Vx9*?SO{d2BUz|% zrqsxrI+)D#2Zx>)*v|o?kR7@(Y)`}B7o6s}4suet@W*)Wgn#ERc%%|5c$@wC*|Ej% zqmOQV*|kAsE=$j>AcgC6C*VBsGkqyOcSn24N>MD-P6O-hI1_%Fs&EB0v{d0Ls>LR& zNa4^is^$A4*~PidG*;mXbb3?aDl{tRI|OHTp$B0^83rN_EK3Tyx_ZLVun{pL)=TMj zoU5=7tupJl(}y*UC+uPCMHK||4sJ2CU1=}bHmm=5cEMh-%}@4+CZ{fcSKdO>6b$RJ z9I)Ogt-VcDZWiShsoWsH|KnS0{C!x_Fz45R8V!Y74VyJ}Y$FuGif?b~6sspsqHDpV(DD^^8Ol#~hON&bQQRS4akUvbZfPMa2557{^{HCwN{tJls3 z%HjHJUiYGV@tfDX>{%Y2_xgBR9f;e|x%?GZn#g0#`nI(d?*yGQ|M&Tb{}dr(QfVMd ID!_EsU)Tzuu>b%7 delta 652 zcmY*WOK4L;6g@NVljdjIG&L2UHE8-lNlYIxShXwLSFvhp4K4~&qp3~B)L<)gAy^d5 zLJ@VaAT9(ES0Z9?*H9{52r8&qR10Dj6~wLzsm7{2?<+xYhCBD1bMM@_Gc%{%)Goyn zi8!2?goMaG!w7uqzgPg2*MRN2VI&Tnf4-*|aF+mRJzd=f8sH;7XYu&a9r{!*_Xl7B z;wMgJlG%fIOP2w;kFIX|h$U{)&7HFi8W=-Imhr}UK+yvi1H=&>jtSg!D*z z3}R5)EH+49QI<~jNYs~QTJ^w$RcwvR*hSuf8gQCns#IuEOp~;K*esgwP2-~pmVYE~ zWYQJrVpjHv56YI^8mnyLl_sg;m*4$zuQvWXqG*`$Xh5xomvtJ}YqpXXGN★★★½') + ahs.setToolTip(_('Allow half star ratings, for example: ') + '★★★⯨') add_row(None, ahs) # Composite display properties diff --git a/src/calibre/utils/fonts/utils.py b/src/calibre/utils/fonts/utils.py index fd5987614d..155298a362 100644 --- a/src/calibre/utils/fonts/utils.py +++ b/src/calibre/utils/fonts/utils.py @@ -463,7 +463,7 @@ def test_glyph_ids(): def test_supports_text(): data = P('fonts/calibreSymbols.otf', data=True) - if not supports_text(data, '.★½'): + if not supports_text(data, '.★½⯨'): raise RuntimeError('Incorrectly returning that text is not supported') if supports_text(data, 'abc'): raise RuntimeError('Incorrectly claiming that text is supported') diff --git a/src/pyj/test_utils.pyj b/src/pyj/test_utils.pyj index f424e1b06d..da2c6bbe1b 100644 --- a/src/pyj/test_utils.pyj +++ b/src/pyj/test_utils.pyj @@ -8,7 +8,7 @@ from utils import fmt_sidx, human_readable, rating_to_stars @test def misc_utils(): - assert_equal(rating_to_stars(3, True), '★½') + assert_equal(rating_to_stars(3, True), '★⯨') assert_equal(fmt_sidx(10), 'X') assert_equal(fmt_sidx(1.2), '1.20') assert_equal(list(map(human_readable, [1, 1024.0, 1025, 1024*1024*2.3])), ["1 B", "1 KB", "1 KB", "2.3 MB"]) diff --git a/src/pyj/utils.pyj b/src/pyj/utils.pyj index a431d94905..8e489d8832 100644 --- a/src/pyj/utils.pyj +++ b/src/pyj/utils.pyj @@ -121,7 +121,7 @@ def fmt_sidx(val, fmt='{:.2f}', use_roman=True): return int(val) + '' return fmt.format(float(val)) -def rating_to_stars(value, allow_half_stars=False, star='★', half='½'): +def rating_to_stars(value, allow_half_stars=False, star='★', half='⯨'): r = max(0, min(int(value or 0), 10)) if allow_half_stars: ans = star.repeat(r // 2)