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"...): ; ==================== ; PROCEDURE SMALL.CAPS ; ==================== ; Return a sosofo containing the string as small caps ; PROCEDURE SPLIT-CASE: ; 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) (cond ((null? l) (list 'undefined '())) (#t (let* ((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))) ) (cond ((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 splitted-cdr)))) (#t (list first-case (cons (list uc) splitted-cdr))) ) ) ) ) ) ; PROCEDURE MAKE-SMALL-CAPS: ; Builds the sosofos for a splitted string (define (make-small-caps l size first-is-lower) (cond ((null? l) (empty-sosofo)) (#t (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 first-is-lower)) ) ) ) ) ; PROCEDURE SMALL-CAPS: ; 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 http://dailynews.yahoo.com/fc/US/Emergency_Information/ DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
(dsssl) Smallcap fonts for <acronym, V.Krishna Kumar | Thread | Re: (dsssl) Smallcap fonts for <acr, Christopher R. Maden |
(dsssl) Smallcap fonts for <acronym, V.Krishna Kumar | Date | Re: (dsssl) Smallcap fonts for <acr, Christopher R. Maden |
Month |