Re: (dsssl) Smallcap fonts for <acronym> in docbook

Subject: Re: (dsssl) Smallcap fonts for <acronym> in docbook
From: Eric Brunel <eric_brunel@xxxxxxxx>
Date: Thu, 20 Sep 2001 01:19:35 -0700 (PDT)
Hi Krish,

--- "V.Krishna Kumar" <lvimala@xxxxxxx> wrote:
> I need to 
> use smallcaps for <acronym>. How do I do that ?

I don't know DocBook stylesheets, so maybe there's a
much better solution than the one I give below. I had
the same problem with a DTD and stylesheet I wrote and
I couldn't find a simple way to do that. I finally
wrote a set of procedures converting a string to the
corresponding sosofo for its small caps. Here is the
code (it's a bit ugly, and very "lispian"...):

; ====================
; ====================
; Return a sosofo containing the string as small caps

; Splits a string as a list of chars according to the
chars' cases
; Returns the splitted string with the case of the
first char as first element

(define (split-case l)
    ((null? l) (list 'undefined '()))
        ((c (car l))
         (uc (char-upcase c))
         (is-lower (not (char=? c uc)))
         (first-case (if is-lower 'lower 'upper))
         (res (split-case (cdr l)))
         (last-case (car res))
         (splitted-cdr (car (cdr res)))
          ((equal? last-case 'undefined) (list
first-case (list (list uc))))
          ((equal? first-case last-case) (list
first-case (cons (cons uc (car splitted-cdr)) (cdr
          (#t                            (list
first-case (cons (list uc) splitted-cdr)))

; Builds the sosofos for a splitted string

(define (make-small-caps l size first-is-lower)
    ((null? l) (empty-sosofo))
      (make sequence
        (make sequence
          use: (style font-size: (if first-is-lower (*
size 0.75) size))
          (literal (list->string (car l)))
        (make-small-caps (cdr l) size (not

; Builds the sosofos for the small caps of a string

(define (small-caps str size)
  (let ((l (split-case (string->list str))))
    (make-small-caps (car (cdr l)) size (equal? (car
l) 'lower))

To use it, you'll have to include the procedures in
your stylesheet, then put in the processing section
for the "acronym" element a code looking like:
(small-caps (data current-node) *font-size*)

Be sure also to declare a default language in your
stylesheet via the (declare-default-language ...)
instruction, or else OpenJade won't know how to
convert characters to upper case...

Hope this will be helpful. But there's probably a much
better way to do that than mine...
 - eric -

Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information

 DSSSList info and archive:

Current Thread