ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Ulrike Fischer <news3@nililand.de>
To: ntg-context@ntg.nl
Subject: Re: manipulate ttf-fonts loaded with luatex
Date: Tue, 2 Nov 2010 16:16:39 +0100	[thread overview]
Message-ID: <w5kp80nr6xrw$.dlg@nililand.de> (raw)
In-Reply-To: <4CC9C769.5020005@wxs.nl>

Am Thu, 28 Oct 2010 20:56:41 +0200 schrieb Hans Hagen:

 
>> Hm. I do have a bit the impression as if we have here a context and
>> latex philosophy clash. I'm not asking you to provide a funktion
 
> Huh? I'm not sure what philosophy refers to, 

Well I refer to sentences like this:
 
> Sure, but the first complaints would end up in ... my 
> mailbox unless your package is private .... 

> The fact that it's custom in latex to overload code and 
> thus create a maintaince depency does not mean that I want such a 
> dependency on my code.

Unlike context latex is decentral. Reponsability is splitted. And so
no one would feel that I'm a thread for "their" code or to their
support burden if I would announce a package.  Nobody would feel the
urge to take away the task from me for fear that I break something. 

Anyway: I'm writing latex packages. Whatever I will do: no context
user will be affected by my code.  


> > Couldn't you give some examples how to manipulate a font after it
> > has been defined with \font\test (if it is possible) and then let me
> > play around?

...

> 
> Anyhow, you can access some font data afterwards. In context form:
> 
>      \startluacode
>          function Whatever(name)
>              for k, v in pairs(fonts.ids[font.current()].descriptions) do
>                  if v.name == name then
>                      tex.sprint("\\char"..k.."\\relax")
>                      break
>                  end
>              end
>          end
>      \stopluacode
>      \font\test=file:pirat.ttf
>      \def\MyChessChar#1{{\test\directlua{Whatever("#1")}}}
>      \MyChessChar{c160}
> 
> This is dead slow and inefficient but as you don't want a proper 
> function for it I don't care too much. 

This is an interesting piece of code but not actually what I asked
for. I don't need to loop through the font to find out the correct
\char-command connected to a glyph. I can look it up in fontforge
and store it in a table. I need a way to reencode/reorder the font,
so that the input "K" points to the glyph "c140". Pirat is not the
only chessfont I have, I don't want to change the input if I change
the font, so every chessfont should have the same internal order.

My main problem is that they are so few informations about the
generic context font loader code. E.g. after the rereading of the
luatex manual I came up with the following:

\starttext
\font\test={file:PIRAT.TTF}
\test
%K\char75\char140\char140

\directlua{
mytable=font.fonts[font.id('test')]
mytable.characters[75],mytable.characters[140]=mytable.characters[140],mytable.characters[75]
tex.definefont("testb",font.define(mytable))
}

\testb
K\char75\char140\char140
\stoptext

Then input "K" gives me (as wanted) a king. 

But it leads to questions:

1. Why is the spacing in \testb wrong if the chars have been already
used after \test?

2. Which values/tables in mytable should I reset/change too to get a
"sane" font \testb?

3. I can also use "mytable=fonts.ids[font.id('test')]". Is this
better? What are the differences?


> Interesting is that it does not  work out (as wis to be expected
> as the normal glyph access function does something similar).

? I didn't understand this remark. If you mean that you didn't get
an output: There is nothing at position 160. The king is c140.


-- 
Ulrike Fischer 

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2010-11-02 15:16 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27 10:37 Ulrike Fischer
2010-10-27 18:35 ` Aditya Mahajan
2010-10-27 20:01   ` Ulrike Fischer
2010-10-27 21:32     ` Aditya Mahajan
2010-10-28  8:34       ` Ulrike Fischer
2010-10-28 12:33         ` Hans Hagen
2010-10-28 12:57           ` Ulrike Fischer
2010-10-28 13:08             ` Taco Hoekwater
2010-10-28 13:29               ` Ulrike Fischer
2010-10-28 13:33               ` Khaled Hosny
2010-10-28 14:59                 ` Hans Hagen
2010-10-28 15:37                   ` Ulrike Fischer
2010-10-28 16:01                     ` Hans Hagen
2010-10-28 17:08                       ` Ulrike Fischer
2010-10-28 17:17                         ` Hans Hagen
2010-10-28 17:48                           ` Ulrike Fischer
2010-10-28 18:56                             ` Hans Hagen
2010-11-02 15:16                               ` Ulrike Fischer [this message]
2010-11-02 15:40                                 ` Hans Hagen
2010-10-28 19:35                             ` Hans Hagen
2010-10-28 19:46                               ` Khaled Hosny
2010-10-28 20:29                                 ` Hans Hagen
2010-10-28 15:48                   ` Taco Hoekwater
2010-10-28 15:59                     ` Khaled Hosny
2010-10-28 16:06                       ` Hans Hagen
2010-10-28 16:29                       ` Hans Hagen
2010-10-28 16:47                     ` Ulrike Fischer
2010-10-28 17:03                       ` taco
2010-10-28 19:48                         ` Khaled Hosny
2010-10-28 13:10             ` Hans Hagen
2010-10-28 13:34               ` Ulrike Fischer

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='w5kp80nr6xrw$.dlg@nililand.de' \
    --to=news3@nililand.de \
    --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).