| 1 |
% |
| 2 |
% |
| 3 |
% change file of psout.w for jMetaPost (CWEB version) |
| 4 |
% Akira Kakuto (translated the WEB version) |
| 5 |
% |
| 6 |
% |
| 7 |
|
| 8 |
@x |
| 9 |
#include <math.h> |
| 10 |
@y |
| 11 |
#include <math.h> |
| 12 |
#include <ptexenc/ptexenc.h> |
| 13 |
#ifdef UPMP |
| 14 |
#include <ptexenc/unicode.h> |
| 15 |
#endif |
| 16 |
@z |
| 17 |
|
| 18 |
% Treat all Kanji fonts as used |
| 19 |
@x |
| 20 |
if ( mp->font_info[p].qqqq.b3==mp_used ) |
| 21 |
@y |
| 22 |
if ( mp->font_info[p].qqqq.b3==mp_used || mp->font_id[f]!=0) |
| 23 |
@z |
| 24 |
|
| 25 |
% |
| 26 |
% Kanji string output |
| 27 |
@x |
| 28 |
static void mp_print_initial_comment(MP mp,mp_edge_object *hh, int prologues); |
| 29 |
@y |
| 30 |
static void mp_print_initial_comment(MP mp,mp_edge_object *hh, int prologues); |
| 31 |
|
| 32 |
#define Hi(x) (((x) >> 8) & 0xff) |
| 33 |
#define Lo(x) ((x) & 0xff) |
| 34 |
|
| 35 |
@ @c |
| 36 |
static void mp_ps_kanji_string_out (MP mp, char *s) |
| 37 |
{ |
| 38 |
int i, c; |
| 39 |
size_t len; |
| 40 |
|
| 41 |
len = strlen(s); |
| 42 |
i=0; |
| 43 |
mp_ps_print(mp, "<"); |
| 44 |
while (i<len) { |
| 45 |
if ( mp->ps->ps_offset+5>mp->max_print_line ) |
| 46 |
mp_ps_print_ln(mp); |
| 47 |
#ifdef UPMP |
| 48 |
c=toDVI(fromBUFF((unsigned char*)s, len, i)); |
| 49 |
i=i+multistrlen((unsigned char*)s, len, i); |
| 50 |
if (isinternalUPTEX() && c>65535) { |
| 51 |
int cx=UTF32toUTF16HS(c); /* High surrogate */ |
| 52 |
mp_hex_digit_out(mp, Hi(cx) / 16); |
| 53 |
mp_hex_digit_out(mp, Hi(cx) % 16); |
| 54 |
mp_hex_digit_out(mp, Lo(cx) / 16); |
| 55 |
mp_hex_digit_out(mp, Lo(cx) % 16); |
| 56 |
c=UTF32toUTF16LS(c); /* Low surrogate */ |
| 57 |
} |
| 58 |
#else |
| 59 |
c=toDVI(fromBUFF((unsigned char*)s, i+2, i)); |
| 60 |
i=i+2; |
| 61 |
#endif |
| 62 |
mp_hex_digit_out(mp, Hi(c) / 16); |
| 63 |
mp_hex_digit_out(mp, Hi(c) % 16); |
| 64 |
mp_hex_digit_out(mp, Lo(c) / 16); |
| 65 |
mp_hex_digit_out(mp, Lo(c) % 16); |
| 66 |
}; |
| 67 |
mp_ps_print(mp, ">"); |
| 68 |
}; |
| 69 |
@z |
| 70 |
|
| 71 |
@x |
| 72 |
mp_ps_print_nl(mp, "%%Creator: MetaPost "); |
| 73 |
@y |
| 74 |
mp_ps_print_nl(mp, "%%Creator: MetaPost ("@= @>P_UP@= @>"MetaPost) "); |
| 75 |
@z |
| 76 |
|
| 77 |
% |
| 78 |
% Call Kanji string output routine if the font is JFM. |
| 79 |
@x |
| 80 |
mp_ps_string_out(mp, gr_text_p(p),gr_text_l(p)); |
| 81 |
@y |
| 82 |
if (mp->font_id[gr_font_n(p)]!=0) |
| 83 |
mp_ps_kanji_string_out(mp, gr_text_p(p)); |
| 84 |
else |
| 85 |
mp_ps_string_out(mp, gr_text_p(p),gr_text_l(p)); |
| 86 |
@z |