2

This is a follow-up of this question of mine and uses the same setup.

I am trying to typeset chess annotation symbols. The MWE is

\documentclass{article}
\usepackage{xskak}
\newcommand\mychessboard[1][]{\chessboard[#1]}
\usepackage{chess-workshop-symbols}

\begin{document}
\wbetter       \\   % fails
\bbetter       \\   % fails
\wupperhand    \\   % fails
\bupperhand    \\
\wdecisive     \\   % fails
\bdecisive     \\   % fails
\equal         \\
\unclear       \\   % fails
\compensation  \\   % fails
\withattack    \\
\withinit      \\
\counterplay   \\
\zugzwang      \\
\mate          \\
\withidea      \\
\onlymove      \\
\betteris      \\
\file          \\
\end{document}

All symbols display correctly if I process the file with pdflatex. Using tex4ebook, some don't display correctly as indicated by the fails comment above.

Is there a way to fix this? Thanks.

Edit: Added image to show calibre/ebook viewer result mentioned in my comment.calibre/ebook viewer result

user41974
  • 841

1 Answers1

3

The problem is that several symbols doesn't have Unicode counterparts, so we need to output them as two characters. In some cases it doesn't really fit the original.

SkakNew.htf:

SkakNew  32 121
'' ''     32
'!' ''     33
'”' ''     34
'#' ''  35
'$' ''  36
'%' ''  37
'&' ''  38
'’' ''     39
'(' ''  40
')' ''  41
'*' ''  42
'+' ''  43
',' ''  44
'-' ''  45
'.' ''  46
'/' ''     47
'0' ''  48
'1' ''  49
'2' ''  50
'3' ''  51
'4' ''  52
'5' ''  53
'6' ''  54
'7' ''  55
'8' ''  56
'9' ''  57
':' ''  58
';' ''  59
'¡' ''     60
'=' ''  61
'¿' ''     62
'?' ''  63
'@' ''  64
'→' ''  65
'♗' ''  66
'↑' ''  67
'⊙' ''  68
'△' ''  69
'□' ''  70
'⇗' ''  71
'⇔' ''  72
'⊞' ''  73
'╳' ''  74
'♔' ''  75
'⟂' ''  76
'≪' ''  77
'♘' ''  78
'≫' ''  79
'Ⅱ' ''  80
'♕' ''  81
'♖' ''  82
'>' ''  83
'⊕' ''  84
'○' ''  85
'⇆' ''  86
'W' ''  87
'×' ''  88
'Y' ''  89
'Z' ''  90
'[' ''  91
'“' ''     92
']' ''  93
'ˆ' ''     94
'˙' ''     95
'‘' ''     96
'⧉' ''  97
'⌓' ''  98
'±' ''  99
'⦂' ''  100
'∓' ''  101
'⩲' ''  102
'⩱' ''  103
'+-' ''  I can't find it, it is plus followed by minus
'-+' ''  minus followed by plus
'=' ''  106
'∞' ''  107
'l' ''  108
'#' ''  109
'=∞' ''  110
'o' ''  111
'p' ''  112
'q' ''  113
'r' ''  114
's' ''  115
't' ''  116
'u' ''  117
'v' ''  118
'w' ''  119
'x' ''  120
'y' ''  121
SkakNew  32 121

Resulting HTML:

enter image description here

And PDF:

enter image description here

\compensation command output isn't really ideal

The problem with Unicode characters is that especially smaller devices, like Kindle may not support all of them. In this case, there are two solutions. First is to request image generation for such characters. It can be requested if you put number 1 in the second column in the htf file:

'=∞' '1'  110

To ease the htf file editing and to find out which lines correspond to particular characters, you can generate font map for SkakNew font with the following Tex code:

\documentclass{article} 
  \input showfonts.4ht 
\begin{document} 
  \showfonts 
     {SkakNew-Figurine} 
     {} 
\end{document}  

compile it with pdflatex.

The second way is to convert the SkakNew-Figurine.otf to woff format, which can be used on web pages and configure the chess characters to use this font. You need to install the helpers4ht bundle and use the following .cfg:

\RequirePackage{addfont4ht}
\Preamble{xhtml}
\AddFontFace{SkakNewFigurine}{SkakNew-Figurine}{SkakNew-Figurine.woff}{}
\Css{.SkakNew-Figurine-{font-family:"SkakNewFigurine",sans-serif;}}
\begin{document}
\EndPreamble
michal.h21
  • 50,697
  • Thanks for the fixes. My output is same except that \wbetter doesn't display correctly on the Calibre/ebook reader (see picture in updated question). Does it show correctly for you? – user41974 May 24 '16 at 02:30
  • @user41974 yes, it works for me even in Calibre's ebook viewer. It probably can't find font with glyph for this character on your system – michal.h21 May 24 '16 at 11:15
  • Thanks for confirming that it's ok for you. Transferring the converted epub file to my kindle didn't help. Is there any way around this problem? – user41974 May 24 '16 at 11:37
  • Only converting the chess characters as images, I am afraid. Which is far from ideal, as this causes problems with baseline alignment, font size resizing etc. – michal.h21 May 24 '16 at 12:04
  • Would it possible to install the missing font on my system? Which windows system font does tex4ebook use for these symbols? – user41974 May 24 '16 at 12:18
  • @user41974 fonts are selected by the browser by default. you can include fonts in the epub file, see http://tex.stackexchange.com/a/289562/2891 for example. I am not sure whether the font inclusion works in Kindle – michal.h21 May 24 '16 at 12:35
  • I tried your suggestion the above link but it didn't help. I probably did something wrong. Where do I get the xskak fonts in woff format? I will use graphics for the symbols for now. Simple question: which lines in skaknew.htf refer to them eg \wbetter and how does the numbering work? Thanks. – user41974 May 25 '16 at 04:31
  • @user41974 you can convert the otf version of SkakNew fonts to Woff. I will upgrade my answer to show you how to do that – michal.h21 May 25 '16 at 06:45
  • Thanks for the explanations. I tried your suggestion of using the woff font file but it didn't work for me. The woff file is in the epub directory after running tex4ebook but some symbols still don't show. I get errors "Mimetype for tmp is not registered" and "Mimetype for opf is not registered" during the run. Is this normal? Thanks. – user41974 May 26 '16 at 03:53
  • @user41974 it seems to work in epub, but not in mobi - it seems that chess Unicode characters are translated to nonsense symbols by kindlegen. – michal.h21 May 26 '16 at 10:44
  • Thanks for confirming this. I'll stick to graphics for the symbols. – user41974 May 26 '16 at 10:56
  • I have just noticed that tex2ebook gives warnings while processing the file. One is about starting/ending with character code 121 instead of 154. The other one is "improper entry (line 72)" for skaknew.htf. This is the line that defines the symbol that is causing problems. Does this warning mean anything and could this be the problem with the symbol not showing correctly? Thanks. – user41974 Jun 07 '16 at 09:41
  • @user41974 the first warning is OK, we reuse the same htf file for several fonts and it only tells us that the font does have different number of characters than the htf file. the second one is strange, because it doesn't look like there should be any problem at line 72 in the htf file – michal.h21 Jun 07 '16 at 13:13
  • Thanks for the feedback. Do you get the second warning? – user41974 Jun 07 '16 at 13:24
  • @user41974 yes, I do get the second warning. But I get it even when I replace the unicode entity with char, so it maybe isn't really related to some error in the htf file, but rather to font processing by tex4ht. – michal.h21 Jun 07 '16 at 13:30
  • Ok thanks. It's strange that the warning is for the line that gives me problems. – user41974 Jun 07 '16 at 13:32