From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: MkIV italic correction?
Date: Wed, 27 May 2009 10:11:16 +0200 [thread overview]
Message-ID: <4A1CF5A4.7040906@wxs.nl> (raw)
In-Reply-To: <bfeb3bf10905262134u34174690m3d01d0cfd5d5127c@mail.gmail.com>
Dohyun Kim wrote:
> Considering current state that we don't know any fonts that has ITLC table,
> it would be better than nothing to implement italic correction as follows.
> In the following code, "fontdata" is a table returned by the function
> "fonts.define.read".
>
> local param = fontdata.parameters
> local italicangle = fontdata.shared.otfdata.metadata.italicangle
> if italicangle and italicangle < 0 then
> local uwidth = fontdata.shared.otfdata.metadata.uwidth or 40
> local factor = fontdata.factor or 655.36
> param.slant = - math.tan(italicangle*math.pi/180) * param.quad
> for i,v in pairs(fontdata.characters) do
> local gl = fontdata.descriptions[i]
> local it = (gl.boundingbox[3] - gl.width + uwidth*0.5) * factor
> if it > 0 then v.italic = it end
> end
> end
there are seleveral solutions:
- extend the font with this info (faster but then it's always there
which might not be ok as it's an approximation)
- calculate it after loading (which is what you propose)
in the mkiv code we do have a hook for that kind of things so this is
then what i propose. watch how we don't scale here, we just add an entry
to the shared data as that's where we hook in; the real implementation
would look slightly different as an optimization is possible
\starttext
\startluacode
table.insert(fonts.triggers,"itlc")
local function itlc(tfmdata,value)
if value then
-- the magic 40 and it formula come from Dohyun Kim
local fontdata = tfmdata.shared.otfdata or tfmdata.shared.afmdata
local metadata = fontdata and fontdata.metadata
if metadata then
local italicangle = metadata.italicangle
if italicangle and italicangle ~= 0 then
local uwidth = (metadata.uwidth or 40)/2
for unicode, d in next, tfmdata.descriptions do
local it = d.boundingbox[3] - d.width + uwidth
if it ~= 0 then
d.italic = it
end
end
end
end
end
end
fonts.initializers.base.otf.itlc = itlc
fonts.initializers.node.otf.itlc = itlc
fonts.initializers.base.afm.itlc = itlc
fonts.initializers.node.afm.itlc = itlc
\stopluacode
\definedfont[SerifItalic*default at 24pt] test\/test
\definefontfeature[xdefault][default][itlc=yes]
\definedfont[SerifItalic*xdefault at 24pt] test\/test
\stoptext
i could add it to the generic code (although i'm not going to add all
the other context goodies to the generic code definitely not as long as
they're experimental)
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| 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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2009-05-27 8:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-20 6:25 Corsair
2009-05-20 7:21 ` Yue Wang
2009-05-20 7:37 ` Corsair
2009-05-21 9:55 ` Hans Hagen
2009-05-21 11:55 ` Corsair
2009-05-21 11:59 ` Taco Hoekwater
2009-05-21 13:36 ` Corsair
2009-05-22 9:15 ` Taco Hoekwater
2009-05-21 13:20 ` Khaled Hosny
2009-05-22 9:25 ` Taco Hoekwater
2009-05-22 10:48 ` Hans Hagen
2009-05-22 11:23 ` Taco Hoekwater
2009-05-22 12:44 ` French typography is back Robert-André Mauchin
2009-05-22 15:51 ` Arthur Reutenauer
2009-05-22 16:38 ` Robert-André Mauchin
2009-05-22 22:58 ` Arthur Reutenauer
2009-05-22 16:40 ` luigi scarso
2009-05-22 17:06 ` Hans Hagen
2009-05-27 4:34 ` MkIV italic correction? Dohyun Kim
2009-05-27 8:11 ` Hans Hagen [this message]
2009-06-01 15:15 ` Khaled Hosny
2009-06-01 20:19 ` Hans Hagen
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=4A1CF5A4.7040906@wxs.nl \
--to=pragma@wxs.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).