Help needed with unicode

84 views
Skip to first unread message

Benoit

unread,
Jun 30, 2019, 12:47:57 PM6/30/19
to Metamath
Hi all,

I recently defined some classes that I want to look like an overlined character and a character with a circumflex (see ~cccbar , ~ccchat and ~ crrhat at http://us2.metamath.org/mpeuni/mmdefinitions.html).

Specifically, I want them to look like \overline{\mathbb{C}} and \hat{\mathbb{C}}.  I used the unicode "combining diacritical marks" U+0305 ◌̅ COMBINING OVERLINE and U+0302 ◌̂ COMBINING CIRCUMFLEX ACCENT (see https://www.compart.com/en/unicode/block/U+0300). Specifically, the set.mm file has
  althtmldef "CCbar" as "ℂ̅";
  althtmldef "CChat" as "ℂ̂";
  althtmldef "RRhat" as "ℝ̂";

The result is not very nice for the overline (the overline is a bit off to the right and a bit too high above the letter) and is a complete failure for the circumflex.  Does anyone know the reason -- and a solution?

When I generate the html pages on my computer, the characters look fine. This might be because the fonts are not installed by default?

Remark: actually, I generally use in \widehat{A} instead of \hat{A} (and similarly \overline{A} instead of \bar{A}) since I think the larger marks look better, but I haven't seen a unicode character for "widehat".

Thanks,
Benoit

André L F S Bacci

unread,
Jun 30, 2019, 2:55:44 PM6/30/19
to meta...@googlegroups.com
althtmldef accept a full HTML definition? If so... 

althtmldef "CCbar" as "<span style='text-decoration: overline'>&#8450;</span>";

André

Benoit

unread,
Jun 30, 2019, 5:36:24 PM6/30/19
to Metamath
Thanks André.  I introduced RRbar using your proposal in my latest PR, in order to compare how they look.

Anyone has an idea for \hat{R} ?  It's particularly strange that it works when I generate the html locally, though I haven't done anything special with fonts, and on the contrary, it does not work on metamath.org where, if I understood correctly, a special set of fonts is loaded locally?

Benoit

André L F S Bacci

unread,
Jun 30, 2019, 6:20:13 PM6/30/19
to meta...@googlegroups.com
On Sun, Jun 30, 2019 at 6:36 PM Benoit <benoit...@gmail.com> wrote:
Thanks André.  I introduced RRbar using your proposal in my latest PR, in order to compare how they look.

Anyone has an idea for \hat{R} ?  It's particularly strange that it works when I generate the html locally, though I haven't done anything special with fonts, and on the contrary, it does not work on metamath.org where, if I understood correctly, a special set of fonts is loaded locally?

This is somewhat of heretic / excessive suggestion, but... A little of https://viereck.ch/latex-to-svg/ with https://www.svgminify.com/ genetared:

althtmldef "RRhat" as "<svg width='1.776ex' height='2.725ex' style='vertical-align:-0.252ex' aria-hidden='true' focusable='false' role='img' viewBox='0 -1065.1 764.5 1173.4' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><defs><path id='a' d='m208 74q0-24 46-28 18 0 18-11 0-1-2-13-3-14-6-18t-13-4q-2 0-12 0t-34 1-64 1q-71 0-91-2h-8q-7 7-7 11 2 27 13 35h14q70 3 102 50 6 6 181 305t178 303q7 12 24 12h25q6-9 6-10l28-323q28-323 30-326 5-11 65-11 25 0 25-10 0-2-3-14-3-15-5-18t-14-4q-3 0-14 0t-39 1-73 1q-94 0-123-2h-12q-6 6-6 9t2 18q4 13 6 16l4 3h20q54 3 64 17l-12 150h-238l-34-58q-41-69-41-81zm308 186q0 11-12 156t-14 146l-27-43q-16-27-63-107l-90-152 103-1q103 0 103 1z'/><path id='b' d='m112 560l137 134 8-8q130-124 130-126l-26-29q-2 1-58 50l-53 46-55-47q-13-11-26-23t-21-19l-8-6q-2-2-15 14l-13 14z'/></defs><g transform='scale(1 -1)' fill='currentColor' stroke='currentColor' stroke-width='0'><use xlink:href='#a'/><use x='264' y='266' xlink:href='#b'/></g></svg>";

In fact, this is I make in books I edit. Use Latex as de facto language for complex math expressions, and then render they as minified SVG for print.

I suggest to further to add an "altlatexdef" to automate in future situations.

André

Mario Carneiro

unread,
Jun 30, 2019, 10:34:01 PM6/30/19
to metamath
Oh dear, this will generate horribly large HTML files. If this glyph could be added to the header and referred to, it may work better. I guess since it's SVG you could just put it in an SVG file and load it like any other image.

--
You received this message because you are subscribed to the Google Groups "Metamath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to metamath+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/metamath/CAL1T4B1na4%2BmsJvjJm-MxDS%3D%2Bve3w-c_hon%2BBqPQVyzaWF6H0A%40mail.gmail.com.

Benoit

unread,
Jul 1, 2019, 6:15:48 AM7/1/19
to Metamath
Thanks André and Mario.
I tweaked a bit the html code of http://us2.metamath.org/mpeuni/ccchat.html , changing the fonts. Some font choices give nicer results.  My conclusion is that we should use

  althtmldef "CChat" as "&#8450;&#x302;";
because it is simple, semantically correct, and correctly generates a single glyph.  I think that the problem is with the font.  Something like XITS not supporting unicode combining characters?  Maybe I should report it to https://github.com/alif-type/xits ?

I actually prefer to have an ugly symbol with a simple and correct code (that generates "text-only") than go into very intricate hard-to-maintain code in order to have a better looking symbol.

Benoit

André L F S Bacci

unread,
Jul 1, 2019, 2:24:51 PM7/1/19
to meta...@googlegroups.com
On Sun, Jun 30, 2019 at 11:34 PM Mario Carneiro <di....@gmail.com> wrote:
Oh dear, this will generate horribly large HTML files. If this glyph could be added to the header and referred to, it may work better. I guess since it's SVG you could just put it in an SVG file and load it like any other image.

Yes, and so the suggestion to automate this. `altlatexdef` calls a external render & minifier, generating hash-md5-of-contents.svg of glyph, and then using this as simple image on pages.

Another option is to use https://www.mathjax.org for the same effect, in a pure online execution.

On Mon, Jul 1, 2019 at 7:15 AM Benoit <benoit...@gmail.com> wrote:
Thanks André and Mario.
I tweaked a bit the html code of http://us2.metamath.org/mpeuni/ccchat.html , changing the fonts. Some font choices give nicer results.

Render as:
image.png
on a Linux machine, Chrome. Same for Firefox. The same problem. Initial load shows better, then a webflont loads and the result changes to this.

 
  My conclusion is that we should use
  althtmldef "CChat" as "&#8450;&#x302;";
because it is simple, semantically correct, and correctly generates a single glyph.  I think that the problem is with the font.  Something like XITS not supporting unicode combining characters?  Maybe I should report it to https://github.com/alif-type/xits ?

I actually prefer to have an ugly symbol with a simple and correct code (that generates "text-only") than go into very intricate hard-to-maintain code in order to have a better looking symbol.

Consider symbol in SVG with a alt text with original Latex expression. Not only you have a better guarantee of correct print, but a helpful hint for people using aural readers and copy support (in contrast with Unicode magic).

André

Benoit

unread,
Jul 1, 2019, 4:54:49 PM7/1/19
to Metamath
After the experiment, I reverted to the combining unicode.  I like the fact that it is simple, text-only, and does not require additional files.

When I replace XITS with STIX in the html code, everything looks nice.  I'm not sure what this entails, but would it be possible/desirable to switch from XITS to STIX ?  Not only because of the single case that started this thread, but it looks like XITS was partly designed to fix some problems with STIX 1 and for right-to-left writing.  Since then, STIX 2 has been released, which apparently fixes said problems (and metamath.org is not concerned with bidirectional writing).
See the STIX font project: https://github.com/stipub/stixfonts
A comparison of STIX and XITS, dated from before STIX 2, but anticipating it: https://tex.stackexchange.com/questions/227216/stix-versus-xits

Benoit

David A. Wheeler

unread,
Jul 1, 2019, 6:32:22 PM7/1/19
to metamath, Metamath
On Mon, 1 Jul 2019 13:54:49 -0700 (PDT), Benoit <benoit...@gmail.com> wrote:
> After the experiment, I reverted to the combining unicode. I like the fact
> that it is simple, text-only, and does not require additional files.

Me too. I think having simple HTML is a plus.

> When I replace XITS with STIX in the html code, everything looks nice. I'm
> not sure what this entails, but would it be possible/desirable to switch
> from XITS to STIX ?

It's possible. As you noted, a new version of STIX has been released, and it
might produce "better" results than XITS.

I think we ought to try it out on many platforms before committing to such a change.
Sometimes fonts work well only on specific platforms, and that wouldn't be good.

--- David A. Wheeler

Benoit

unread,
Jul 2, 2019, 7:26:46 PM7/2/19
to Metamath
> When I replace XITS with STIX in the html code, everything looks nice.  I'm
> not sure what this entails, but would it be possible/desirable to switch
> from XITS to STIX ?

It's possible.  As you noted, a new version of STIX has been released, and it
might produce "better" results than XITS.

I think we ought to try it out on many platforms before committing to such a change.
Sometimes fonts work well only on specific platforms, and that wouldn't be good.

To ease testing from multiple platforms and browsers, one could add to us2.metamath.org/ a page mpeuni/mmascii-STIX.html using STIX 2 instead of XITS. One simply needs to replace the lines
  @font-face {
    font-family: XITSMath-Regular;
    src: url(xits-math.woff);
  }
  .math { font-family: XITSMath-Regular }
with the corresponding STIX version.  I'm not sure whether it is
  font-family: STIX2Math;
  src: url(STIX2Math.woff2);
or a variant (e.g. STIXTwoMath). Then, we could easily compare ascii.html with ascii-STIX.html from several browsers, devices, etc. before switching.

Benoit



Reply all
Reply to author
Forward
0 new messages