fonts one last time

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

fonts one last time

Charles Hartman
(Whew.) Here's a script for the main stack of a two-stack app full of  
fields called "Text" with a mix of fonts and styles. As far as I can  
tell from preliminary tests, this -- at last! -- should (1) adjust  
the default text font and (2) adjust the monospaced font I need for  
some text, both by looking for particular fonts, while (3) preserving  
the special-font status of those monospace passages and (4)  
preserving all style markings (link, bold, etc), yet (5) changing  
text after those to the default font (which Rev refuses to do by  
itself).

In case somebody else has the same combination of problems I've had.

Charles Hartman
Professor of English, Poet in Residence
Connecticut College
[hidden email]
*the Scandroid* is at cherry.conncoll.edu/cohar/Programs.htm

=============================================================
on preOpenStack
   -- could check platform (which is the overall point here);
   -- but really care only whether certain fonts are available.
   -- First: establish names of running (proportional) and special
   -- (monospaced) fonts for "Text" fields
   /*  ----- PROPOSED PRODUCTION CODE
   if "Palatino" is in the fontNames then
     put "Palatino" into theRunningFont
     put 12 into mySize
   else
     put "Times New Roman" into theRunningFont
     put 12 into mySize        -- check this on Windows!
   end if
   if "Courier" is in the fontNames then
     put "Courier" into theMonoFont
   else
     put "Courier New" into theMonoFont
   end if
   */
   ---------- TESTING CODE; COMMENT OUT FOR PRODUCTION!
   ask "running (non-monospaced) font?"
   put it into theRunningFont
   ask "monospaced font?"
   put it into theMonoFont
   put 12 into mySize
   -- do the change only if need default font other than present one
   if theRunningFont is not the textFont of this stack then
     changeFieldTextProps "English Metrics","Text",mySize, \
         theRunningFont,theMonoFont
     changeFieldTextProps "Reference Stack","Text",mySize, \
         theRunningFont,theMonoFont
   end if
end preOpenStack


-- based on David Epstein's script for preserving styles
-- while changing the default font throughout a stack
on changeFieldTextProps myStack,f,mySize,myFont,myMonoFont
   repeat with c = 1 to the number of cards of stack myStack
     if exists(field f of card c of stack myStack) then
       put the htmlText of field f of card c of stack myStack \
           into hold[c]
       -- seek and change all font specifications to mono font
       put offset("<font face=", hold[c]) into tagFoundAt
       -- if tag not found we'll skip this repeat
       repeat while tagFoundAt is not zero
         put tagFoundAt into endOfTag
         add offset(">",hold[c],tagFoundAt) to endOfTag
         put myMonoFont into char tagFoundAt+12 to endOfTag-2 \
             of hold[c]
         --answer char tagFoundAt+12 to endOfTag-2]
         put offset("<font face=",hold[c],endOfTag) into increment
         if increment is zero
         then exit repeat
         put increment + endOfTag into TagFoundAT
       end repeat
     end if
   end repeat
   set the textSize of stack myStack to mySize
   set the textFont of stack myStack to myFont
   repeat with c = 1 to the number of cards of stack myStack
     if exists(field f of card c of stack myStack)
     then set the htmlText of field f of card c of stack myStack \
         to hold[c]
   end repeat
end changeFieldTextProps

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: fonts one last time

Charles Hartman
(By the way, I tried to send this same message earlier, but the list  
rejected it because it was something like 35k. That's pasting a  
script directly from Rev into a message. When I paste it into BBEdit  
and then into mail, it's down to 7k. What's the Rev script editor  
doing with it to bloat it so much? Can't be just Unicode, I think --  
HTML?)

coh

On Jul 9, 2005, at 7:46 PM, Charles Hartman wrote:

[etc]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution