Hi Alex,

> the usage of 'idx' in my implementation had a serious flaw: Because the
> unicod values in "glyphlist.txt" are partially sorted, we get a highly
> imbalanced tree:

Why does inserting and removing using 'idx' require manual rebalancing
using 'balance' in the first place?  I would expect insert and remove
to keep the tree balanced which should be more efficient than
rebalancing the whole tree.

It seems to me that to keep key/value pairs in the tree, the key must
be a symbol holding that value.  What if I want the keys to be numbers
or pairs?

> Then, to avoid the conflict with multiple values, I simply ignored all
> lines with multiple values, by checking with (member " " L). Does this
> sound reasonable? In this way the first entry in "lib/glyphlist.txt"
> will "win". At least this is the simplest solution ;-)
>
>> I would actually prefer keeping the complete mapping as in the
>> original code I sent.  That would allow searching through the fonts
>> for the right glyph.
>
> I see. For now I would like to stick with the simple version to see how
> it works out. I have to be very careful, as "lib/ps.l" is used heavily
> in several business applications.

Fair enough.  In the long-term, wouldn't it be better to put the glyph
related stuff into @lib/glyph.l and keep access to the full glyph <->
codepoint mapping?

# *Glyph *Codepoint

(in "lib/glyphlist.txt"
   (use (L N)
      (while (setq L (line))
         (unless (= '"#" (car L))
            (setq L (split L '";") N (pack (car L)))
            (for C (mapcar '((X) (char (hex (pack X)))) (split (cadr L) " "))
               (if (idx '*Glyph C)
                  (push (car @) N)
                  (set C (list N))
                  (idx '*Glyph C T) )
               (if (idx '*Codepoint N)
                  (push (car @) C)
                  (set N (list C))
                  (idx '*Codepoint N T) ) ) ) ) ) )

(balance '*Glyph (sort (idx '*Glyph)))
(balance '*Codepoint (sort (idx '*Codepoint)))

(de glyph (C)
   (val (car (idx '*Glyph C))) )

(de codepoint (C)
   (val (car (idx '*Codepoint C))) )

>> I prefer 'glyph' returning NIL instead of ".notdef".
>
> OK, me too. Is it not necessary?

It would be good to keep .notdef in the output postscript file so we
could use (or (glyph X) ".notdef") or (or (car (glyph X)) ".notdef")
in case 'glyph' returns a list.  (I don't think I want to output
".notdef" in pdf.)

Thank you,

Tomas
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to