Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.postscript

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2012, 07:07 PM
Ramon F Herrera
Guest
 
Posts: n/a
Default Is it possible to replace 1 custom character in a font??


This is simple curiosity. In OO programming you can take advantage of
whatever resources (classes, functions) are available but you may
subclass your own.

Let's say that I am happy with ALL the characters, except for one,
where I prefer to build my own.

Is that doable? Practicable?

TIA,

-Ramon

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 07-16-2012, 07:29 PM
Bill
Guest
 
Posts: n/a
Default Re: Is it possible to replace 1 custom character in a font??

On Jul 16, 3:07*pm, Ramon F Herrera <ra...@conexus.net> wrote:
> This is simple curiosity. In OO programming you can take advantage of
> whatever resources (classes, functions) are available but you may
> subclass your own.
>
> Let's say that I am happy with ALL the characters, except for one,
> where I prefer to build my own.
>
> Is that doable? Practicable?
>
> TIA,
>
> -Ramon


---------------------------------------------------------------------------------------------------------------

You might be able to achieve this with Type Light, a free font
editor...

http://www.cr8software.net/typelight.html

Bill
Reply With Quote
  #3 (permalink)  
Old 07-17-2012, 12:20 AM
Character
Guest
 
Posts: n/a
Default Re: Is it possible to replace 1 custom character in a font??

On 7/16/2012 12:07 PM, Ramon F Herrera wrote:
>
> This is simple curiosity. In OO programming you can take advantage of
> whatever resources (classes, functions) are available but you may
> subclass your own.
>
> Let's say that I am happy with ALL the characters, except for one,
> where I prefer to build my own.
>
> Is that doable?


Yes

> Practicable?


Yes, depending on your knowledge of the available tools

BUT: It may be in violation of the terms of the license agreement for
the font. SOME foundries (such as Adobe) allow such changes as long as
the font isn't re-distributed. Many others strictly prohibit modification.

There is a little-known tool built into Windows operating systems that
lets you define your own character and use it in any font. It's called
the Private Character Editor.

Its eudcedit.exe. You can START/RUN Eudcedit.exe

A tutorial is here:
http://www.microsoft.com/resources/d....mspx?mfr=true

Googling for Private Character Editor will lead you to other assistance.

- Character

Reply With Quote
  #4 (permalink)  
Old 07-17-2012, 03:51 AM
luser- -droog
Guest
 
Posts: n/a
Default Re: Is it possible to replace 1 custom character in a font??


On Monday, July 16, 2012 2:07:16 PM UTC-5, Ramon F Herrera wrote:
> This is simple curiosity. In OO programming you can take advantage of
> whatever resources (classes, functions) are available but you may
> subclass your own.
>
> Let's say that I am happy with ALL the characters, except for one,
> where I prefer to build my own.
>
> Is that doable? Practicable?


Yes, the postscript interpreter invokes itself recursively
when executing a font (in order to defer the rendering into
the cache). So, within the BuildChar procedure of a Type3
(User-defined) font, you can among other things
select a font and show strings.

I cooked-up an example.

%!
%customchar.ps
%Example replaces the space char (using ASCII decimal code)
%with a big black 'em'-square

/q{0 0 moveto 1 0 lineto 1 1 lineto 0 1 lineto closepath}def

/X<</FontType 3/FontBBox[0 0 1 1]/FontMatrix[1 0 0 1 0 0]
/Encoding StandardEncoding
/BuildChar{ % font char(int)
exch pop
dup 32 eq { pop
1 0 0 0 1 1 setcachedevice
q fill
}{
/Times-Roman 1 selectfont
(?) dup 0 4 3 roll put dup stringwidth %(?) Wx Wy
0 0 1 1 setcachedevice
0 0 moveto
show
}ifelse
}
>>definefont pop


/X 30 selectfont

100 300 moveto
(Modified Font?) show

Reply With Quote
  #5 (permalink)  
