Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lex] Use \textsc for Unicode character names #5077

Merged
merged 2 commits into from Nov 19, 2021
Merged

Conversation

jensmaurer
Copy link
Member

Fixes #5032

The presentation of Unicode character names is ... hurting the eye. Using \textsc improves the situation:

Before:

unicode1

After:

unicode2

We could also consider using fixed-width font for the "U+nnnn" part, but maybe it is better to limit fixed-width font to C++-level things, which "U+nnnn" most definitely is not.

@tkoeppe, I'd appreciate your opinion here.

@jensmaurer
Copy link
Member Author

jensmaurer commented Oct 27, 2021

The "+" in "U+nnnn" could use some shrinking (akin to the "+" in "C++").

This is not yet ready to merge, because I haven't done the full makeover yet.

@jwakely
Copy link
Member

jwakely commented Oct 27, 2021

I like the smaller text, but why does the "After" image show U+U+000B?

@jensmaurer
Copy link
Member Author

jensmaurer commented Oct 27, 2021

why does the "After" image show U+U+000B?

Because there was a typo. Meanwhile fixed.

New "after", now with smaller "+":

unicode3

@jensmaurer
Copy link
Member Author

@tkoeppe , do you have an opinion here?

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 7, 2021

I saw that, let me think about it... it's a bit jarring to have the U+nnnn be so large by comparison -- could we perhaps make that smallcaps, too?

@jensmaurer
Copy link
Member Author

@tkoeppe, tried that. The problem is that the digits stay the same size:

lex

@jensmaurer
Copy link
Member Author

jensmaurer commented Nov 7, 2021

@tkoeppe, here's everything with simply \textsmaller[1]. This fixes the size of the digits.

lex

@jensmaurer
Copy link
Member Author

This last variant looks quite nice to me.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 7, 2021

Shame there are no real small-caps-sized numerals in our main font. I'll look a bit more. How are your scaled numerals looking for contrast and weight?

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 7, 2021

(But I think we're onto something here.)

@jensmaurer
Copy link
Member Author

@tkoeppe, see the latest screenshot three comments up. This has scaled digits.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 7, 2021

Can we use actual small-caps letters, and only use scaling for the numerals? That avoids the awkward spacing of capitals (captials aren't designed to be juxtaposed and would normally call for tracking).

Can you try this:

\newcommand{\unicode}[2]{\textsc{u}\textsmaller[1]{\protect\raisebox{.2ex}{\textsmaller[1]{+}}#1} \textsc{#2}}

(By contrast, the (upper-case) numreals are fine because they are designed to appear together.)

@jensmaurer
Copy link
Member Author

jensmaurer commented Nov 7, 2021

@tkoeppe, here's \textsc for everything, except scaling the digits manually:

lex

(I'm not seeing a difference compared to all-capitals scaled smaller, but that may be just me.)

@jensmaurer jensmaurer marked this pull request as ready for review November 7, 2021 19:31
@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2021

Look closely, the scaled-down caps are too tight and too thin. The proper small caps are more widely spaced and have the same weight as the other letters.

I think this is nice now, we can apply this.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2021

Hm, I don't think we have a monospaced roman font. How do you feel about using the typewriter font for the hexadecimal digits (but leaving everything else the same)?

@jensmaurer
Copy link
Member Author

@tkoeppe, here is the monospace variant (including making the U+ monospace):

lex

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2021

Yeah, I tried that, too. I'm not sure. Both versions have merit. Normal roman font blends in more nicely but doesn't give us fixed-width codepoints, whereas the codefont stands out a bit more (in the sense of being more disrupting). I think I could live with both versions -- any thoughts or preferences? @burblebee?

@jensmaurer
Copy link
Member Author

jensmaurer commented Nov 8, 2021

We usually reserve code font for, well, code, i.e. snippets that could reasonably appear in a valid C++ program. U+nnnn is definitely not of that kind. I do see the advantage of using a fixed-width font here, but that doesn't outweigh the disadvantages (more visually disruptive; does not visually connect to/align with the following character name) for me.

I do note that given the work applied to use macros for Unicode designators, we're at liberty to quickly change the layout down the road, should we so desire.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 8, 2021

I was also thinking with only making the hex digit sequence use code font, but it's also not that great. OK, let's go with the scaled roman capitals then, that definitely looked nice. And the lack of fixed would only be noticable in tabular settings.

(As long as only decimal digits appear, we can use fixed-with numerals from the roman font, too -- that doesn't solve every problem, but maybe there'll be one or two situations where we can lean on that.)

Also check for uppercase hex digits inside \ucode and \unicode,
which do not work well with \textsc.
@jensmaurer
Copy link
Member Author

Now that we've got that settled, this feels ready to me. Please review carefully that I haven't introduced an accidental change in the numbers or names while restructuring the code to use the new macros.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 19, 2021

Thanks a lot! The smallest capitals for the biggest wins.

@tkoeppe tkoeppe merged commit 02f9bb5 into cplusplus:main Nov 19, 2021
@Eelis
Copy link
Contributor

Eelis commented Dec 21, 2021

I didn't follow the complete conversation, but I just noticed that in the PDF, letters occurring as hex digits are now a bit bigger than the U at the start:

image

Looks weird, was that intentional? (If so, ignore this message.)

@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 21, 2021

@Eelis: That's because the (hex) numbers are manually scaled, whereas everything else is small-caps. The problem is ultimately that our font doesn't have small-caps numerals, so we're emulating those. The details could be tweaked of course; suggestions welcome.

@Eelis
Copy link
Contributor

Eelis commented Dec 21, 2021

@tkoeppe For cxxdraft-htmlgen, I ended up using Eelis/cxxdraft-htmlgen@e5f612d because scaled down capital smallcaps seem to look good in Firefox and Chromium. But I see that in LaTeX, that approach creates too widely spaced letters, so I'm at a loss, sorry.

@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 21, 2021

I can make the scaled caps a little smaller still:

image

down from status quo:

image

@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 21, 2021

Looks like Source Sans Pro has small-caps numerals: https://fonts.google.com/specimen/Source+Sans+Pro

Not an option for us unfortunately :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inconsistent formatting for \U+nnnn
4 participants