June is right. I will go further and say that if your chosen font is not consistently fixed-width, your efforts to get tidy boxes are doomed to failure. None of the "fixed width" fonts that I've tried (on the Macintosh) are consistently fixed width -- certainly not over the C-J-K codespaces. The matter is discussed in: http://www.jsoftware.com/jwiki/Addons/format/sbox Nor is the width-ratio for (Chinese):(Latin) always 2:1, as suggested in the past in this forum. When I've tried it, the ratio is more like 3:5. The above link shows an example. Let me stress that the problem is not confined to C-J-K characters. If your app contains any "fancy" glyphs, like arrows, planetary symbols, electronics symbols or the zoology male/female signs, then all the common fixed-width fonts are likely to let you down. Several of them share glyphs in many of the less common codespaces. This may be due to ad-hoc decisions by the platform vendors to cobble-up missing glyphs from a "related" font under-the-covers. Microsoft's IE used to be very bad about this wherever arrows were concerned.
On Wed, Apr 30, 2014 at 9:51 AM, June Kim (김창준) <[email protected]> wrote: > This approach won't work with different width characters(such as in Korean) > in unicode. (Some characters are wide -- taking two-character space, others > narrow -- taking one-character space) > > > On Wed, Apr 30, 2014 at 6:24 AM, Don Guinn <[email protected]> wrote: > > > This has bugged me for quite a while too. I tried making sure all text > was > > unicode. Didn't help. The text was converted to U8 before determining the > > size of the boxes, still messing up the alignment. > > > > > > This thread prompted me to think about the problem again. Instead of > trying > > to build the entire logic to box I thought of a different approach. > Convert > > the text to display boxed to literal without any U8 characters. Any > > character will do. I chose 'x'. Then the boxing works just fine. Format > the > > boxed 'x's into a literal array. Then take the data from the original, > make > > sure it is all unicode and replace the 'x's with this data. A little work > > was needed to reorder the data for ranks greater than 1. > > > > > > This gave me a chance to study L: and S: as they simplified doing this. > It > > seems to work for fixed-width fonts. Variable width fonts still mess up > > alignment. > > > > > > box=:3 : 0 > > > > to_uni=.(7 u:"1":)`]@.(131072=3!:0) > > > > try. ts=.;(<@,)S:0 t=.to_uni L:0 y catch. ts=.0 end. > > > > if. +./131072 32~:(3!:0)&>ts;<y do. y return. end. > > > > ts=.' '(I.ts e. TAB,CR,LF)}ts > > > > inc=.(3 : 'u:box_n=:>:box_n')"0 > > > > i=.I.'x'=,tx=.":('x'"0)L:0 t > > > > box_n=:n1=.a.i.'@' > > > > i=.i/:n1(<#]),3 u: 7 u:"1":(inc)L:0 t > > > > ($tx)$ts i},tx > > > > ) > > > > > > > > tst=:(2 3$7 u:'ABCDΣF');i.3 4 5 > > > > > > > > box tst > > > > ┌───┬──────────────┐ > > > > │ABC│ 0 1 2 3 4│ > > > > │DΣF│ 5 6 7 8 9│ > > > > │ │10 11 12 13 14│ > > > > │ │15 16 17 18 19│ > > > > │ │ │ > > > > │ │20 21 22 23 24│ > > > > │ │25 26 27 28 29│ > > > > │ │30 31 32 33 34│ > > > > │ │35 36 37 38 39│ > > > > │ │ │ > > > > │ │40 41 42 43 44│ > > > > │ │45 46 47 48 49│ > > > > │ │50 51 52 53 54│ > > > > │ │55 56 57 58 59│ > > > > └───┴──────────────┘ > > > > > > > > The alignment in your browser may not be perfect, but it looked good in > my > > ijx session. > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
