ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: "Hamid,Idris" <Idris.Hamid@ColoState.EDU>,
	mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Hans Hagen <j.hagen@freedom.nl>
Subject: [NTG-context] Re: Scaling characters without font switching in CLD
Date: Sun, 13 Aug 2023 14:32:31 +0200	[thread overview]
Message-ID: <89be6b88-3bf2-84dd-60cc-1fd542e643f6@freedom.nl> (raw)
In-Reply-To: <3ff5855a-bd10-4d18-847d-8c5b214c1a0a@Spark>

[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]

On 8/13/2023 12:56 AM, Hamid,Idris wrote:
> On Aug 12, 2023, 4:20 PM -0600, Hans Hagen <j.hagen@xs4all.nl>, wrote:
> 
>> btw, no need for squeezine as there are virtual commands for scaling; not for rotating
> 
>  From your original CLD template:
> 
> local function topthing(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 or 0) + 0.5*(data2.height or 0),
>                  depth    = data1.depth,
>                  width    = data1.width,
>                  unicode  = target,
>                  commands = {
>                      { "slot", 0, 0x048 },
>                      { "left", 0.5*(data2.width  or 0) + 0.5*(data1.width  or 0) },
>                      { "up",   0.5*(data2.height or 0) },
>                      { "slot", 0, 0x2D9, },
>                  },
>              }
>          end
> --    end
> end
a little lesson in efficiency attached

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

[-- Attachment #2: transliteration-lua.tex --]
[-- Type: text/plain, Size: 4361 bytes --]

\startluacode

-- Ṯṯ Ḥḥ Ḫḫ Ḏḏ Šš Ṣṣ Ḍḍ Ṭṭ Ẓẓ Ġġ Āā Īī Ūū ʿ ʾ

local function process(characters,target,value)
    if value == "force" then
        return true
    elseif characters[target] then
        return false
    else
        return true
    end
end

local function below(characters,value,target,base,accent,left,down,depth)
    if process(characters,target,value) then
        local data1 = characters[base]
        local data2 = characters[accent]
        if data1 and data2 then
            characters[target] = {
                height   = data1.height,
                depth    = depth*data2.height,
                width    = data1.width,
                unicode  = target,
                commands = {
                    { "slot", 0, base },
                    { "left", left*(data2.width  or 0) + 0.5*(data1.width  or 0) },
                    { "down", down*(data2.height or 0) +     (data2.height or 0) },
                    { "slot", 0, accent },
                },
            }
        end
    end
end

local function ccrap(characters,value,target,base,template,scale,mirror)
    if process(characters,target,value) then
        local data1 = characters[base]
        local data2 = characters[template]
        if data1 and data2 then
            local height1 = data1.height
            local height2 = data2.height
            local width1  = scale * data1.width
            characters[target] = {
                height   = height2,
                depth    = 0,
                width    = width1,
                unicode  = target,
                commands = {
                    {
                        "offset",
                        mirror and width1 or 0,
                        height2 - (mirror and 0 or scale*height1),
                        base,
                        mirror and -scale or scale,
                        mirror and -scale or scale
                    },
                },
            }
        end
    end
end

-- in principle one can have some extra parameters for shifts but this
-- is suboptimal anyway and only meant for minion

local function initialize(tfmdata,feature,value)
    if value then
        local characters = tfmdata.characters

        below (characters,value,0x1E6E,0x054,0x0AF,0.50,0.07,0.20) -- Tlinebelow
        below (characters,value,0x1E6F,0x074,0x0AF,0.45,0.07,0.20) -- tlinebelow
        below (characters,value,0x1E24,0x048,0x2D9,0.50,0.10,0.30) -- Hdotbelow
        below (characters,value,0x1E25,0x068,0x2D9,0.50,0.10,0.30) -- hdotbelow
        below (characters,value,0x1E2A,0x048,0x2D8,0.50,0.10,0.35) -- Hbrevebelow
        below (characters,value,0x1E2B,0x068,0x2D8,0.50,0.10,0.35) -- hbrevebelow
        below (characters,value,0x1E0E,0x044,0x0AF,0.50,0.07,0.20) -- Dlinebelow
        below (characters,value,0x1E0F,0x064,0x0AF,0.40,0.07,0.20) -- dlinebelow
        below (characters,value,0x1E62,0x053,0x2D9,0.50,0.12,0.30) -- Sdotbelow
        below (characters,value,0x1E63,0x073,0x2D9,0.40,0.12,0.30) -- sdotbelow
        below (characters,value,0x1E0C,0x044,0x2D9,0.50,0.12,0.30) -- Ddotbelow
        below (characters,value,0x1E0D,0x064,0x2D9,0.40,0.12,0.30) -- ddotbelow
        below (characters,value,0x1E6C,0x054,0x2D9,0.50,0.12,0.30) -- Tdotbelow
        below (characters,value,0x1E6D,0x074,0x2D9,0.40,0.12,0.30) -- tdotbelow
        below (characters,value,0x1E92,0x05A,0x2D9,0.50,0.12,0.30) -- Zdotbelow
        below (characters,value,0x1E93,0x07A,0x2D9,0.40,0.12,0.30) -- zdotbelow

        ccrap (characters,value,0x02BE,0x063,0x043,0.5,false) -- some fake
        ccrap (characters,value,0x02BF,0x063,0x043,0.5,true)  -- some fake
    end
end

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

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

% \definefontfeature[default][default][idrify=yes]
\definefontfeature[default][default][idrify=force]

\showglyphs

\startTEXpage[offset=1ts]
    \definedfont[MinionPro-Regular.otf*default @ 12pt]%
    Ṯṯ Ḥḥ Ḫḫ Ḏḏ Šš Ṣṣ Ḍḍ Ṭṭ Ẓẓ Ġġ Āā Īī Ūū ʿ ʾ
\stopTEXpage

\stoptext

[-- Attachment #3: 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-13 12:34 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
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 [this message]

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=89be6b88-3bf2-84dd-60cc-1fd542e643f6@freedom.nl \
    --to=ntg-context@ntg.nl \
    --cc=Idris.Hamid@ColoState.EDU \
    --cc=j.hagen@freedom.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).