Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #2566 > unrolled thread

wanted: kcharpath ...

Started byPeter Billam <peter@www.pjb.com.au>
First post2016-05-15 03:33 +0000
Last post2016-06-06 07:53 +0200
Articles 20 on this page of 23 — 3 participants

Back to article view | Back to comp.lang.postscript


Contents

  wanted: kcharpath ... Peter Billam <peter@www.pjb.com.au> - 2016-05-15 03:33 +0000
    Re: wanted: kcharpath ... luser- -droog <mijoryx@yahoo.com> - 2016-05-15 14:16 -0700
      Re: wanted: kcharpath ... Peter Billam <peter@www.pjb.com.au> - 2016-05-16 06:51 +0000
        Re: wanted: kcharpath ... Peter Billam <peter@www.pjb.com.au> - 2016-05-18 02:01 +0000
          Re: wanted: kcharpath ... luser- -droog <mijoryx@yahoo.com> - 2016-05-17 20:41 -0700
            Re: wanted: kcharpath ... luser- -droog <mijoryx@yahoo.com> - 2016-05-17 20:44 -0700
              Re: wanted: kcharpath ... Peter Billam <peter@www.pjb.com.au> - 2016-05-18 06:59 +0000
        Re: wanted: kcharpath ... luser- -droog <mijoryx@yahoo.com> - 2016-05-18 22:29 -0700
    Re: wanted: kcharpath ... Carlos <angus@quovadis.com.ar> - 2016-05-18 23:00 +0200
      Re: wanted: kcharpath ... Peter Billam <peter@www.pjb.com.au> - 2016-05-21 02:09 +0000
        Re: wanted: kcharpath ... Peter Billam <peter@www.pjb.com.au> - 2016-05-21 03:13 +0000
        Re: wanted: kcharpath ... Carlos <angus@quovadis.com.ar> - 2016-05-22 14:20 +0200
          Re: wanted: kcharpath ... Peter Billam <peter@www.pjb.com.au> - 2016-05-29 06:24 +0000
            Re: wanted: kcharpath ... luser- -droog <mijoryx@yahoo.com> - 2016-05-28 23:43 -0700
            Re: wanted: kcharpath ... luser- -droog <mijoryx@yahoo.com> - 2016-05-29 01:10 -0700
              from image to imagemask Peter Billam <peter@www.pjb.com.au> - 2016-05-31 08:51 +0000
                Re: from image to imagemask luser- -droog <mijoryx@yahoo.com> - 2016-06-01 00:53 -0700
                  Re: from image to imagemask luser- -droog <mijoryx@yahoo.com> - 2016-06-01 01:10 -0700
                    Re: from image to imagemask Peter Billam <peter@www.pjb.com.au> - 2016-06-02 01:26 +0000
                      Re: from image to imagemask Peter Billam <peter@www.pjb.com.au> - 2016-06-03 07:53 +0000
            Re: wanted: kcharpath ... Carlos <angus@quovadis.com.ar> - 2016-06-03 14:38 +0200
              Re: wanted: kcharpath ... Peter Billam <peter@www.pjb.com.au> - 2016-06-06 02:43 +0000
                Re: wanted: kcharpath ... Carlos <angus@quovadis.com.ar> - 2016-06-06 07:53 +0200

Page 1 of 2  [1] 2  Next page →


#2566 — wanted: kcharpath ...

FromPeter Billam <peter@www.pjb.com.au>
Date2016-05-15 03:33 +0000
Subjectwanted: kcharpath ...
Message-ID<slrnnjfrfs.2bk.peter@box8.pjb.com.au>
Greetings.  OK; so we have show and kshow...
  (a string) show
  { -2 0 rmoveto } (a string) kshow

and we have charpath ...
  gsave (a string) true charpath clip do_something_colourful grestore

but I haven't spotted its kerning equivalent :-(
  gsave { -2 0 rmoveto } (a string) true kcharpath
  clip do_something_colourful grestore

Is there another way to do this, like using cshow or something ?
Should I write kcharpath myself, looping along the string with `get`
and `charpath` and invoking proc ?  Has it been written already ?

Thanks, regards,
Peter

P.S. hope I got the code right ...

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [next] | [standalone]


#2567

Fromluser- -droog <mijoryx@yahoo.com>
Date2016-05-15 14:16 -0700
Message-ID<6c745d14-747c-4cda-884d-b86509a3f455@googlegroups.com>
In reply to#2566
On Saturday, May 14, 2016 at 10:33:16 PM UTC-5, Peter Billam wrote:
> Greetings.  OK; so we have show and kshow...
>   (a string) show
>   { -2 0 rmoveto } (a string) kshow
> 
> and we have charpath ...
>   gsave (a string) true charpath clip do_something_colourful grestore
> 
> but I haven't spotted its kerning equivalent :-(
>   gsave { -2 0 rmoveto } (a string) true kcharpath
>   clip do_something_colourful grestore
> 
> Is there another way to do this, like using cshow or something ?
> Should I write kcharpath myself, looping along the string with `get`
> and `charpath` and invoking proc ?  Has it been written already ?
> 
> Thanks, regards,
> Peter
> 
> P.S. hope I got the code right ...
> 

Here's a first-draft. Remember the proc gets passed 
the previous char and next char, so usually need to
`pop pop`. Oddly, charpath seems to destroy the
currentpoint, requiring the extra juggling with
stringwidth.

% proc string bool  .  -
/kcharpath {
    {bool str proc}{exch def}forall
    str length 0 gt {
        currentpoint
        str 0 1 getinterval dup 
            bool charpath
            stringwidth
        4 2 roll moveto rmoveto
        1 1 str length 1 sub { /idx exch def 
            str idx 1 sub get 
            str idx get 
            proc
            currentpoint
            str idx 1 getinterval dup 
                bool charpath
                stringwidth
            4 2 roll moveto rmoveto
        } for 
    } if
} def 

/Times-Roman 20 selectfont
100 500 moveto
{pop pop -2 0 rmoveto} (a string) true kcharpath
stroke

[toc] | [prev] | [next] | [standalone]


#2568

FromPeter Billam <peter@www.pjb.com.au>
Date2016-05-16 06:51 +0000
Message-ID<slrnnjirg5.3au.peter@box8.pjb.com.au>
In reply to#2567
On 2016-05-15, luser- -droog <mijoryx@yahoo.com> wrote:
> Here's a first-draft. Remember the proc gets passed the
> previous char and next char, so usually need to `pop pop`.

Ah... indeed.  Thanks :-)
People do always say you have to read the small print...

> Oddly, charpath seems to destroy the currentpoint,
> requiring the extra juggling with stringwidth.
> % proc string bool  .  -
> /kcharpath {
>     {bool str proc}{exch def}forall
>     str length 0 gt {
>         currentpoint
>         str 0 1 getinterval dup 
>             bool charpath
>             stringwidth
>         4 2 roll moveto rmoveto
>         1 1 str length 1 sub { /idx exch def 
>             str idx 1 sub get 
>             str idx get 
>             proc
>             currentpoint
>             str idx 1 getinterval dup 
>                 bool charpath
>                 stringwidth
>             4 2 roll moveto rmoveto
>         } for 
>     } if
> } def 
> /Times-Roman 20 selectfont
> 100 500 moveto
> {pop pop -2 0 rmoveto} (a string) true kcharpath
> stroke

That works very well for me :-)  Neat.
I think I even understand it; once I'd got the
  currentpoint ... stringwidth 4 2 roll moveto rmoveto
it wasn't so scary.

Again: Thanks,
Peter

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [prev] | [next] | [standalone]


#2569

FromPeter Billam <peter@www.pjb.com.au>
Date2016-05-18 02:01 +0000
Message-ID<slrnnjnj75.24n.peter@box8.pjb.com.au>
In reply to#2568
On 2016-05-15, luser- -droog <mijoryx@yahoo.com> wrote:
> Here's a first-draft. ...
> % proc string bool  .  -
> /kcharpath { ... } def 

That continues to work well :-)  I was motivated by
  http://www.pjb.com.au/art/posters/babylon_howl.jpg
(a sketch for a poster for a local band) where I wanted to kern
the ZapfChancery-MediumItalic letters closer so they joined up
and looked like handwriting, then fill them with a color-gradient.

And I built on it, after reading The Art Deco Poster (William
Crowse, Thames and Hudson) p.7 where the word CONTENTS is
kerned close so the letters overlap, and with each letter
getting its own left-to-right gray-to-white gradient. So :

/kcharbychar {   % usage: kernproc paintproc string bool  kcharbychar
  % kernproc is called _between_ characters (as in kshow) ;
  % paintproc is called _on_ each character, with its path set, eg:
  % { clip clippath pathbbox 2 index sub exch 3 index sub exch
  %   black white false 0.5 rectgradientfill }
  { bool str paintproc kernproc }{exch def} forall
  str length 0 gt {
    currentpoint
    str 0 1 getinterval dup
      bool charpath
      gsave paintproc grestore
      stringwidth newpath
    4 2 roll moveto rmoveto
    1 1 str length 1 sub { /idx exch def
      str idx 1 sub get
      str idx get
      kernproc
      currentpoint
      str idx 1 getinterval dup
        bool charpath
        gsave paintproc grestore
        stringwidth newpath
      4 2 roll moveto rmoveto
    } for
  } if
} bind def

/Helvetica-Bold 150 selectfont
20 400 moveto
{ pop pop -40 0 rmoveto }
{ clip clippath pathbbox 2 index sub exch 3 index sub exch
  [ black red blue ] randomrgb white false 0.5 rectgradientfill }
(DUBONNET) true kcharbychar

randomrgb and rectgradientfill come from
  http://www.pjb.com.au/comp/colours.html
The regrettable "2 index sub exch 3 index sub exch" bit
converts  llx lly urx ury  to  llx lly width height

That gives eg:  http://www.pjb.com.au/art/posters/malsanulejo.jpg

PS has suddenly opened up for me in the last few months, since I cut
down on line-drawing and started path-constructing and clipping :-)

Peter

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [prev] | [next] | [standalone]


#2570

Fromluser- -droog <mijoryx@yahoo.com>
Date2016-05-17 20:41 -0700
Message-ID<0411ab1c-7ad9-4667-891f-d82458a3a20c@googlegroups.com>
In reply to#2569
On Tuesday, May 17, 2016 at 9:01:10 PM UTC-5, Peter Billam wrote:
> On 2016-05-15, luser- -droog <mijoryx@yahoo.com> wrote:
> > Here's a first-draft. ...
> > % proc string bool  .  -
> > /kcharpath { ... } def 
> 
> That continues to work well :-)  [snip]
> And I built on it, after reading The Art Deco Poster (William
> Crowse, Thames and Hudson) p.7 where the word CONTENTS is
> kerned close so the letters overlap, and with each letter
> getting its own left-to-right gray-to-white gradient. So :
> 
> /kcharbychar {   % usage: kernproc paintproc string bool  kcharbychar

Excellent. But before making too much use of this,
I feel we need to address the problems that I left
unaddressed in the function I posted. 

Basically, it's the name space that we
need to worry about. For the function's internal
definitions, it should at least have

   10 dict begin

   end

wrapped around it. But then what if the user proc
wants to do `def`? Or if it wants to use a variable
called `str`?

I've written up an explanation of Carlos's solution
that he posted here a year or so ago.
http://codereview.stackexchange.com/questions/12249/concatenative-postscript-library/69933#69933
That approach is more complicated because it tries
to pre-bind as much as possible for a tight inner loop.

One simpler way to do it is to replace simple calls to the
user proc

    kernproc

with

    [ /kernproc load /exec cvx currentdict /begin cvx ]
    cvx exec

. Now the dict is out of the way while `kernproc`
is executing.

[toc] | [prev] | [next] | [standalone]


#2571

Fromluser- -droog <mijoryx@yahoo.com>
Date2016-05-17 20:44 -0700
Message-ID<edce5a30-601f-4d6a-abf8-1784ffa734ac@googlegroups.com>
In reply to#2570
On Tuesday, May 17, 2016 at 10:41:57 PM UTC-5, luser- -droog wrote:

> One simpler way to do it is to replace simple calls to the
> user proc
> 
>     kernproc
> 
> with
> 
>     [ /kernproc load /exec cvx currentdict /begin cvx ]

end  % pop the dict

>     cvx exec
> 
> . Now the dict is out of the way while `kernproc`
> is executing.

Now it is.

[toc] | [prev] | [next] | [standalone]


#2572

FromPeter Billam <peter@www.pjb.com.au>
Date2016-05-18 06:59 +0000
Message-ID<slrnnjo4mq.304.peter@box8.pjb.com.au>
In reply to#2571
On 2016-05-18, luser- -droog <mijoryx@yahoo.com> wrote:
> On Tuesday, May 17, 2016 at 10:41:57 PM UTC-5, luser- -droog wrote:
>> One simpler way to do it is to replace simple calls to the
>>     kernproc
>> with
>>     [ /kernproc load /exec cvx currentdict /begin cvx ]
>
> end  % pop the dict
>
>>     cvx exec
>> . Now the dict is out of the way while `kernproc` is executing.
> Now it is.

I'll study those lines and probably incorporate them ...
So far I'd just given my local variables long names beginning
with the procedure-name like  kcharbychar_str  but was
planning to standardise on a more Perl-like eg:
`text::str`, for all the variables in ~/ps/lib/text.ps
That's more verbose, but it's very low-tech and readable.
OTOH, it is about time I became fluent with these local dicts :-)

Thanks again,
Peter

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [prev] | [next] | [standalone]


#2575