Old 08-13-2012, 01:15 PM
David Combs
Guest
 
Posts: n/a
Default Re: Is it possible to replace 1 custom character in a font??

>I cooked-up an example.
>
>%!
>%customchar.ps
>%Example replaces the space char (using ASCII decimal code)
>%with a big black 'em'-square
>
>/q{0 0 moveto 1 0 lineto 1 1 lineto 0 1 lineto closepath}def
>
>/X<</FontType 3/FontBBox[0 0 1 1]/FontMatrix[1 0 0 1 0 0]
> /Encoding StandardEncoding
> /BuildChar{ % font char(int)
> exch pop
> dup 32 eq { pop
> 1 0 0 0 1 1 setcachedevice
> q fill
> }{
> /Times-Roman 1 selectfont
> (?) dup 0 4 3 roll put dup stringwidth %(?) Wx Wy
> 0 0 1 1 setcachedevice
> 0 0 moveto
> show
> }ifelse
> }
>>>definefont pop

>
>/X 30 selectfont
>
>100 300 moveto
>(Modified Font?) show
>


Thanks for saving people some programming.

I will save this post for possible future use.

But first a probably insulting question: you did TEST
the code?

(I ask only because so many cs textbooks include program
after program (source) that won't even compile, perhaps
even in the human brain!)

David

Reply With Quote
  #6 (permalink)  
Old 08-13-2012, 01:48 PM
David Combs
Guest
 
Posts: n/a
Default Re: Is it possible to replace 1 custom character in a font??

A *different* followup, ABOUT the postscript language,
as demonstrated in your example:

>
>I cooked-up an example.
>
>%!
>%customchar.ps
>%Example replaces the space char (using ASCII decimal code)
>%with a big black 'em'-square
>
>/q{0 0 moveto 1 0 lineto 1 1 lineto 0 1 lineto closepath}def
>
>/X<</FontType 3/FontBBox[0 0 1 1]/FontMatrix[1 0 0 1 0 0]
> /Encoding StandardEncoding
> /BuildChar{ % font char(int)
> exch pop
> dup 32 eq { pop
> 1 0 0 0 1 1 setcachedevice
> q fill
> }{
> /Times-Roman 1 selectfont
> (?) dup 0 4 3 roll put dup stringwidth %(?) Wx Wy
> 0 0 1 1 setcachedevice
> 0 0 moveto
> show
> }ifelse
> }
>>>definefont pop

>
>/X 30 selectfont
>
>100 300 moveto
>(Modified Font?) show
>




I would call having to program like that, with
those miserable-to-code (correctly!) stack operations (eg dup, roll, etc),
it's obviously a language not made for human use.

Even though when it was new, back around 1980 and available
only in the Apple laserwriter, the almost only way to use it *was*
by hand coding it.

Couldn't Adobe have added a *few* ops to make coding VASTLY
simpler?

Example: The HP-50 calculator, using a *very* nice version
of a reverse polish language.

Has REAL functions and procedures, with args, local vars,
as just one added feature.

Now, the above is in reverse-polish mode.

But it also lets you write stuff in "algebra" (with parens
and everthing, and even calls to those function you defined
up above!) -- this is its "algebraic" mode.

Here its manual:
http://h10032.www1.hp.com/ctg/Manual/c00554621.pdf

From the tbl of contents, jump down to "RPL programming",
and page on from there.

Also note that everything is an "object".

Look at it, you'll like it!

---------------------------

Now, could Adobe could have added these features
back in '80. No, not with those small and expensive
they were limited to at that time.

BUT, they COULD have EASILY added these language features
later on, eg 2000 or after. And note that none of the
added language-features would require changes to any
of the prior Adobe postscript!

Old programs would continue to run in new printers
with their new interpreters. You just couldn't
use the new features in the OLD printers, etc.

If at all curious about these nifty language-featurees
in the HP-50, go to the up above url. It will make
you jealous!


David


