Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Nothing ever becomes real until it is experienced. -- John Keats


devel / comp.lang.postscript / Re: Printing UTF8 (Unicode)

SubjectAuthor
* Printing UTF8 (Unicode)David Newall
+* Re: Printing UTF8 (Unicode)Carlos
|`- Re: Printing UTF8 (Unicode)David Newall
+* Re: Printing UTF8 (Unicode)David Newall
|`* Re: Printing UTF8 (Unicode)Carlos
| `* Re: Printing UTF8 (Unicode)David Newall
|  `* Re: Printing UTF8 (Unicode)Carlos
|   `- Re: Printing UTF8 (Unicode)David Newall
`* Printing UTF8 (Unicode) - opinions pleaseDavid Newall
 +* Re: Printing UTF8 (Unicode) - opinions pleaseCarlos
 |`- Re: Printing UTF8 (Unicode) - opinions pleaseluser droog
 `* Re: Printing UTF8 (Unicode) - opinions pleaseluser droog
  `- Re: Printing UTF8 (Unicode) - opinions pleaseDavid Newall

1
Printing UTF8 (Unicode)

<4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=118&group=comp.lang.postscript#118

  copy link   Newsgroups: comp.lang.postscript
Newsgroups: comp.lang.postscript
X-Mozilla-News-Host: news://news.ausics.net:119
Cc: Glaukon <glaukon.ariston@gmail.com>
From: davidn@davidnewall.com (David Newall)
Subject: Printing UTF8 (Unicode)
Message-ID: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
Date: Fri, 21 Jan 2022 21:56:44 +1100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Organization: Ausics - https://www.ausics.net
Lines: 178
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news.ausics.net!not-for-mail
 by: David Newall - Fri, 21 Jan 2022 10:56 UTC

Hello All,

I've written some PostScript to allow me to print UTF8-encoded strings:

(UTF-8 Encoded String.....) utfshow

I'm happy to send you the full source, or, if appropriate, publish it
here; however, the exposition below includes everything you should need.

I use a UTF-8 decoder which was written (in C) by Bjoern Hoehrmann (see
http://bjoern.hoehrmann.de/utf-8/decoder/dfa/):

%/ Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de>
%/ See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.

/UTF8_ACCEPT 0 def
/UTF8_REJECT 12 def

/utf8d [
%/ The first part of the table maps bytes to character classes that
%/ to reduce the size of the transition table and create bitmasks.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
8 8 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
10 3 3 3 3 3 3 3 3 3 3 3 3 4 3 3 11 6 6 6 5 8 8 8 8 8 8 8 8 8 8 8

%/ The second part is a transition table that maps a combination
%/ of a state of the automaton and a character class to a state.
0 12 24 36 60 96 84 12 12 12 48 72 12 12 12 12 12 12 12 12 12 12 12 12
12 0 12 12 12 12 12 0 12 0 12 12 12 24 12 12 12 12 12 24 12 24 12 12
12 12 12 12 12 12 12 24 12 12 12 12 12 24 12 12 12 12 12 12 12 24 12 12
12 12 12 12 12 12 12 36 12 36 12 12 12 36 12 12 12 12 12 36 12 36 12 12
12 36 12 12 12 12 12 12 12 12 12 12
] def

% codep state byte decode codep' state'
/decode {
utf8d 1 index get % type
% codep state byte type
2 index UTF8_ACCEPT ne % state not UTF8_ACCEPT?
{ exch 16#3F and 4 -1 roll 6 bitshift or }
{ dup neg 16#FF exch bitshift 3 -1 roll and 4 -1 roll pop }
ifelse % state type codep'
3 1 roll add 256 add utf8d exch get % codep' state'
} def

%***************************************************************************/

I also use a table which Adobe published ("UNICODE translation table for
non-ASCII characters"), which they say is for going from a glyph name to
a Unicode codepoint. I (ab)use it in the reverse direction. I turned
it into a dictionary keyed on the codepoint.

The table is currently at https://github.com/adobe-type-tools/agl-aglfn.
Some codepoints have multiple possible glyph names, so the dictionary
has an array of potential glyph names for each codepoint. Finally,
fonts often have glyphs named /uniHHHH, where HHHH is the codepoint.

I converted the table to PS using awk:

BEGIN{FS="[; ]"}
{ for(i=2; i<=NF; i++) {
if(!($i in h)) {h[$i]=++n;v[n]=$i}
g[$i]=g[$i]"/"$1
}
} END{
print "/unicode <<"
for(i=1;i<=n;i++) print "\t16#"v[i]"["g[v[i]]"/uni"toupper(v[i])"]"
print ">> def"
}

Adobe's table is turned into this:

/unicode <<
16#0041[/A/uni0041]
16#00C6[/AE/uni00C6]
...
16#305A[/zuhiragana/uni305A]
16#30BA[/zukatakana/uni30BA]
>> def

The crux of printing Unicode code points is to find which of the
possible glyphs the current font defines. I search currentfont's
CharStrings.

% look for one of the glyphs in fontdict's CharStrings
% [/glyph ...] fontdict chooseglyph /glyph true
% false
/chooseglyph {
/CharStrings get exch % the glyphs defined in fontdict
false 3 1 roll % assume we don't find a glyph
% false CharStrings [glyphs]
{ 2 copy known {true 4 2 roll exch pop exit}{pop} ifelse } forall
pop % remove CharStrings
} def

I've noticed that Symbol sometimes contains glyphs that other fonts
don't, so, if I don't find a glyph in currentfont I look through Symbol.

I thought it might be a good idea to also try ZapfDingbats. In
retrospect, that might be a red herring.

Adobe also publish a table like the Unicode table, giving the names of
that font's glyphs. It's at the same place, and converts using the same
awk:

/zapf <<
16#275E[/a100/uni275E]
16#2761[/a101/uni2761]
...
16#275D[/a99/uni275D]
16#2720[/a9/uni2720]
>> def

This is the code which prints a unicode code point (or .notdef if a
glyph cannot be found):

% SPDX-License-Identifier: LGPL-2.1-or-later
% % Copyright (c) 2022 by davidnewall.com. All rights reserved.

% print a single unicode codepoint:
% integer unicodeshow -
/unicodeshow {
% load array of known glyph names for this code point
unicode 1 index known
{unicode exch get} % array of possible glyphs
{ pop []} % unknown code point
ifelse
{
dup currentfont chooseglyph { glyphshow exit } if
dup /ZapfDingbats findfont chooseglyph {
currentfont exch /ZapfDingbats currentfontsize selectfont
glyphshow setfont exit } if
dup /Symbol findfont chooseglyph {
currentfont exch /Symbol currentfontsize selectfont
glyphshow setfont exit } if
/.notdef glyphshow exit
} loop
pop
} def

I get the current font size using this:

/currentfontsize {
currentfont dup /OrigFont get
2 { /FontMatrix get 3 get exch } repeat div
} bind def

Finally (at last!), to print a UTF-8 string:

/utfshow {
UTF8_ACCEPT 0 UTF8_ACCEPT % prev codep current
4 -1 roll {
decode
dup UTF8_ACCEPT eq { 1 index unicodeshow } if
dup UTF8_REJECT eq {
(%% Bad UTF-8 sequence\n) print pop
UTF8_ACCEPT /.notdef glyphshow } if
3 -1 roll pop dup 3 1 roll % prev = current
} forall
pop pop pop
} def

Regards,

David

Re: Printing UTF8 (Unicode)

<20220121142303.00000241@cvkm.cz>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=119&group=comp.lang.postscript#119

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: carlos@cvkm.cz (Carlos)
Newsgroups: comp.lang.postscript
Subject: Re: Printing UTF8 (Unicode)
Date: Fri, 21 Jan 2022 14:23:03 +0100
Lines: 30
Message-ID: <20220121142303.00000241@cvkm.cz>
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Trace: individual.net QCZcOe4+X6wOTj3kkAHt8gkRejqGFYAeBYTIHc9NKMisttpym3
Cancel-Lock: sha1:WYUTISB4GYgSKKVzm9LXivJM97g=
X-Newsreader: Claws Mail 4.0.0 (GTK+ 3.24.29; x86_64-w64-mingw32)
 by: Carlos - Fri, 21 Jan 2022 13:23 UTC

David Newall <davidn@davidnewall.com>:

> Hello All,
>
> I've written some PostScript to allow me to print UTF8-encoded
> strings:

This is great!

[...]
> % print a single unicode codepoint:
> % integer unicodeshow -
> /unicodeshow {
[...]
> /utfshow {
> UTF8_ACCEPT 0 UTF8_ACCEPT % prev codep current
> 4 -1 roll {
> decode
> dup UTF8_ACCEPT eq { 1 index unicodeshow } if
[...]

Doesn't "x glyphshow y glyphshow" lose the kerning between x and y?
(I'm not really sure)

If it does, an alternative could be to create a (probably composite)
temporary font out of the characters used in the string and "show" a
reencoded string using that font. Too complicated though :)

Carlos.

Re: Printing UTF8 (Unicode)

<61eb5d97$1@news.ausics.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=120&group=comp.lang.postscript#120

  copy link   Newsgroups: comp.lang.postscript
Subject: Re: Printing UTF8 (Unicode)
Newsgroups: comp.lang.postscript
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
<20220121142303.00000241@cvkm.cz>
From: davidn@davidnewall.com (David Newall)
Date: Sat, 22 Jan 2022 12:27:49 +1100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <20220121142303.00000241@cvkm.cz>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <61eb5d97$1@news.ausics.net>
Organization: Ausics - https://www.ausics.net
Lines: 15
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!news.bbs.nz!news.ausics.net!not-for-mail
 by: David Newall - Sat, 22 Jan 2022 01:27 UTC

On 22/1/22 12:23 am, Carlos wrote:
> David Newall <davidn@davidnewall.com>:
>> I've written some PostScript to allow me to print UTF8-encoded
>> strings:
>
> This is great!

Thank you. It seemed a problem which needed to be solved. I hope I've
made a start that's good enough to criticize.

> Doesn't "x glyphshow y glyphshow" lose the kerning between x and y?
> (I'm not really sure)

PostScript doesn't automatically kern. There are operators you can use
to do that, but it is something you have to do.

Re: Printing UTF8 (Unicode)

<61ecbe1b$1@news.ausics.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=123&group=comp.lang.postscript#123

  copy link   Newsgroups: comp.lang.postscript
Subject: Re: Printing UTF8 (Unicode)
Newsgroups: comp.lang.postscript
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
From: davidn@davidnewall.com (David Newall)
Date: Sun, 23 Jan 2022 13:31:54 +1100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <61ecbe1b$1@news.ausics.net>
Organization: Ausics - https://www.ausics.net
Lines: 41
X-Complaints: abuse@ausics.net
Path: i2pn2.org!rocksolid2!news.neodome.net!csiph.com!news.bbs.nz!news.ausics.net!not-for-mail
 by: David Newall - Sun, 23 Jan 2022 02:31 UTC

On 21/1/22 9:56 pm, David Newall wrote:
> I've written some PostScript to allow me to print UTF8-encoded strings

There was an error in unicodeshow. I wasn't attempting /uniXXXX for
codepoints that weren't in Adobe's table.

Apparently it's also not uncommon to use /uXXXX through /uXXXXXX (4 to 6
hex digits), so I check for those, too.

% integer unicodeshow - show glyph for unicode code point
/unicodeshow {
% load array of known glyph names for this code point, supplemented
% with /uXXXXXX (4 - 6 hex chars) and /uniXXXX (when codepoint fits
% in 4 hex chars)
[
unicode 2 index known {unicode 2 index get aload pop} if
% convert number to hex for /uXXXX.. and /uniXXXX
(0000000) 6 counttomark 1 add index % string index number
{
% number must fit in 6 hex digits
1 index 0 eq {
pop pop pop
/.error where {pop .error} {signalerror} ifelse
} if
dup 0 eq { pop exit } if
3 copy 16 mod dup 9 gt { 55 } { 48 } ifelse add put
16 idiv exch 1 sub exch
} loop
% require min 4 hex digits
dup 2 gt { -1 3 { 1 index exch 16#30 put } for 2 } if
% /uXXXX - /uXXXXXX
2 copy 7 1 index sub getinterval dup 0 16#75 put cvn 3 1 roll
% /uniXXXX
2 eq { dup 0 (uni) putinterval dup cvn exch } if
pop
] exch pop
%[(candidates)2 index]== pstack(---)==
dup currentfont chooseglyph not { /.notdef } if glyphshow
pop
} bind def

Printing UTF8 (Unicode) - opinions please

<61ecc714$1@news.ausics.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=124&group=comp.lang.postscript#124

  copy link   Newsgroups: comp.lang.postscript
Subject: Printing UTF8 (Unicode) - opinions please
Newsgroups: comp.lang.postscript
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
From: davidn@davidnewall.com (David Newall)
Date: Sun, 23 Jan 2022 14:10:12 +1100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <61ecc714$1@news.ausics.net>
Organization: Ausics - https://www.ausics.net
Lines: 52
X-Complaints: abuse@ausics.net
Path: i2pn2.org!rocksolid2!news.neodome.net!tncsrv06.tnetconsulting.net!news.bbs.nz!news.ausics.net!not-for-mail
 by: David Newall - Sun, 23 Jan 2022 03:10 UTC

Hi All,

I'm soliciting opinions...

On 21/1/22 9:56 pm, David Newall wrote:
> I've written some PostScript to allow me to print UTF8-encoded strings
> ...
> I also use a table which Adobe published ("UNICODE translation table for
> non-ASCII characters"), which they say is for going from a glyph name to
> a Unicode codepoint.  I (ab)use it in the reverse direction.  I turned
> it into a dictionary keyed on the codepoint.

Many (most?) fonts have glyphs which aren't in Adobe's table, or which
are named differently. Fontforge can write a table of glyphs in a font
and their corresponding codepoints. Using that table, unicodeshow looks
more like this:

% lookup a unicode codepoint (int) in a list of known glyphs (dict)
% and display the glyph found.
% dict int unicodeshow -
/unicodeshow {
2 copy known { get } { pop pop /.notdef } ifelse glyphshow
} bind def

While this looks much neater, it requires pre-generating a dictionary
for each font used.

I can't decide which approach is better.

I'm not delighted by needing to add a dictionary that's specific to the
current font to utfshow and unicodeshow because it feels wrong.

I suppose whatever fonts are used to print unicode will be embedded in
the PS, so I could add the table to each font's dictionary. I wonder if
that would cause confusion to anybody reading the code:

/unicodeshow { % int unicodeshow -
currentfont /unicode 2 copy known not {
pop pop /unicodeshow cvx /invalidfont
/.error where {pop .error} {signalerror} ifelse
} if
get exch 2 copy known { get } { pop pop /.notdef } ifelse glyphshow
} bind def

Maybe that's not so awful.

Opinions? Would adding to a font dictionary going to break things?
(I'm looking at you, Acrobat and Distiller.)

Regards,

David

Re: Printing UTF8 (Unicode)

<20220123133511.00003a2f@cvkm.cz>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=125&group=comp.lang.postscript#125

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: carlos@cvkm.cz (Carlos)
Newsgroups: comp.lang.postscript
Subject: Re: Printing UTF8 (Unicode)
Date: Sun, 23 Jan 2022 13:35:11 +0100
Lines: 41
Message-ID: <20220123133511.00003a2f@cvkm.cz>
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
<61ecbe1b$1@news.ausics.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
X-Trace: individual.net E63G5/tDdyDH4O0jQw/AsArIVlYprvNgZVxUj6FQhYv/KefV8J
Cancel-Lock: sha1:2xHYdiEL3ZJbloOzTGNFkcc7Zq4=
X-Newsreader: Claws Mail 4.0.0 (GTK+ 3.24.29; x86_64-w64-mingw32)
 by: Carlos - Sun, 23 Jan 2022 12:35 UTC

V Sun, 23 Jan 2022 13:31:54 +1100
David Newall <davidn@davidnewall.com> napsáno:

> On 21/1/22 9:56 pm, David Newall wrote:
> > I've written some PostScript to allow me to print UTF8-encoded
> > strings
>
> There was an error in unicodeshow. I wasn't attempting /uniXXXX for
> codepoints that weren't in Adobe's table.
>
> Apparently it's also not uncommon to use /uXXXX through /uXXXXXX (4
> to 6 hex digits), so I check for those, too.

Adobe's table (or one similar to it) is included in Ghostscript
(AdobeGlyphList), and maybe other interpreters, too.

Here's an old snippet that gets a glyph name (or uniXXXX) based on its
code:

/RevList AdobeGlyphList length dict dup begin
AdobeGlyphList { exch def } forall
end def
% code -- (uniXXXX)
/uniX { 16 6 string cvrs dup length 7 exch sub exch
(uni0000) 7 string copy dup 4 2 roll putinterval } def
% font code -- glyphname
/unitoname { dup RevList exch known
{ RevList exch get }
{ uniX cvn } ifelse
exch /CharStrings get 1 index known not
{ pop /.notdef } if
} def

(It doesn't contemplate several names per code... I thought it was a
1-1 relationship.)

If you know you are dealing with modern fonts that include the uni/u
aliases, you can get rid of the Adobe table lookup altogether... You
don't need the canonical glyph names for those fonts.

Re: Printing UTF8 (Unicode) - opinions please

<20220123135610.00003ecb@cvkm.cz>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=126&group=comp.lang.postscript#126

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: carlos@cvkm.cz (Carlos)
Newsgroups: comp.lang.postscript
Subject: Re: Printing UTF8 (Unicode) - opinions please
Date: Sun, 23 Jan 2022 13:56:10 +0100
Lines: 53
Message-ID: <20220123135610.00003ecb@cvkm.cz>
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
<61ecc714$1@news.ausics.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
X-Trace: individual.net sjRzV016/W5/p45MzT+rzA89DTTgNyCPgbhC3rPXKHGpCYrXoF
Cancel-Lock: sha1:chxWWR0JBdsQrCoijJksZQujyRA=
X-Newsreader: Claws Mail 4.0.0 (GTK+ 3.24.29; x86_64-w64-mingw32)
 by: Carlos - Sun, 23 Jan 2022 12:56 UTC

V Sun, 23 Jan 2022 14:10:12 +1100
David Newall <davidn@davidnewall.com> napsáno:

> Hi All,
>
> I'm soliciting opinions...
>
> On 21/1/22 9:56 pm, David Newall wrote:
> > I've written some PostScript to allow me to print UTF8-encoded
> > strings ...
> > I also use a table which Adobe published ("UNICODE translation
> > table for non-ASCII characters"), which they say is for going from
> > a glyph name to a Unicode codepoint.  I (ab)use it in the reverse
> > direction.  I turned it into a dictionary keyed on the codepoint.
> Many (most?) fonts have glyphs which aren't in Adobe's table, or which
> are named differently. Fontforge can write a table of glyphs in a
> font and their corresponding codepoints. Using that table,
> unicodeshow looks more like this:
>
> % lookup a unicode codepoint (int) in a list of known glyphs (dict)
> % and display the glyph found.
> % dict int unicodeshow -
> /unicodeshow {
> 2 copy known { get } { pop pop /.notdef } ifelse glyphshow
> } bind def
>
> While this looks much neater, it requires pre-generating a dictionary
> for each font used.
>
> I can't decide which approach is better.

I think if a font has a mapping between unicode points and glyphs that
you can extract (with Fontforge or whatever), then it surely also has
uni/u aliases. The Adobe table is for older fonts that don't have them,
so it's the only lookup table you need.

> I'm not delighted by needing to add a dictionary that's specific to
> the current font to utfshow and unicodeshow because it feels wrong.

Also, having to pre-process the files to insert the tables is not good.

[...]
> Opinions? Would adding to a font dictionary going to break things?
> (I'm looking at you, Acrobat and Distiller.)

Don't know about that, I only use Ghostscript. But if the reason to add
a lookup is speed, a possible optimization could be not to call
unicodeshow on each codepoint, but identify string intervals where all
bytes are either <= 127 or > 127. Call show on the former, and utfshow
on the latter.

C.

Re: Printing UTF8 (Unicode) - opinions please

<e063f3eb-b255-44d6-93d8-5123fb38d463n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=127&group=comp.lang.postscript#127

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:a05:6214:e6e:: with SMTP id jz14mr15599008qvb.4.1643041993666;
Mon, 24 Jan 2022 08:33:13 -0800 (PST)
X-Received: by 2002:a9d:4d06:: with SMTP id n6mr1817659otf.4.1643041993256;
Mon, 24 Jan 2022 08:33:13 -0800 (PST)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!feeder1.cambriumusenet.nl!feed.tweak.nl!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Mon, 24 Jan 2022 08:33:13 -0800 (PST)
In-Reply-To: <61ecc714$1@news.ausics.net>
Injection-Info: google-groups.googlegroups.com; posting-host=97.87.183.68; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 97.87.183.68
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com> <61ecc714$1@news.ausics.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e063f3eb-b255-44d6-93d8-5123fb38d463n@googlegroups.com>
Subject: Re: Printing UTF8 (Unicode) - opinions please
From: luser.droog@gmail.com (luser droog)
Injection-Date: Mon, 24 Jan 2022 16:33:13 +0000
Content-Type: text/plain; charset="UTF-8"
 by: luser droog - Mon, 24 Jan 2022 16:33 UTC

On Saturday, January 22, 2022 at 9:10:23 PM UTC-6, David Newall wrote:

> Opinions? Would adding to a font dictionary going to break things?
> (I'm looking at you, Acrobat and Distiller.)
>
> Regards,
>
> David

I don't see how that could be a problem unless the additions conflict
with existing names. It's possible that findfont will give you a dictionary
without write access. But you could copy everything into a new dictionary
and then call `definefont` on that and you should be good to go. (Take
care *not* to copy the /UniqueID key since definefont will want to
generate a new one.)

Re: Printing UTF8 (Unicode) - opinions please

<0f6bec57-97cb-4fbd-b666-b26f31c5814cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=128&group=comp.lang.postscript#128

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:a05:6214:2307:: with SMTP id gc7mr15388581qvb.7.1643042279321;
Mon, 24 Jan 2022 08:37:59 -0800 (PST)
X-Received: by 2002:a05:6830:1aea:: with SMTP id c10mr4112910otd.57.1643042279093;
Mon, 24 Jan 2022 08:37:59 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Mon, 24 Jan 2022 08:37:58 -0800 (PST)
In-Reply-To: <20220123135610.00003ecb@cvkm.cz>
Injection-Info: google-groups.googlegroups.com; posting-host=97.87.183.68; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 97.87.183.68
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
<61ecc714$1@news.ausics.net> <20220123135610.00003ecb@cvkm.cz>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0f6bec57-97cb-4fbd-b666-b26f31c5814cn@googlegroups.com>
Subject: Re: Printing UTF8 (Unicode) - opinions please
From: luser.droog@gmail.com (luser droog)
Injection-Date: Mon, 24 Jan 2022 16:37:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 20
 by: luser droog - Mon, 24 Jan 2022 16:37 UTC

On Sunday, January 23, 2022 at 6:56:13 AM UTC-6, Carlos wrote:
> V Sun, 23 Jan 2022 14:10:12 +1100
> David Newall <dav...@davidnewall.com> napsáno:

> [...]
> > Opinions? Would adding to a font dictionary going to break things?
> > (I'm looking at you, Acrobat and Distiller.)
> Don't know about that, I only use Ghostscript. But if the reason to add
> a lookup is speed, a possible optimization could be not to call
> unicodeshow on each codepoint, but identify string intervals where all
> bytes are either <= 127 or > 127. Call show on the former, and utfshow
> on the latter.
>
> C.

Or if speed is not a problem, you could implement a replacement for
kshow instead of show. Then the whole show family can easily be built
off of that.

Re: Printing UTF8 (Unicode)

<61f0c70f$1@news.ausics.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=133&group=comp.lang.postscript#133

  copy link   Newsgroups: comp.lang.postscript
Subject: Re: Printing UTF8 (Unicode)
Newsgroups: comp.lang.postscript
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
<61ecbe1b$1@news.ausics.net> <20220123133511.00003a2f@cvkm.cz>
From: davidn@davidnewall.com (David Newall)
Date: Wed, 26 Jan 2022 14:59:09 +1100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <20220123133511.00003a2f@cvkm.cz>
Content-Type: text/plain; charset=iso-8859-2; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <61f0c70f$1@news.ausics.net>
Organization: Ausics - https://www.ausics.net
Lines: 74
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news.ausics.net!not-for-mail
 by: David Newall - Wed, 26 Jan 2022 03:59 UTC

Hi Carlos,

Thanks for your very useful feedback.

I will say, up-front, that using Adobe Glyph List (glyphlist.txt found
at https://github.com/adobe-type-tools/agl-aglfn) is often sufficient,
depending on what unicode values need to be painted and what font is to
be used. But I want to do better than "often".

I'm using https://antofthy.gitlab.io/info/data/utf8-demo.txt to test my
code. It's coverage is ... extensive (and my current code seems to work
for all of it -- font withstanding.)

On 23/1/22 11:35 pm, Carlos wrote:
> Adobe's table (or one similar to it) is included in Ghostscript
> (AdobeGlyphList), and maybe other interpreters, too.

I didn't know about AdobeGlyphList. The one in Ghostscript (9.50) has
multiple names for some unicode values. Converseley Adobe Glyph List
(glyphlist.txt found at //github.com/adobe-type-tools/agl-aglfn)
contains multiple values for some names.

No font is guaranteed to use any of these names and many fonts that I've
examined use different names for unicode values (and different values
for some names.)

> If you know you are dealing with modern fonts that include the uni/u
> aliases, you can get rid of the Adobe table lookup altogether... You
> don't need the canonical glyph names for those fonts.

No font that I've examined includes uni/u names for every glyph, or even
for most glyphs.

One can't rely on any pre-determined glyph name, nor any pre-determined
lookup table. What a mess.

On 23/1/22 11:56 pm, Carlos wrote:
> I think if a font has a mapping between unicode points and glyphs that
> you can extract (with Fontforge or whatever), then it surely also has
> uni/u aliases. The Adobe table is for older fonts that don't have them,
> so it's the only lookup table you need.

I wish that were true, but it's not.

After your comment about older fonts, I examined Courier, a Type 1 font
(https://web.archive.org/web/20010617080950/http://www.ctan.org/tex-archive/fonts/psfonts/courier/).
The CharStrings array breaks my
assumptions and my code completely fails.

>> I'm not delighted by needing to add a dictionary that's specific to
>> the current font to utfshow and unicodeshow because it feels wrong.
>
> Also, having to pre-process the files to insert the tables is not good.

I completely agree. I don't like it. I want to be able to use any font
without preprocessing, but I can't see how.

> a possible optimization could be not to call
> unicodeshow on each codepoint, but identify string intervals where all
> bytes are either <= 127 or > 127. Call show on the former, and utfshow
> on the latter.

Agreed. Ps2pdf slows down dramatically with large number of glyphshows.
https://antofthy.gitlab.io/info/data/utf8-demo.txt, which is 50K, takes
4 minutes to process using utf8show and ps2pdf. The utf8-decode phase
takes 20ms and Ghostscript takes 510ms.

For anyone interested, https://davidnewall/software/utf8show. It's
still a work-in-progress.

David

Re: Printing UTF8 (Unicode) - opinions please

<61f0c8d1$1@news.ausics.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=134&group=comp.lang.postscript#134

  copy link   Newsgroups: comp.lang.postscript
Subject: Re: Printing UTF8 (Unicode) - opinions please
Newsgroups: comp.lang.postscript
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
<61ecc714$1@news.ausics.net>
<e063f3eb-b255-44d6-93d8-5123fb38d463n@googlegroups.com>
From: davidn@davidnewall.com (David Newall)
Date: Wed, 26 Jan 2022 15:06:39 +1100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <e063f3eb-b255-44d6-93d8-5123fb38d463n@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <61f0c8d1$1@news.ausics.net>
Organization: Ausics - https://www.ausics.net
Lines: 22
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news.ausics.net!not-for-mail
 by: David Newall - Wed, 26 Jan 2022 04:06 UTC

On 25/1/22 3:33 am, luser droog wrote:
> On Saturday, January 22, 2022 at 9:10:23 PM UTC-6, David Newall wrote:
>
>> Opinions? Would adding to a font dictionary going to break things?
>> (I'm looking at you, Acrobat and Distiller.)
>
> I don't see how that could be a problem unless the additions conflict
> with existing names. It's possible that findfont will give you a dictionary
> without write access. But you could copy everything into a new dictionary
> and then call `definefont` on that and you should be good to go.

Thanks. I can't see how it could, either, but I have little experience
with actual Adobe software, as I use Ghostscript for almost all of my
PostScript work.

I might have been unclear in "adding to a font dictionary". I'm not
contemplating /name findfont { modify } definefont, but fontforge font;
awk '...' font.g2n; vi font.t42.

Regards,

David

Re: Printing UTF8 (Unicode)

<20220210150537.00002cd7@cvkm.cz>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=142&group=comp.lang.postscript#142

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: carlos@cvkm.cz (Carlos)
Newsgroups: comp.lang.postscript
Subject: Re: Printing UTF8 (Unicode)
Date: Thu, 10 Feb 2022 15:05:37 +0100
Lines: 28
Message-ID: <20220210150537.00002cd7@cvkm.cz>
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
<61ecbe1b$1@news.ausics.net>
<20220123133511.00003a2f@cvkm.cz>
<61f0c70f$1@news.ausics.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Trace: individual.net qx3BtfJuAhjQuCShDB+h+Q6+oZ0zPNbnDshecdMIM1YQRBxYLF
Cancel-Lock: sha1:mwCZHxW5j2kuFqqBhNNt/Q+y8Ys=
X-Newsreader: Claws Mail 4.0.0 (GTK+ 3.24.29; x86_64-w64-mingw32)
 by: Carlos - Thu, 10 Feb 2022 14:05 UTC

On Wed, 26 Jan 2022 14:59:09 +1100
David Newall <davidn@davidnewall.com> wrote:
> No font is guaranteed to use any of these names and many fonts that
> I've examined use different names for unicode values (and different
> values for some names.)
>
> > If you know you are dealing with modern fonts that include the uni/u
> > aliases, you can get rid of the Adobe table lookup altogether... You
> > don't need the canonical glyph names for those fonts.
>
> No font that I've examined includes uni/u names for every glyph, or
> even for most glyphs.
>
> One can't rely on any pre-determined glyph name, nor any
> pre-determined lookup table. What a mess.

Well, that's disappointing...

> After your comment about older fonts, I examined Courier, a Type 1
> font
> (https://web.archive.org/web/20010617080950/http://www.ctan.org/tex-archive/fonts/psfonts/courier/).
> The CharStrings array breaks my assumptions and my code completely
> fails.

What assumptions?

C.

Re: Printing UTF8 (Unicode)

<2b68a254-4a37-3e29-17c1-015bdac58164@davidnewall.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=145&group=comp.lang.postscript#145

  copy link   Newsgroups: comp.lang.postscript
Message-ID: <2b68a254-4a37-3e29-17c1-015bdac58164@davidnewall.com>
Date: Wed, 16 Feb 2022 13:55:22 +1100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Subject: Re: Printing UTF8 (Unicode)
Content-Language: en-US
To: Carlos <carlos@cvkm.cz>
Newsgroups: comp.lang.postscript
References: <4fe53d50-e66a-82b8-48fd-d0928e149698@davidnewall.com>
<61ecbe1b$1@news.ausics.net> <20220123133511.00003a2f@cvkm.cz>
<61f0c70f$1@news.ausics.net> <20220210150537.00002cd7@cvkm.cz>
From: davidn@davidnewall.com (David Newall)
In-Reply-To: <20220210150537.00002cd7@cvkm.cz>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Organization: Ausics - https://www.ausics.net
Lines: 17
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.bbs.nz!news.ausics.net!not-for-mail
 by: David Newall - Wed, 16 Feb 2022 02:55 UTC

On 11/2/22 01:05, Carlos wrote:
>> After your comment about older fonts, I examined Courier, a Type 1
>> font
>> (https://web.archive.org/web/20010617080950/http://www.ctan.org/tex-archive/fonts/psfonts/courier/).
>> The CharStrings array breaks my assumptions and my code completely
>> fails.
> What assumptions?

The issue wasn't type 1 fonts, after all, that was just the thread I
pulled at. The issue is CharStrings. Not all fonts have one. In
particular, type 3 fonts don't. Type 3 fonts have a BuildGlyph or
BuildChar procedure which often use a CharProcs dictionary, but that's
not guaranteed.

I now taking the position that a font must have CharStrings or CharProcs
to be used with this body of code. In practice that's unlikely to be a
problem.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor