(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
[EMAIL PROTECTED]
*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
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to