Reply With Quote
  #7 (permalink)  
Old 08-13-2012, 10:54 PM
luser- -droog
Guest
 
Posts: n/a
Default Re: Is it possible to replace 1 custom character in a font??

On Monday, August 13, 2012 8:15:16 AM UTC-5, David Combs wrote:
> >I cooked-up an example.

>
> >

>
> >%!

>
> >%customchar.ps

>
> >%Example replaces the space char (using ASCII decimal code)

>
> >%with a big black 'em'-square

>
> >

>
> >/q{0 0 moveto 1 0 lineto 1 1 lineto 0 1 lineto closepath}def

>
> >

>
> >/X<</FontType 3/FontBBox[0 0 1 1]/FontMatrix[1 0 0 1 0 0]

>
> > /Encoding StandardEncoding

>
> > /BuildChar{ % font char(int)

>
> > exch pop

>
> > dup 32 eq { pop

>
> > 1 0 0 0 1 1 setcachedevice

>
> > q fill

>
> > }{

>
> > /Times-Roman 1 selectfont

>
> > (?) dup 0 4 3 roll put dup stringwidth %(?) Wx Wy

>
> > 0 0 1 1 setcachedevice

>
> > 0 0 moveto

>
> > show

>
> > }ifelse

>
> > }

>
> >>>definefont pop

>
> >

>
> >/X 30 selectfont

>
> >

>
> >100 300 moveto

>
> >(Modified Font?) show

>
> >

>
>
>
> Thanks for saving people some programming.
>
>
>
> I will save this post for possible future use.
>
>
>
> But first a probably insulting question: you did TEST
>
> the code?
>
>
>
> (I ask only because so many cs textbooks include program
>
> after program (source) that won't even compile, perhaps
>
> even in the human brain!)
>
>
>
> David


I tested it with ghostscript. Gv, ghostview, and GSView
should therefore have no problem.
It looks like I forgot 'showpage' at the end.
So you may need to add that line to convert to pdf
or send it to a printer. I'd have tested it with xpost
(my own interpreter), but it doesn't parse the Level-2
<<dictionary>> syntax yet.

I could add more commentary, if that would be helpful.
I usually aim for the Miltonic maxim: show, don't tell.
So I am quite prone to not providing essential
documentation.

The sections about Fonts and 'definefont' in particular
from the PLRM would be good background for understanding
this code.

-- droog
Reply With Quote
  #8 (permalink)  
Old 08-14-2012, 03:04 AM
SaGS
Guest
 
Posts: n/a
Default Re: Is it possible to replace 1 custom character in a font??

On Jul 16, 10:07*pm, Ramon F Herrera <ra...@conexus.net> wrote:
> ...
> In OO programming you can take advantage of whatever resources
> (classes, functions) are available but you may subclass your own.
>
> Let's say that I am happy with ALL the characters, except for one,
> where I prefer to build my own.
> ...


For a way to do it from PostScript code, see section 5.9.3 "Replacing
or Adding Individual Glyphs" in the "PostScript Language Reference
Manual (3rd ed)" <http://partners.adobe.com/public/developer/ps/
index_specs.html>.

Another way, also done from PostScript code, is to define a Type 0
font with the original font (from which you get the glyph you are
happy with) and a font of your own (containing just the new glyph(s))
as descendants. I think either a FMapType of 6 (SubsVector mapping) or
9 (CMap mapping) will do. See section 5.10 "Composite fonts" in the
same document.
Reply With Quote
  #9 (permalink)  
Old 08-16-2012, 10:09 AM
luser- -droog
Guest
 
Posts: n/a
Default Re: Is it possible to replace 1 custom character in a font??

On Monday, August 13, 2012 8:48:44 AM UTC-5, David Combs wrote:
> A *different* followup, ABOUT the postscript language,
>
> as demonstrated in your example:
>
>
>
> >

>
> >I cooked-up an example.

>
> >

>
> >%!