Fromluser- -droog <mijoryx@yahoo.com>
Date2016-05-18 22:29 -0700
Message-ID<5ca8496d-cbe4-4155-8a83-7527f59889c2@googlegroups.com>
In reply to#2568
On Monday, May 16, 2016 at 1:51:50 AM UTC-5, Peter Billam wrote:
> On 2016-05-15, luser- -droog <mijoryx@yahoo.com> wrote:
> > Here's a first-draft. 
[snip] 
> That works very well for me :-)  Neat.
> I think I even understand it; once I'd got the
>   currentpoint ... stringwidth 4 2 roll moveto rmoveto
> it wasn't so scary.
> 

Yes. The scary part is that it still works if you
remove the `4 2 roll`.

[toc] | [prev] | [next] | [standalone]


#2574

FromCarlos <angus@quovadis.com.ar>
Date2016-05-18 23:00 +0200
Message-ID<20160518230051.164da369@samara.DOMA>
In reply to#2566
[Peter Billam <peter@www.pjb.com.au>, 2016-05-15 03:33]
> Greetings.  OK; so we have show and kshow...
>   (a string) show
>   { -2 0 rmoveto } (a string) kshow
> 
> and we have charpath ...
>   gsave (a string) true charpath clip do_something_colourful grestore
> 
> but I haven't spotted its kerning equivalent :-(
>   gsave { -2 0 rmoveto } (a string) true kcharpath
>   clip do_something_colourful grestore
> 
> Is there another way to do this, like using cshow or something ?
> Should I write kcharpath myself, looping along the string with `get`
> and `charpath` and invoking proc ?  Has it been written already ?
> 
> Thanks, regards,
> Peter
> 
> P.S. hope I got the code right ...

This one uses cshow. It's certainly longer (and messier), but in case
you use composite fonts...

The proc gets the current and next character *names* (not codes) in the
stack. Also, currentfont returns the current char's font, and nextfont
the next char's.

% proc string bool --
/kcharpath {
    1 index length 0 gt {
        8 dict begin
            { bool str proc } { exch def } forall % nice!
            /oldfont currentfont def
            % accumulate char info: [ dx dy code name font ]
            /chars [ {
                3 -1 roll  dup  currentfont /Encoding get exch get  currentfont
                5 array astore
            } str cshow ] def
            /s 1 string def
            /curchar chars 0 get def
            curchar 4 get setfont  s 0 curchar 2 get put
            currentpoint
            s bool charpath
            moveto  curchar 0 get  curchar 1 get  rmoveto
            1 1 chars length 1 sub {
                dup  /curchar chars 3 -1 roll 1 sub get  def
                /nextchar chars 3 -1 roll get def
                % change 3's to 2's if you want the proc to get char *codes*:
                curchar 3 get  nextchar 3 get
                [
                    /nextfont nextchar 4 get /def cvx
                    /proc load /exec cvx
                    currentdict /begin cvx
                ] end cvx exec  % nicer!
                nextchar 4 get setfont  s 0 nextchar 2 get put
                currentpoint
                s bool charpath
                moveto  nextchar 0 get  nextchar 1 get  rmoveto
            } for
            oldfont setfont
        end
        currentdict /nextfont undef
    } { pop pop pop } ifelse
} def


(some good ideas stolen from luser--droog's solution)

Demo:

/ASCIISmallCaps <<
    /FontType 0
    /FontMatrix [ 1 0 0 1 0 0 ]
    /FMapType 6
    /SubsVector <00 61 1a>
    /Encoding [ 0 1 2 ]
    /FDepVector [
        /Times-Roman findfont
        /Times-SC /Times-Roman findfont dup length dict copy
          dup /FontName /Times-SC put
          dup /Encoding [ 65 1 90 {
                              1 string dup 0  4 -1 roll put  cvn
                          } for
                        ] put
          definefont 0.8 scalefont
        /Times-end /Times-Roman findfont dup length dict copy
          dup /FontName /Times-end put
          dup /Encoding [ /bracketleft /bar /bracketright
                          /tilde /.notdef ] put
          definefont
    ]
>> definefont pop

/ASCIISmallCaps 20 selectfont

100 400 moveto

{ pop pop 10 10 rmoveto } (Hello) true kcharpath stroke

showpage

-- 

[toc] | [prev] | [next] | [standalone]


#2580

FromPeter Billam <peter@www.pjb.com.au>
Date2016-05-21 02:09 +0000
Message-ID<slrnnjvgqe.1tl.peter@box8.pjb.com.au>
In reply to#2574
On 2016-05-18, Carlos <angus@quovadis.com.ar> wrote:
> This one uses cshow. It's certainly longer (and messier),
> but in case you use composite fonts...

Sorry for the delay, I've never met composite fonts before,
I think I got brain overload.
There are things I could use composite fonts for, though...

> The proc gets the current and next character *names* (not codes)
> in the stack.

Where is that most likely to bother me ?
(ie: once I get past the ` {pop pop ` stage)

> % proc string bool --
> /kcharpath {
>     ...
> } def

Again, works beautifully :-)

