pmattes / x3270

Family of IBM 3270 emulators
46 stars 18 forks source link

APL Glyphs #10

Open jibanes opened 3 years ago

jibanes commented 3 years ago

x3270 ( suite3270-4.0ga12-src.tgz ) on debian amd64 ( x86_64 ) with fonts-3270 installed.

x3270 v4.0ga12 Mon Nov 23 21:04:43 UTC 2020 jibanes
Build options: --enable-local-process
SBCS host code pages (with aliases):
cp037 (cp37, us, us-intl), cp273 (german), cp275 (brazilian), cp277 (norwegian), cp278 (finnish, swedish), cp280 (italian), cp284 (spanish), cp285 (uk), cp297 (french), cp424 (hebrew), cp500 (belgian), cp803 (hebrew-old), cp870 (polish, slovenian), cp871 (icelandic), cp875 (greek), cp880 (russian), cp1026 (turkish), cp1047, cp1140 (us-euro), cp1141 (german-euro), cp1142 (norwegian-euro), cp1143 (finnish-euro, swedish-euro), cp1144 (italian-euro), cp1145 (spanish-euro), cp1146 (uk-euro), cp1147 (french-euro), cp1148 (belgian-euro), cp1149 (icelandic-euro), cp1160 (thai), bracket (oldibm, bracket437)
DBCS host code pages (with aliases):
cp930 (japanese-kana), cp935 (simplified-chinese), cp937 (traditional-chinese), cp939 (japanese-latin), cp1388 (chinese-gb18030)

Copyright 1989-2020, Paul Mattes, GTRC and others.
See the source code or documentation for licensing details.
Distributed WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

While I can connect to (remote) apl process with x3270 (ran with the -apl argument) on the "telnet" port; I can type apl expressions with apl glyphs, and while they return the correct expression (meaning, the glyphs have properly been sent to the apl interpreter); they can not be displayed (they are displayed as a "black/empty character"). Certainly there must be a way to use a special font or something like that? The output of the apl processes is properly received, but the apl glyphs are not displayed by x3270.

pmattes commented 3 years ago

The default "3270" font (which should be part of the fonts-3270 package) includes all of the APL glyphs. Are you running with the 3270 font?

jibanes commented 3 years ago

I'm sorry it doesn't seem to load the 3270 font (or find it). When not using the -apl argument it displays a non APL charset, but when using -apl it displays black/blank characters, but they have the proper "apl" behavior. I've strace'd x3270 but it doesn't seem to use the 3270 font.

pmattes commented 3 years ago

I can't vouch for what Debian's fonts-3270 package actually does, but you should be able to see if the 3270 font is installed with this command: xlsfonts | grep 3270

There's also something that doesn't make sense to me here. You said that x3270 has different display behavior depending on whether you use the "-apl" command-line option or not. In older versions of x3270 (3.6 and earlier), the "-apl" option changed quite a bit of x3270's behavior, including the font and keymap. But in x3270 4.0 and up, the "-apl" option simply puts the keyboard and paste mode in APL mode at start-up -- the same thing as hitting Shift-Esc. APL keyboard mode is indicated by an Alpha (α) in the OIA. Are you sure you are running x3270 4.0 for these tests?

jibanes commented 3 years ago
3270
3270-12
3270-12bold
3270-20
3270-20bold
3270bold
3270gr
3270gt12
3270gt12bold
3270gt16
3270gt16bold
3270gt24
3270gt24bold
3270gt32
3270gt32bold
3270gt8
3270h

Options->Font shows that "3270 font (14 points)" is used. File->About x3270->Configuration shows that 3270cg-1a is used, locale codeset: UTF-8.

I have tried 3.x and 4.0 (may have misreported earlier results as I might have started 3.x instead of 4.0. Please allow me to clarify a few points: I am using IBM APL/2 here, I wrote some code that listens to a tcp port and accept APL-input, it accepts utf-8 glyphs (I think utf-8 precedes APL itself) and converts those to IBM APL/2's EBCDIC format "on-the-fly". Ideally, someday, when/if x3270 supports it, it will send graphics to 3270.

Perhaps I simply need to change the default emulator window font?

Now, as aforementioned, the APL glyphs do not display on x3270,

pmattes commented 3 years ago

The emulator font is already correct, if File -> About x3270 -> Configuration shows "Emulator font: 3270". That's the one that includes all of the APL glyphs, including the line-drawing characters.

Could you start x3270 with the "-trace" command-line option, and then run it against your code? It will leave a trace file in /tmp. If you can send me that file, it will tell me exactly what is being sent to x3270. Then we should be able to figure out what is going on.

jibanes commented 3 years ago

Thank you very much for looking into this, the file is attached. It connects to port localhost:5000 I typed the iota apl glyph then followed by 400, then it displayed the numbers from 1 to 400, then I exited the APL session with )OFF

trace.zip

pmattes commented 3 years ago

Okay, now I see what you are doing, and what is going wrong.

You are running x3270 in NVT mode. x3270 fully supports APL glyphs in 3270 mode, as long as you use the 14-point 3270 font. So if you connected to your host in 3270 mode (so what x3270 is seeing is EBCDIC, not UTF-8), everything would work.

When x3270 is in NVT mode, it uses UTF-8-encoded Unicode instead of EBCDIC. And it gets one side of that correct -- when you press Alt-i, for example, that is interpreted as the APL character 'iota', which is U+2373. That is sent to the host correctly as the UTF-8 sequence E2 8D B3.

However, when x3270 is asked to display (or echo) APL characters in NVT mode, its success is at the mercy of whatever font you are using. As far as I know, none of the old-style X11 fonts that x3270 uses support all of the APL2 glyphs. (Some of the ISO 10646 fonts support roughly half them.) Neither does it work with the 14-point 3270 font right now. For obscure historical reasons, the 3270 fonts use a non-standard encoding, and x3270 does not map U+2373 back to the right spot in the 3270cg encoding (0x011d). That's a bug.

The fix should be straightforward, and it will be in x3270 4.1.

jibanes commented 3 years ago

Thank you very much Paul!