Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Formatting Unicode symbol in a label

1,538 views
Skip to first unread message

Dan'l B

unread,
Jan 4, 2014, 7:32:56 AM1/4/14
to
Given a line such as

"" u (myDateSP(1,2)):3:((strcol(4) eq "First") ? ("U+1F311"):1/0) w labels left font "Arial Unicode MS,18" offset -4,0,\

How do I insert the Unicode codepoint for a quarter moon symbol (for example)? The above formatting doesn't work.

Arial Unicode MS includes that unicode character. Times New Roman PSMT also supports it; both are available on my system.

OSX 10.6.8
GN 4.6 patchlevel 4
pdfcairo installed
using PDF terminal

Karl

unread,
Jan 4, 2014, 12:16:05 PM1/4/14
to
Am 04.01.2014 13:32, schrieb Dan'l B:
> Given a line such as
>
> "" u (myDateSP(1,2)):3:((strcol(4) eq "First") ? ("U+1F311"):1/0) w labels left font "Arial Unicode MS,18" offset -4,0,\
>
> How do I insert the Unicode codepoint for a quarter moon symbol (for example)? The above formatting doesn't work.
>
(the abscissa part of your using statement seems to be missing the
dollar signs)

One simple way would be to

set encoding utf8

and then directly put the symbol there.




Hans-Bernhard Bröker

unread,
Jan 4, 2014, 1:09:08 PM1/4/14
to
On 04.01.2014 13:32, Dan'l B wrote:
> Given a line such as
>
> "" u (myDateSP(1,2)):3:((strcol(4) eq "First") ? ("U+1F311"):1/0) w labels left font "Arial Unicode MS,18" offset -4,0,\

I'm less than convinced that you can have a ternary operator's two
results be one string and one number.

> How do I insert the Unicode codepoint for a quarter moon symbol (for example)? The above formatting doesn't work.

So how exactly does it fail, then?


Dan'l B

unread,
Jan 5, 2014, 2:56:08 AM1/5/14
to
Failure: it simple prints the literal codepoint: U+1F311

This, for example, works, but only with Aqua and SVG terminals; it fails in PDF (prints the literal "G"):

"" u (myDateSP(1,2)):3:((strcol(4) eq "First") ? ("G"):1/0) w labels left font "Moon Phases,28" offset -4,0,\

(Moon Phases is an old symbol font; it fails in PDF using any of its variants: TTF, PS, OTF.)

Dan'l B

unread,
Jan 5, 2014, 3:05:20 AM1/5/14
to
On Saturday, January 4, 2014 1:32:56 PM UTC+1, Dan'l B wrote:
Aha, Karl's suggestion did the trick: set encoding utf8

It does not, however, enable that Moon Phases font to work on the PDFcairo terminal.

Karl

unread,
Jan 5, 2014, 12:28:28 PM1/5/14
to
pdf and pdfcairo have different ways of handling the font names etc. I�d
say you just gave the wrong name. :-/

Have you tried using the font in a simpler way, e.g. in an axis label or
plot title, to make sure it�s not a problem in "with label"?

K

P.S. Who on earth gave you a data file that contains utf8 moon symbols? ;-)

Karl

unread,
Jan 5, 2014, 12:44:06 PM1/5/14
to
Am 05.01.2014 08:56, schrieb Dan'l B:
>
> Failure: it simple prints the literal codepoint: U+1F311
>

Well, of course. That�s what your string contains.

You can enter (octal) ascii codepoints as, e.g. "\131", but i�m not sure
this is possible for unicode, see "help enhanced tex mode":

"You can access special symbols numerically by specifying
\character-code (in octal), e.g., {/Symbol \245} is the symbol for
infinity. This does not work for multibyte encodings like UTF-8,
however. In a UTF-8 environment, you should be able to enter multibyte
sequences implicitly by typing or otherwise selecting the character you
want. "


K

Dan'l B

unread,
Jan 5, 2014, 9:08:56 PM1/5/14
to
On Saturday, January 4, 2014 1:32:56 PM UTC+1, Dan'l B wrote:
I'll go back to the "help enhanced tex mode", thanks.

I've tried every trick in the book that I could find (man pages, searching, etc): putting the font name in the working directory, fontpath, removing spaces in the name, etc. That said, I am a complete noob on these font issues so it's a steep curve.

Last discovery is that SVG terminal outputs the Moon Phases symbols OK but when I used an online SVG -> PDF converter, the symbols didn't survive. Opening the SVG in Photoshop Elements and printing to PDF locally fails as well. The Aqua terminal handles it nicely and I can then print to PDF but it adds a lot of steps to the workflow when I have many pages.