> /ASCIISmallCaps <<
>     /FontType 0
>     /FontMatrix [ 1 0 0 1 0 0 ]
>     /FMapType 6
>     /SubsVector <00 61 1a>
>     /Encoding [ 0 1 2 ]
>     /FDepVector [
>         /Times-Roman findfont
>         /Times-SC /Times-Roman findfont dup length dict copy
>           dup /FontName /Times-SC put
>           dup /Encoding [ 65 1 90 {
>                               1 string dup 0  4 -1 roll put  cvn
>                           } for
>                         ] put
>           definefont 0.8 scalefont
>         /Times-end /Times-Roman findfont dup length dict copy
>           dup /FontName /Times-end put
>           dup /Encoding [ /bracketleft /bar /bracketright
>                           /tilde /.notdef ] put
>           definefont
>     ]
> >> definefont pop

I'm still not sure how that works.  How does it turn lower-case
into small uppercase?  It must be in the SubsVector, since 61 hex
is "A" ascii, and 1a is 26, the length of the alphabet;
but I don't see a `32 sub` or `32 add` anywhere.
And how does `0.8 scalefont` only get applied to former a-z chars ?
And the `/Encoding [ 65 1 90`  (PLRM: "an array of integers, each
used as an index to extract a font dictionary from the FDepVector")
I think it was at that point that I got brain-overload :-( ...

Regards,  Peter

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [prev] | [next] | [standalone]


#2581

FromPeter Billam <peter@www.pjb.com.au>
Date2016-05-21 03:13 +0000
Message-ID<slrnnjvkj2.2gj.peter@box8.pjb.com.au>
In reply to#2580
On 2016-05-21, Peter Billam <peter@www.pjb.com.au> wrote:
> I'm still not sure how that works.  How does it turn lower-case
> into small uppercase?  It must be in the SubsVector, since 61 hex
> is "A" ascii,

Sorry - typo :  I meant   is "a" ascii.

Peter

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [prev] | [next] | [standalone]


#2584

FromCarlos <angus@quovadis.com.ar>
Date2016-05-22 14:20 +0200
Message-ID<20160522142030.2ad51c0f@samara.DOMA>
In reply to#2580
[Peter Billam <peter@www.pjb.com.au>, 2016-05-21 02:09]
[...]
> > The proc gets the current and next character *names* (not codes)
> > in the stack.  
> 
> Where is that most likely to bother me ?
> (ie: once I get past the ` {pop pop ` stage)

I figured character codes are mostly useless if you are using
reencoded fonts. Also, if you load kerning tables, they usually have
pairs of glyph names, not codes.

If you discard them they are not going to bother you at all,
regardless of their type ;).

[...]
> > /ASCIISmallCaps <<
> >     /FontType 0
> >     /FontMatrix [ 1 0 0 1 0 0 ]
> >     /FMapType 6
> >     /SubsVector <00 61 1a>
> >     /Encoding [ 0 1 2 ]
> >     /FDepVector [
> >         /Times-Roman findfont
> >         /Times-SC /Times-Roman findfont dup length dict copy
> >           dup /FontName /Times-SC put
> >           dup /Encoding [ 65 1 90 {
> >                               1 string dup 0  4 -1 roll put  cvn
> >                           } for
> >                         ] put
> >           definefont 0.8 scalefont
> >         /Times-end /Times-Roman findfont dup length dict copy
> >           dup /FontName /Times-end put
> >           dup /Encoding [ /bracketleft /bar /bracketright
> >                           /tilde /.notdef ] put
> >           definefont
> >     ]  
> > >> definefont pop  
> 
> I'm still not sure how that works.  How does it turn lower-case
> into small uppercase?  It must be in the SubsVector, since 61 hex
> is "A" ascii, and 1a is 26, the length of the alphabet;
> but I don't see a `32 sub` or `32 add` anywhere.
> And how does `0.8 scalefont` only get applied to former a-z chars ?
> And the `/Encoding [ 65 1 90`  (PLRM: "an array of integers, each
> used as an index to extract a font dictionary from the FDepVector")
> I think it was at that point that I got brain-overload :-( ...

SubsVector defines character code ranges by their size, the last being
implicit. The ranges are:

        size      range
  16#61 = 97        0 -  96;  \000 - `
  16#1A = 26       97 - 122;  a    - z
  implicit        123 - 256;  {    - \377

When show (or cshow) meets an 'a' in a string (code 97), it finds it
belongs to the second range (index 1). It looks up the number at index
1 in the Encoding vector (it's 1 again). Then uses that number to find
which subfont to use from FDepVector (it's the font at index 1). Then
it subtracts the start of the range from the char code (97-97=0) and
uses the glyph at that index in the subfont's Encoding vector.

The font at index 1 in FDepVector is reencoded, it's Encoding vector
is simply [ /A /B /C /D /E ... /Z ]. I made it looping from 'A' (65)
to 'Z' (90), creating a string with that letter and then converting it
to a name... it was a silly thing to do, using getinterval/putinterval
to copy the range from Times-Roman's encoding, or even writing /A /B
... /Z would have been faster and more readable.

Anyway, to get back... the subtraction you were missing is done
automatically by the composite font system. And scalefont is only
applied to the font on top of the stack, which is the font we just
created by copying Times-Roman, and changing its Encoding vector.

HTH

-- 

[toc] | [prev] | [next] | [standalone]


#2588

FromPeter Billam <peter@www.pjb.com.au>
Date2016-05-29 06:24 +0000
Message-ID<slrnnkl2os.2lf.peter@box8.pjb.com.au>
In reply to#2584
Sorry for the delay, I've been creating my first ever Type 3 font.
When I look through The Art Deco Poster (Crouse) I notice that every
single poster has its own individual font ! (and they're almost all
all-uppercase, too.)  I going to miss charpath and clip, though ...

On 2016-05-22, Carlos <angus@quovadis.com.ar> wrote:
> [Peter Billam <peter@www.pjb.com.au>, 2016-05-21 02:09]
>> ...
>> I'm still not sure how that works.  How does it turn lower-case
>> into small uppercase?  It must be in the SubsVector, since 61 hex
>> is "A" ascii, and 1a is 26, the length of the alphabet;
>> but I don't see a `32 sub` or `32 add` anywhere.
>> And how does `0.8 scalefont` only get applied to former a-z chars ?
>> And the `/Encoding [ 65 1 90`  (PLRM: "an array of integers, each
>> used as an index to extract a font dictionary from the FDepVector")
>> I think it was at that point that I got brain-overload :-( ...
>
> SubsVector defines character code ranges by their size, the last being
> implicit. The ranges are:
>         size      range
>   16#61 = 97        0 -  96;  \000 - `
>   16#1A = 26       97 - 122;  a    - z
>   implicit        123 - 256;  {    - \377
>
> When show (or cshow) meets an 'a' in a string (code 97), it finds it
> belongs to the second range (index 1). It looks up the number at index
> 1 in the Encoding vector (it's 1 again). Then uses that number to find
> which subfont to use from FDepVector (it's the font at index 1). Then
> it subtracts the start of the range from the char code (97-97=0) and
> uses the glyph at that index in the subfont's Encoding vector.
>
> The font at index 1 in FDepVector is reencoded, it's Encoding vector
> is simply [ /A /B /C /D /E ... /Z ]. I made it looping from 'A' (65)
> to 'Z' (90), creating a string with that letter and then converting it
> to a name... it was a silly thing to do, using getinterval/putinterval
> to copy the range from Times-Roman's encoding, or even writing /A /B
> ... /Z would have been faster and more readable.

That's the:
  dup /Encoding [65 1 90 {1 string dup 0 4 -1 roll put cvn} for] put

So how would you rewrite that, in an ideal world ?
(I'll roll it into my SmallCaps collection.)

> Anyway, to get back... the subtraction you were missing is done
> automatically by the composite font system. And scalefont is only
> applied to the font on top of the stack, which is the font we just
> created by copying Times-Roman, and changing its Encoding vector.

OK, I think I get that :-)
Could still be a while before I'm fluent in this area, though...

Is there a website somewhere with a collection of Type 3 fonts ?
Should be on github, really, if github can realise .ps is text...

Many thanks,
Peter

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [prev] | [next] | [standalone]


#2589

Fromluser- -droog <mijoryx@yahoo.com>
Date2016-05-28 23:43 -0700
Message-ID<a85160ca-e9d8-456a-94cb-494a0ae53c2a@googlegroups.com>
In reply to#2588
On Sunday, May 29, 2016 at 1:24:29 AM UTC-5, Peter Billam wrote:

> Should be on github, really, if github can realise .ps is text...
> 

My recent complaint is only the online `diff` display on the commit page.
GitHub works just fine for browsing ps files, even adding syntax 
highlighting, hence the oddity that diffs don't.

-- 
nice solidarity, bro

[toc] | [prev] | [next] | [standalone]


#2590

Fromluser- -droog <mijoryx@yahoo.com>
Date2016-05-29 01:10 -0700
Message-ID<13981bac-3f12-48ab-8598-e7cd69798408@googlegroups.com>
In reply to#2588
On Sunday, May 29, 2016 at 1:24:29 AM UTC-5, Peter Billam wrote:
> Sorry for the delay, I've been creating my first ever Type 3 font.

Fun! I've made a few.

A poor-man's composite font:
https://groups.google.com/d/topic/comp.lang.postscript/fZrJLboPDl0/discussion

A crossword font:
http://codegolf.stackexchange.com/a/3948/2381

A bitmap font:
https://github.com/luser-dr00g/xpost/blob/master/data/bitfont.ps

[toc] | [prev] | [next] | [standalone]


#2591 — from image to imagemask

FromPeter Billam <peter@www.pjb.com.au>
Date2016-05-31 08:51 +0000
Subjectfrom image to imagemask
Message-ID<slrnnkqk3l.3ne.peter@box8.pjb.com.au>
In reply to#2590
On 2016-05-29, luser- -droog <mijoryx@yahoo.com> wrote:
> On Sunday, May 29, 2016 at 1:24:29 AM UTC-5, Peter Billam wrote:
>> Sorry for the delay, I've been creating my first ever Type 3 font.
> Fun! I've made a few.  ...  A bitmap font:
> https://github.com/luser-dr00g/xpost/blob/master/data/bitfont.ps

I like that! nostalgic; a strong cultural reference,
could even become a major fashion-statement :-)

Trouble is, I'll want to show green text on a black background,
or orange text over a realistic natural landscape.
AIUI, this means I have to modify it from `image` to `imagemask`.
But I haven't managed to do this :-(   See:
  http://www.pjb.com.au/comp/fonts.html#install
The source:
  http://www.pjb.com.au/comp/free/fonts.ps.txt
If you look for Bitfont5x7 you'll see my dirty footprints.  I think
maybe the    /_ (\377) /# (\0)  in the charprocs doesn't suit the
/BitsPerComponent 1  which PLRM p.220 says is needed by imagemask ?

I'm printing with
  (/home/pjb/ps/lib/fonts.ps) run
  /Bitfont5x7 40 selectfont
  % black setrgbcolor 0 0 xmax ymax rectfill   palegreen setrgbcolor
  100 100 moveto (01234 56789 ?) show

(Also, it's leaving 76 numbers on the stack,  101 99 99 110 110 etc,
 not sure where they come from.)

Suggestions gratefully received...

Peter

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [prev] | [next] | [standalone]


#2592 — Re: from image to imagemask

Fromluser- -droog <mijoryx@yahoo.com>
Date2016-06-01 00:53 -0700
SubjectRe: from image to imagemask
Message-ID<2a1f732c-60fd-4042-8ffc-2d9464446df8@googlegroups.com>
In reply to#2591
On Tuesday, May 31, 2016 at 3:51:03 AM UTC-5, Peter Billam wrote:
> On 2016-05-29, luser- -droog <mijoryx@yahoo.com> wrote:
> > On Sunday, May 29, 2016 at 1:24:29 AM UTC-5, Peter Billam wrote:
> >> Sorry for the delay, I've been creating my first ever Type 3 font.
> > Fun! I've made a few.  ...  A bitmap font:
> > https://github.com/luser-dr00g/xpost/blob/master/data/bitfont.ps
> 
> I like that! nostalgic; a strong cultural reference,
> could even become a major fashion-statement :-)
> 
> Trouble is, I'll want to show green text on a black background,
> or orange text over a realistic natural landscape.
> AIUI, this means I have to modify it from `image` to `imagemask`.
> But I haven't managed to do this :-(  

Yes, I see how that would make it more useful.
And yes, the whole program concept kinda falls
apart when you need bits.

My first idea is adding a function to do the conversion.
Instead of just depositing lots of strings on the stack
for image to consume, a function call to pack the 5 x 7 
values into bitmaps.

sth like

%m n bits
/bits {
    %ug. brainlock.
} def

I thought the idea would happen, but then the star trek 
episode got more interesting.

more soon.

[toc] | [prev] | [next] | [standalone]


#2593 — Re: from image to imagemask

Fromluser- -droog <mijoryx@yahoo.com>
Date2016-06-01 01:10 -0700
SubjectRe: from image to imagemask
Message-ID<c07b8961-c73d-4804-b4fd-f96b646a07b1@googlegroups.com>
In reply to#2592
On Wednesday, June 1, 2016 at 2:53:32 AM UTC-5, luser- -droog wrote:
> On Tuesday, May 31, 2016 at 3:51:03 AM UTC-5, Peter Billam wrote:

> > Trouble is, I'll want to show green text on a black background,
> > or orange text over a realistic natural landscape.
> > AIUI, this means I have to modify it from `image` to `imagemask`.
> > But I haven't managed to do this :-(  
> 
> Yes, I see how that would make it more useful.
> And yes, the whole program concept kinda falls
> apart when you need bits.
> 
> My first idea is adding a function to do the conversion.
> Instead of just depositing lots of strings on the stack
> for image to consume, a function call to pack the 5 x 7 
> values into bitmaps.
> 
> sth like
> 
> %m n bits
> /bits {
>     %ug. brainlock.
> } def
> 
> I thought the idea would happen, but then the star trek 
> episode got more interesting.
> 
> more soon.

The values are completely in the wrong order 
for this. Let me leave it at a link where I'm grabbing
some ideas to sleep on:
http://stackoverflow.com/questions/17613770/733077/image-represented-as-radix-number-in-postscript

[toc] | [prev] | [next] | [standalone]


#2598 — Re: from image to imagemask

FromPeter Billam <peter@www.pjb.com.au>
Date2016-06-02 01:26 +0000
SubjectRe: from image to imagemask
Message-ID<slrnnkv2pe.1ee.peter@box8.pjb.com.au>
In reply to#2593
On 2016-06-01, luser- -droog <mijoryx@yahoo.com> wrote:
> On Wednesday, June 1, 2016 at 2:53:32 AM UTC-5, luser- -droog wrote:
>> On Tuesday, May 31, 2016 at 3:51:03 AM UTC-5, Peter Billam wrote:
>> > Trouble is, I'll want to show green text on a black background,
>> > or orange text over a realistic natural landscape.
>> > AIUI, this means I have to modify it from `image` to `imagemask`.
>> > But I haven't managed to do this :-(  
>> 
> . Let me leave it at a link where I'm grabbing some ideas to sleep on:
> http://stackoverflow.com/questions/17613770/733077/image-represented-as-radix-number-in-postscript

I got something working :-)  See:
  wget -O fonts.ps http://www.pjb.com.au/comp/free/fonts.ps.txt
or:
  curl http://www.pjb.com.au/comp/free/fonts.ps.txt -o fonts.ps  

The main changes were a  5 -1 roll  just before imagemask
to get the charproc into the right place,
and some single-pixel experiments which revealed that in the
  57 {<60 90 90 70 10 60 00>}
each row has to start on a byte-boundary.  This certainly makes
the hex easier to read and write ; I suppose it must be documented
somewhere ...

Displaying with: 
  /xmax currentpagedevice (PageSize) get 0 get def
  /ymax currentpagedevice (PageSize) get 1 get def
  (/home/pjb/ps/lib/fonts.ps) run
  (/home/pjb/ps/lib/colours.ps) run
  /Bitfont5x7 40 selectfont
  black setrgbcolor 0 0 xmax ymax rectfill   green setrgbcolor
  100 100 moveto (01234 56789 ?) show

I'll add some characters, like uppercases, dot, etc :-)

Peter

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [prev] | [next] | [standalone]


#2613 — Re: from image to imagemask

FromPeter Billam <peter@www.pjb.com.au>
Date2016-06-03 07:53 +0000
SubjectRe: from image to imagemask
Message-ID<slrnnl2dru.2og.peter@box8.pjb.com.au>
In reply to#2598
On 2016-06-02, Peter Billam <peter@www.pjb.com.au> wrote:
>   wget -O fonts.ps http://www.pjb.com.au/comp/free/fonts.ps.txt
> or:
>   curl http://www.pjb.com.au/comp/free/fonts.ps.txt -o fonts.ps  
> ...
> I'll add some characters, like uppercases, dot, etc :-)

Bitfont5x7 now has not just digits, but ASCII uppercase and
lowercase, and also + - . , : ; ! ?

Also FatSimple has improved: its only letters are uppercase,
but they include the ISO accents for german and french (so far),
plus the digits 0-9 and also + - = . : | ! ? 

> (Also, it's leaving 76 numbers on the stack,
>  101 99 99 110 110 etc, not sure where they come from.)

These turned out to be generated by my test-document, which was
using kshow, not do do any kerning but to change the colour
at random every character.  You'll never guess: I forgot the
pop pop at the beginning of the proc... Ah, well...

See:
  http://www.pjb.com.au/comp/fonts.html
also now on github:
  https://github.com/peterbillam/postscriptlib

Peter

-- 

Peter Billam    www.pjb.com.au    www.pjb.com.au/comp/contact.html

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.postscript


csiph-web