>
> >%customchar.ps

>
> >%Example replaces the space char (using ASCII decimal code)

>
> >%with a big black 'em'-square

>
> >

>
> >/q{0 0 moveto 1 0 lineto 1 1 lineto 0 1 lineto closepath}def

>
> >

>
> >/X<</FontType 3/FontBBox[0 0 1 1]/FontMatrix[1 0 0 1 0 0]

>
> > /Encoding StandardEncoding

>
> > /BuildChar{ % font char(int)

>
> > exch pop

>
> > dup 32 eq { pop

>
> > 1 0 0 0 1 1 setcachedevice

>
> > q fill

>
> > }{

>
> > /Times-Roman 1 selectfont

>
> > (?) dup 0 4 3 roll put dup stringwidth %(?) Wx Wy

>
> > 0 0 1 1 setcachedevice

>
> > 0 0 moveto

>
> > show

>
> > }ifelse

>
> > }

>
> >>>definefont pop

>
> >

>
> >/X 30 selectfont

>
> >

>
> >100 300 moveto

>
> >(Modified Font?) show

>
> >

>
>
>
>
>
>
>
> I would call having to program like that, with
>
> those miserable-to-code (correctly!) stack operations (eg dup, roll, etc),
>
> it's obviously a language not made for human use.
>
>
>
> Even though when it was new, back around 1980 and available
>
> only in the Apple laserwriter, the almost only way to use it *was*
>
> by hand coding it.
>


Yeah, but by 86 there was LaserTalk and NeWS, and Illustrator was soon to follow.

You're right, of course. But to the very same extent, you're wrong. While both these languages are "general purpose", they are also each targeted to specific embedded applications.

>
> Couldn't Adobe have added a *few* ops to make coding VASTLY
>
> simpler?
>


To quote from Amadeus, <<Which few would Your Majesty suggest?>>
Adobe has, in fact, greatly expanded the language on two occasions.
There have also been various efforts to add a more friendly front-end (Inscript, Metapost). But the paradoxical result of indulging in such efforts isthat, while ostensibly making Postscript 'easier', it places a further obstacle in the way and entrenches the attitude that Postscript requires such aids, efectively making Postscript 'harder'.

If instead you begin with the attitude that Postscript is astonishing perfect in every way, then the leap becomes far less daunting.

>
> Example: The HP-50 calculator, using a *very* nice version
>
> of a reverse polish language.
>
>
>
> Has REAL functions and procedures, with args, local vars,
>
> as just one added feature.
>
>
>
> Now, the above is in reverse-polish mode.
>
>
>
> But it also lets you write stuff in "algebra" (with parens
>
> and everthing, and even calls to those function you defined
>
> up above!) -- this is its "algebraic" mode.
>
>
>
> Here its manual:
>
> http://h10032.www1.hp.com/ctg/Manual/c00554621.pdf
>
>
>
> From the tbl of contents, jump down to "RPL programming",
>
> and page on from there.
>
>
>
> Also note that everything is an "object".
>
>
>
> Look at it, you'll like it!
>
>
>
> ---------------------------
>
>
>
> Now, could Adobe could have added these features
>
> back in '80. No, not with those small and expensive
>
> they were limited to at that time.
>
>
>
> BUT, they COULD have EASILY added these language features
>
> later on, eg 2000 or after. And note that none of the
>
> added language-features would require changes to any
>
> of the prior Adobe postscript!
>
>
>
> Old programs would continue to run in new printers
>
> with their new interpreters. You just couldn't
>
> use the new features in the OLD printers, etc.
>
>
>
> If at all curious about these nifty language-featurees
>
> in the HP-50, go to the up above url. It will make
>
> you jealous!



I'd suggest you take them one-at-a-time and start posting "How to do XX in PS like the HP does?" threads. I'll contribute!

For algebraic mode, we'll need a LL(1) or LR parser. I'll go get my Dragon book...

-- droog
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 06:18 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.