It's a font one finds searching for Moon Phases font, and I think it dates back a way; a fella over in the Apple discussions ran it through his professional font mgmt tool and cleaned it up and produced various PS, OTF, TTF versions for me; nada...

Research ongoing. :-))
Message has been deleted

Dan'l B

unread,
Jan 7, 2014, 11:28:15 AM1/7/14
to
On Saturday, January 4, 2014 1:32:56 PM UTC+1, Dan'l B wrote:
The Symbola font includes all unicode glyphs for moon phases.

In these 4 labels, the last two work. All glyphs appear in OSX Font Book; when inserted as symbols into the BBedit command file, the symbols appear correctly; the BBedit file is saved as UTF8; UTF8 is set in the terminal. The SVG terminal displays all the characters properly; the Aqua and PDF terminals display only the First and Last Quarters properly.

"" u (myDateSP(1,2)):3:((strcol(4) eq "New") ? ("🌑"):1/0) w labels left font "Symbola,28" offset -4,0,\
"" u (myDateSP(1,2)):3:((strcol(4) eq "Full") ? ("🌕"):1/0) w labels left font "Symbola,28" offset -4,0,\
"" u (myDateSP(1,2)):3:((strcol(4) eq "First") ? ("☽"):1/0) w labels left font "Symbola,28" offset -4,0,\
"" u (myDateSP(1,2)):3:((strcol(4) eq "Last") ? ("☾"):1/0) w labels left font "Symbola,28" offset -4,0,\

Neither of these terminal setups seems to help:

set terminal pdfcairo enhanced size 13.5,9.8
set term pdfcairo enhanced font "Symbola" size 13.5,9.8

Ethan A Merritt

unread,
Jan 7, 2014, 4:18:04 PM1/7/14
to
Dan'l B wrote:

> On Saturday, January 4, 2014 1:32:56 PM UTC+1, Dan'l B wrote:
> Turns out that the Symbola font includes all the unicode glyphs for moon
> phases.
>
> Can anyone illuminate me about why the following problem might occur? In
> these labels, the last two work, the first two do not when outputting to
> PDFcairo terminal. They all appear in the OSX Font Book, and when inserted
> as symbols into the BBedit command file, the symbols appear correctly; the
> BBedit file is saved as UTF8; UTF8 is set in the terminal. The SVG
> terminal displays all the characters properly; the Aqua terminal displays
> only the First and Last Quarters properly; EPS and PDF terminals do not
> display any of the four:
>
> "" u (myDateSP(1,2)):3:((strcol(4) eq "New") ? ("🌑"):1/0) w labels left
> font "Symbola,28" offset -4,0,\
> "" u (myDateSP(1,2)):3:((strcol(4) eq "Full") ? ("🌕"):1/0) w labels left
> font "Symbola,28" offset -4,0,\
> "" u (myDateSP(1,2)):3:((strcol(4) eq "First") ? ("☽"):1/0) w labels left
> font "Symbola,28" offset -4,0,\
> "" u (myDateSP(1,2)):3:((strcol(4) eq "Last") ? ("☾"):1/0) w labels left
> font "Symbola,28" offset -4,0,\


The UTF sequences in your 3rd and 4th commands are indeed
☽ Unicode 263D UTF8 0xE2 0x98 0xBD first quarter moon
☾ Unicode 263E UTF8 0xE2 0x98 0xBE last quarter moon
and they display correctly here on my screen as I read your post.

The sequences in your 1st and 2nd commands are not displayed
correctly here but a hex dump shows that they are
Unicode 01F311 UTF8 0xF0 0x9F 0x8C 0x91
Unicode 01F315 UTF8 0xF0 0x9F 0x8C 0x95
These lie on a higher page of the Unicode tables and were added to
the standard in Unicode 6.0 (released Oct 2010). So I can easily
believe that many environments do not yet support them,
including my desktop display.

Maybe you can use instead
⬤ Unicode 2B24 UTF8 0xE2 0xAC 0xA4 Large Black Circle
◯ Unicode 25EF UTF8 0xE2 0x97 0xAF Large Circle

Dan'l B

unread,
Jan 8, 2014, 2:59:14 AM1/8/14
to
Ethan,

That worked just right in the PDFcairo output. I did have to use the small black circle as the large one doesn't render but that is fine.

Many thanks! I find this font business a black art and appreciate you shining some light on the problem.
Big relief after many hours of frustration!
0 new messages