Dear gang,

I. In Context, as is well known, scaling a character is not independent of 
switching the font:

=======
\startTEXpage[offset=1em]
\definefont[Times][times @ 14pt]
\Times Test \tfx Test
\setupinterlinespace

\Times Test \switchtobodyfont[x]Test

\Times Test \high{Test}
\stopTEXpage
=======

\tfx causes a switch to computer modern.

Of course, with the right typescripts and \setupbodyfont, one can maintain 
stylistic consistency when switching fonts.

But what if we want to scale independently of font switching?

II. One approach might be to use symbols:

\startTEXpage
\definesymbol[Tee][\getglyph{times}{T}]
\symbol[Tee]est \tfx \symbol[Tee]est \tfa \symbol[Tee]est
\stopTEXpage

In this example, \tfa does scale the symbol Tee. But \tfx does not scale the 
symbol!

Why does \tfa (or higher such as \tfb etc.) work, but not \tfx (or lower)?

III. The best approach would be to do it in CLD (Context Lua Code). That is 
mostly beyond my skill to write from scratch without a template, but there are 
some experiments in the system file font-imp-effects.lua. There we will find, 
e.g.,

local specification = {
    name        = "extend",
    description = "scale glyphs horizontally",
    initializers = {
        base = initializeextend,
        node = initializeextend,
    }
}

local specification = {
    name        = "squeeze",
    description = "scale glyphs vertically",
    initializers = {
        base = initializesqueeze,
        node = initializesqueeze,
    }
}

This seems hopeful:

\definecolor [transparentgreen]  [g=1,t=.7,a=1]
\definecolor [transparentred]    [r=1,t=.7,a=1]
\definecolor [transparentyellow] [y=1,t=.7,a=1]

\startTEXpage[offset=1em]
\definefontfeature[scale][default][extend=yes,squeeze=yes]
\hbox{\rlap{\definedfont[times @ 14pt]\transparentgreen Test}%
            \definedfont[times*scale @ 14pt]\transparentred Test}
\stopTEXpage

But there is no scaling of the character, extend=yes shifts the glyphs to the 
left, and squeeze=yes appears to do nothing at all.

Here is a file collecting these experiments:

https://www.dropbox.com/scl/fi/dggj3ypgjjeia1bo4eelb/test-scaling.tex?rlkey=hcky6ol594mw8u0j2j1z22heh&dl=0
https://www.dropbox.com/scl/fi/o2u1tsq515ycyoeup43qg/test-scaling.pdf?rlkey=h7gof1vyq3r0bh72qynh71apc&dl=0

IV. Objective:

I need to be able to define a couple of characters in CLD -- glottal stops --, 
and add commands to scale and/or rotate a character without triggering a font 
switch. Again, writing this from scratch is beyond my current skill set - 
although I've recently started to study CLD. Something like this -- some of the 
semantics is almost certainly wrong and/or clumsy -)

==============
-- ʿ ringhalfleft
local function ringhalfleft (characters,target,base,accent)
--    if not characters[target] then
        local data1 = characters[base]
        local data2 = characters[accent]
        if data1 and data2 then
            characters[target] = { -- "ʿ"
                height   = data1.height,
                depth    = (data1.depth or 0) + 0.5*(data2.height or 0),
                width    = data1.width,
                unicode  = target,
                commands = {
                    { "slot", 0, 0 },
                    { "left", -0.5*(data2.width  or 0) + 0.5*(data2.width  or 
0)},
                    -- { "down", 0.2*(data2.height or 0) +   (data2.height or 
0) },
                    { "up", 0.0*(data2.height or 0) +        (data2.height or 
0) },
                    { "slot", 0, 0x063, },
                    { "squeeze", 0.75*(data2.height or 0) },
                    { "extend",  0.75*(data2.width or 0) },
                },
            }
        end
--    end
end

-- ʾ ringhalfright
local function ringhalfright (characters,target,base,accent)
--    if not characters[target] then
        local data1 = characters[base]
        local data2 = characters[accent]
        if data1 and data2 then
            characters[target] = { -- "ʾ"
                height   = data1.height,
                depth    = (data1.depth or 0) + 0.5*(data2.height or 0),
                width    = data1.width,
                unicode  = target,
                commands = {
                    { "slot", 0, 0 },
                    { "left", -0.35*(data2.width  or 0) + 0.5*(data2.width  or 
0)},
                    { "down", 0.0*(data2.height or 0) +       (data2.height or 
0) },
                    -- { "up", 0.0*(data2.height or 0) +   (data2.height or 0) 
},
                    { "slot", 0, 0x063, },
                    { "squeeze", 0.75*(data2.height or 0) },
                    { "extend",  0.75*(data2.width or 0) },
                },
            }
        end
--    end
end

local function initialize(tfmdata,value)
    if value then
        -- Hdotbelow(tfmdata.characters,0x02BF,0x063,0) --
        ringhalfleft (tfmdata.characters,0x02BF,0x063,0x063)
        ringhalfright(tfmdata.characters,0x02BE,0x063,0x063)
           -- (i.e., tfmdata.characters,target,base,accent)
        -- hdotbelow(tfmdata.characters,0x1E25,0x068,0x2D9)
    end
end

local function scale (ringhalfleft,ringhalfright)
    for v in next, ringhalfleft do
        v.height = 0.75 * (v.height or 0)
        v.width  = 0.75 * (v.width or 0)
        v.depth  = 0.75 * (v.depth  or 0)
    end
    for v in next, ringhalfright do
        v.height = 0.75 * (v.height or 0)
        v.width  = 0.75 * (v.width or 0)
        v.depth  = 0.75 * (v.depth  or 0)
    end
end

local specification = {
    name        = "glottalstops",
    description = "glottalstops",
    manipulators = {
        base = initialize,
        node = initialize,
    }
}
==============

Rotation for one of the characters is also needed. Here is an experimental test 
file:

https://www.dropbox.com/scl/fi/wi81e23wg17k8jasqpeon/transliteration-glottal-lua.tex?rlkey=gfwgjduhta1iemouwvjp1n6v3&dl=0
https://www.dropbox.com/scl/fi/rca5v6uusyj6mogyklfpd/transliteration-glottal-lua.pdf?rlkey=ou1lbfdkwec4tpbgkkk3kh9b9&dl=0

Thank you in advance for your guidance.

Best wishes
Idris

--
Professor Idris Samawi Hamid
Department of Philosophy
Colorado State University
Fort Collins, CO 80523
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

Reply via email to