ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Hamid,Idris" <Idris.Hamid@ColoState.EDU>
To: "ntg-context@ntg.nl" <ntg-context@ntg.nl>,
	Hans Hagen <j.hagen@xs4all.nl>
Subject: [NTG-context] Re: Scaling characters without font switching in CLD
Date: Sat, 12 Aug 2023 18:05:46 +0000	[thread overview]
Message-ID: <2419f266-53e5-4b93-87bd-7424d22cb84d@Spark> (raw)
In-Reply-To: <eee3ab0f-875e-39f9-a546-44b76aa81b1d@xs4all.nl>


[-- Attachment #1.1: Type: text/plain, Size: 3577 bytes --]

On Aug 12, 2023, 9:35 AM -0600, Hans Hagen <j.hagen@xs4all.nl>, wrote:
** Caution: EXTERNAL Sender **

On 8/12/2023 4:03 PM, Hamid,Idris wrote:

\tfx causes a switch to computer modern.

Indeed. Something I need to discuss with Wolfgang as double checking is needed before I patch.

Ah.. ok.

But what if we want to scale independently of font switching?
There is no need to go lua here (esp when you have not done vf magick
before and i'm not going to debug code that i have little clue what it's
about to do).

Many thanks. Part of the context is that I have some updatable mission-critical documents that depended on \defineactivecharacter, which is apparently deprecated in LMTX. See earlier thread with that subject line.

[BTW: Just this morning someone from the Persian Gulf asked for an updated version of a document whose compilation depended on \defineactivecharacter, so I need to get this working in the new regime -)]

Now the templates that you provided - many, many thanks! - have what is needed to care of everything except for two characters: 02BE and 02BF.

For one of those two remaining characters we also need scaling, for the other we also need scaling + rotation. It is not clear to me whether the scaling/rotation commands should fall under the character function, e.g.,

=======
-- ʿ ringhalfleft
local function ringhalfleft (characters,target,base,accent)
=======

the initialize function

=======
local function initialize(tfmdata,value)
=======

or whether we just make a new function altogether

=======
local function scale (ringhalfleft)  -- shooting in the dark here
=======

So the reason I said CLD is best is because we already defined all of the needed characters that way -- using your template -- except for these two, for which we need to add scaling and or rotation.

The attached (linked in the previous email but attached here) gives us rotation but no scaling.
- we cheat here and yuse glyph scaled (I have to provide a relative to
current x/y scaling, don't use \glyphscale as that one is used by
context itself
- we use the style variant so that it adapts
- you have to replace "Serif" with "YourFont" and map that one onto a
file (YourFont YourFontBold etc)
- more about these box manipulations in the low level manual

Ok. Just discovered the 11 low-level manuals yesterday, not sure which one to focus on in this case -)
\startsetups glyph:iTee
\dontleavehmode\hpack\bgroup
\setbox\scratchbox \ruledhbox \bgroup
\glyphxscale 400
\glyphyscale 400
\getglyphstyled{Serif}{T}% choose a font here
\egroup
\scratchheight 2.75\ht\scratchbox
\boxyoffset \scratchbox\scratchheight
\boxorientation\scratchbox\plustwo
\ht \scratchbox\scratchheight
\box\scratchbox
\egroup
\stopsetups

\definesymbol
[iTee]
[\directsetup{glyph:iTee}]

\startTEXpage [offset=1ts,width=2cm]
\ruledhbox {\tfx T \symbol{iTee}} \par
\ruledhbox {T \symbol{iTee}} \par
\ruledhbox {\tfa T \symbol{iTee}} \par
\ruledhbox {\bfd T \symbol{iTee}}
\stopTEXpage

Great, will study this. The challenge (for me) will be integrating this approach into the lua definitions of the two needed characters. With \defineactivecharacter deprecated, there seems to be no way other than CLD to make and register the needed macro for \definefontfeature -- and we want to move forward with the new regime and not look back.

With many thanks and much gratitude, Hans.

Best wishes
Idris

--
Professor Idris Samawi Hamid
Department of Philosophy
Colorado State University
Fort Collins, CO 80523

[-- Attachment #1.2: Type: text/html, Size: 5267 bytes --]

[-- Attachment #2: transliteration--glottal-lua.pdf --]
[-- Type: application/octet-stream, Size: 6507 bytes --]

[-- Attachment #3: transliteration--glottal-lua.tex --]
[-- Type: application/octet-stream, Size: 4333 bytes --]

% % \defineactivecharacter ʿ {\high{c}}
% % \defineactivecharacter ʾ {\kern.07 em \high{\rotate[rotation=180,location=high]{c}}}

% % or better

% % \definecharacter ʿ {\high{c}}
% % \definecharacter ʾ {\kern.07 em \high{\rotate[rotation=180,location=high]{c}}}

\startluacode

-- ʿ 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,
    }
}

fonts.handlers.otf.features.register(specification)
\stopluacode

\definefontfeature[glottals][default][glottalstops=yes]

% \definedfont[Serif*default @ 11pt]

\showglyphs

\noheaderandfooterlines

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

\switchtobodyfont[schola,12pt] 
\setupwhitespace[big]

\setuplayout[lines=40]

\starttext

\startTEXpage[offset=10em,width=10in]
\definedfont[MinionPro-Regular.otf*glottals @ 112pt]

1.
cʿc \ AʿA

\blank[7*big]

2.
cʾc \ AʾA

\blank[7*big]

3.
c{\definedfont[MinionPro-Regular.otf*glottals @ 84pt]ʾ}c \ 
A{\definedfont[MinionPro-Regular.otf*glottals @ 84pt]ʾ}A

\blank[7*big]

4.
c{\definedfont[MinionPro-Regular.otf*glottals @ 84pt]\rotate[rotation=180,location=high]{ʾ}}c \
A{\definedfont[MinionPro-Regular.otf*glottals @ 84pt]\rotate[rotation=180,location=high]{ʾ}}A
\stopTEXpage

\stoptext 

[-- Attachment #4: Type: text/plain, Size: 495 bytes --]

___________________________________________________________________________________
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	other threads:[~2023-08-12 18:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-12 14:03 [NTG-context] " Hamid,Idris
2023-08-12 15:34 ` [NTG-context] " Hans Hagen
2023-08-12 18:05   ` Hamid,Idris [this message]
2023-08-12 20:10     ` Hans Hagen via ntg-context
2023-08-12 21:33       ` Hamid,Idris
2023-08-12 21:48         ` Hans Hagen
2023-08-12 22:11           ` Hamid,Idris
2023-08-12 22:16             ` Hamid,Idris
2023-08-12 22:56               ` Hamid,Idris
2023-08-13 12:32                 ` Hans Hagen via ntg-context

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2419f266-53e5-4b93-87bd-7424d22cb84d@Spark \
    --to=idris.hamid@colostate.edu \
    --cc=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).