ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Inconsistent behavior: \addfontfeature and CLD local function
@ 2023-08-20 15:33 Hamid,Idris
  2023-08-20 15:45 ` [NTG-context] " Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Hamid,Idris @ 2023-08-20 15:33 UTC (permalink / raw)
  To: ntg-context


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

Dear gang,

For \addfeature and the like, a virtual font feature defined in terms of a CLD local function behaves differently from other font features. MWE:

==============
\startluacode
local function squeeze(tfmdata)
    for k, v in next, tfmdata.characters do
        v.width = 1.75 * (v.height or 0)
        v.depth  = 1.75 * (v.depth  or 0)
    end
end

local specification = {
    name        = "sqtfm",
    description = "test",
    manipulators = {
        base = squeeze,
        node = squeeze,
    }
}

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

\definefontfeature[forceno]
                  [mode=node,
                   script=latn]


\definefontfeature[forceyes]
                  [mode=node,
                   script=latn,
                   smcp=force,
                   sqtfm=force]
                   % smcp=yes,
                   % sqtfm=yes]

\showglyphs

\startTEXpage[offset=1em]
\definedfont[texgyretermes-regular*forceyes]
% \definedfont[texgyretermes-regular*forceno]
% \addfeature{forceyes}

abcdefg
\stopTEXpage
==============
 You may toggle these lines:

\definedfont[texgyretermes-regular*forceyes]
% \definedfont[texgyretermes-regular*forceno]
% \addfeature{forceyes}

With
\definedfont[texgyretermes-regular*forceyes]
active we get the expected result: small caps plus some negative squeeze (= spread in this case).

With
\definedfont[texgyretermes-regular*forceno]
\addfeature{forceyes}
active we get an *unexpected* result: small caps but no negative squeeze.

(Similar results occur if we toggle the "=force" lines with the "=yes" lines, but the larger project of which this is the MWE uses the force key.)

Clue: A CLD with a feature defined via fonts.handlers.otf.addfeature doesn't seem to have this problem:

==============

\startluacode
local function squeeze(tfmdata)
    for k, v in next, tfmdata.characters do
        v.width = 1.75 * (v.height or 0)
        v.depth  = 1.75 * (v.depth  or 0)
    end
end

local specification = {
    name        = "sqtfm",
    description = "test",
    manipulators = {
        base = squeeze,
        node = squeeze,
    }
}

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

fonts.handlers.otf.addfeature {
    name = "stest",
    type = "substitution",
    data = {
        a = "X",
        b = "P",
    }
}
\stopluacode

\definefontfeature[forceno]
                  [mode=node,
                   script=latn]


\definefontfeature[forceyes]
                  [mode=node,
                   script=latn,
                   % % smcp=force,
                   sqtfm=force,
                   stest=force]
                   % % smcp=yes,
                   % sqtfm=yes,
                   % stest=yes]

\showglyphs

\startTEXpage[offset=1em]
\definedfont[texgyretermes-regular*forceyes]
% \definedfont[texgyretermes-regular*forceno]
% \addfeature{forceyes}

abcdefg
\stopTEXpage
==============

So only the local-function feature appears to exhibit this inconsistency.

What is the explanation for this inconsistent behavior?
Is there a way to get the expected result for \addfeature etc.?

Thank you in advance.

Best wishes
Idris

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

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

[-- Attachment #2: 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [NTG-context] Re: Inconsistent behavior: \addfontfeature and CLD local function
  2023-08-20 15:33 [NTG-context] Inconsistent behavior: \addfontfeature and CLD local function Hamid,Idris
@ 2023-08-20 15:45 ` Hans Hagen
  2023-08-20 19:10   ` Hamid,Idris
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2023-08-20 15:45 UTC (permalink / raw)
  To: Hamid,Idris, mailing list for ConTeXt users

On 8/20/2023 5:33 PM, Hamid,Idris wrote:
> Dear gang,
> 
> For \addfeature and the like, a virtual font feature defined in terms of a CLD local function behaves differently from other font features. MWE:
> 
> ==============
> \startluacode
> local function squeeze(tfmdata)
>      for k, v in next, tfmdata.characters do
>          v.width = 1.75 * (v.height or 0)
>          v.depth  = 1.75 * (v.depth  or 0)
>      end
> end
> 
> local specification = {
>      name        = "sqtfm",
>      description = "test",
>      manipulators = {
>          base = squeeze,
>          node = squeeze,
>      }
> }
because much more has to be done to satisfy the backend (liek advance 
with and such) .. you cannot just change dimensions on the fly for 
characters that could potentially be shared just as you can't change 
glyph dimension mid document

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
-----------------------------------------------------------------

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [NTG-context] Re: Inconsistent behavior: \addfontfeature and CLD local function
  2023-08-20 15:45 ` [NTG-context] " Hans Hagen
@ 2023-08-20 19:10   ` Hamid,Idris
  0 siblings, 0 replies; 3+ messages in thread
From: Hamid,Idris @ 2023-08-20 19:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Hans Hagen


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

Ok, understood. Thank you for the explanation.

Best wishes
Idris

--
Professor Idris Samawi Hamid
Department of Philosophy
Colorado State University
Fort Collins, CO 80523
On Aug 20, 2023, 9:45 AM -0600, Hans Hagen <j.hagen@xs4all.nl>, wrote:
** Caution: EXTERNAL Sender **

On 8/20/2023 5:33 PM, Hamid,Idris wrote:
Dear gang,

For \addfeature and the like, a virtual font feature defined in terms of a CLD local function behaves differently from other font features. MWE:

==============
\startluacode
local function squeeze(tfmdata)
for k, v in next, tfmdata.characters do
v.width = 1.75 * (v.height or 0)
v.depth = 1.75 * (v.depth or 0)
end
end

local specification = {
name = "sqtfm",
description = "test",
manipulators = {
base = squeeze,
node = squeeze,
}
}
because much more has to be done to satisfy the backend (liek advance
with and such) .. you cannot just change dimensions on the fly for
characters that could potentially be shared just as you can't change
glyph dimension mid document

Hans

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pragma-ade.nl%2F&data=05%7C01%7CIdris.Hamid%40colostate.edu%7C2e50b62ee65c41cb704308dba1947214%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638281431156972904%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=SE09abKBexjImz73ucHLxz4Wv6reS75qYg88LrdNOrg%3D&reserved=0 | https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pragma-pod.nl%2F&data=05%7C01%7CIdris.Hamid%40colostate.edu%7C2e50b62ee65c41cb704308dba1947214%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638281431156972904%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HDd8xwSOEAqmBG04WkLwG2NBE8JXlAeGWKVI9iqIU1A%3D&reserved=0
-----------------------------------------------------------------


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

[-- Attachment #2: 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-20 19:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-20 15:33 [NTG-context] Inconsistent behavior: \addfontfeature and CLD local function Hamid,Idris
2023-08-20 15:45 ` [NTG-context] " Hans Hagen
2023-08-20 19:10   ` Hamid,Idris

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).