* Character rotation font feature available?
@ 2016-02-14 20:42 Zhichu Chen
2016-02-14 21:30 ` Marco Patzer
0 siblings, 1 reply; 3+ messages in thread
From: Zhichu Chen @ 2016-02-14 20:42 UTC (permalink / raw)
To: ntg-context
Dear list,
I have some special needs that requires all the characters be rotated by
90 degrees. I've searched around the web and maybe adding
/FontMatrix [0 1 -1 0 0 0]
to the font descriptor dictionary is helpful. But I can't find a \pdf???
primitive that can achieve this. (Am I wrong about this?)
Another solution might be the "vrt2" font feature. There's no difference
between the results with or without enabling the feature. But
I do see the font has the feature by using the shell command:
otfinfo -f <fontname.otf>
May I put my temporary unsatisfying code here and ask for optimization?
Thanks in advance.
=======================================================================================
\startluacode
pdf.setcompresslevel(0)
pdf.setobjcompresslevel(0)
local registerotffeature = fonts.handlers.otf.features.register
--local registerafmfeature = fonts.handlers.afm.features.register
local setmetatableindex = table.setmetatableindex
local function jian(tfmdata,value)
if value then
local characters = tfmdata.characters
local resources = tfmdata.resources
local additions = { }
local private = resources.private
for unicode, old_c in next, characters do
private = private + 1
local width = old_c.width or 0
local height = old_c.height or 0
local depth = old_c.depth or 0
local htsp,wdsp,dpsp =
(height/65536)*(72.0/72.27),(width/65536)*(72.0/72.27),(depth/65536)*(72.0/72.27)
local bboxrulewd = 0.5
local baserulewd = 0.9
local new_c
new_c = {
width = width,
height = height,
depth = depth,
commands = {
{ "push" },
{ "right", width },
{ "special", "pdf: q 0 0 1 RG 0 0 1 rg " ..
bboxrulewd .. " w 0 " .. -dpsp .. " m 0 " .. htsp .. " l " .. -wdsp .. "
" .. htsp .. " l " .. -wdsp .. " " .. -dpsp .. " l s 1 0 1 RG 1 0 1 rg "
.. baserulewd .. " w [2 1] 0 d 0 0 m " .. -wdsp .. " 0 l S Q" },
{ "pop" },
{"special", "pdf: q 0 1 -1 0 0 0 cm"},
{ "down", 0.9*width },
{ "right", -0.1*width },
{ "slot", 1, private },
{ "down", -0.9*width },
{ "right", -0.9*width },
{"special", "pdf: 1 0 0 1 0 0 cm Q"},
}
}
setmetatableindex(new_c,old_c)
characters[unicode] = new_c
additions[private] = old_c
end
for k, v in next, additions do
characters[k] = v
end
resources.private = private
end
end
registerotffeature {
name = "jian",
description = "rotate glyphs",
manipulators = {
base = jian,
node = jian,
}
}
\stopluacode
\definefontfeature
[vertical]
[default]
[jian=yes]
\definefallbackfamily [mainface] [serif] [Adobe Ming Std]
[range={0x00400-0x2FA1F}%
,force=yes%
,features=vertical%
]
\definefallbackfamily [mainface] [sans] [Adobe Heiti Std]
[range={0x00400-0x2FA1F}%
,force=yes%
,features=vertical%
]
\definefallbackfamily [mainface] [mono] [Adobe Fangsong Std]
[range={0x00400-0x2FA1F}%
,force=yes%
,features=vertical%
]
\definefontfamily
[mainface]
[serif]
[TeX Gyre Termes]
[features=vertical]
\definefontfamily
[mainface]
[sans]
[TeX Gyre Heros]
[features=vertical]
\definefontfamily
[mainface]
[mono]
[TeX Gyre Cursor]
[features=vertical]
\definefontfamily
[mainface]
[math]
[TeX Gyre Termes Math]
[features=vertical]
\setscript
[hanzi]
\startsetups footnote:hanzi
\setscript[hanzi]
\stopsetups
\setupnote[footnote][setups={footnote:hanzi}]
\setupalign[hz,hanging]
\setupbodyfont[mainface,20pt]
\showframe
\starttext
裴駰曰凡是徐氏義稱徐姓名以別之餘者悉是駰%
注解并集衆家義。司馬貞索隱曰紀者記也本其%
%
事而記之故曰本紀又紀理也絲縷有紀而帝王書%
稱紀者言爲後代綱紀也。正義曰鄭玄注中候勅%
%
省圖云德合五帝坐星者稱帝又坤靈圖云德配天%
地在正不在私曰帝按太史公依世本大戴禮以黃%
%
帝顓頊帝嚳唐堯虞舜爲五帝譙周應劭宋均皆同%
而孔安國尚書序皇甫謐帝王世紀孫氏注世本並%
%
以伏犧神農黃帝爲三皇少昊顓頊高辛唐虞爲五%
帝裴松之史目云天子稱本紀諸侯曰世家本者繫%
%
其本系故曰本紀者理也統理衆事繫之年月名之%
曰紀第者次序之目一者舉數之由故曰五帝本紀%
%
第一。又曰禮云動則左史書之言則右史書之正%
義云左陽故記動右隂故記言言爲尚書事爲春秋%
%
按春秋時置左右%
史故云史記也%
%
%
裴駰曰凡是徐氏義稱徐姓名以別之餘者悉是駰%
注解并集衆家義。司馬貞索隱曰紀者記也本其%
%
事而記之故曰本紀又紀理也絲縷有紀而帝王書%
稱紀者言爲後代綱紀也。正義曰鄭玄注中候勅%
%
省圖云德合五帝坐星者稱帝又坤靈圖云德配天%
地在正不在私曰帝按太史公依世本大戴禮以黃%
%
帝顓頊帝嚳唐堯虞舜爲五帝譙周應劭宋均皆同%
而孔安國尚書序皇甫謐帝王世紀孫氏注世本並%
%
以伏犧神農黃帝爲三皇少昊顓頊高辛唐虞爲五%
帝裴松之史目云天子稱本紀諸侯曰世家本者繫%
%
其本系故曰本紀者理也統理衆事繫之年月名之%
曰紀第者次序之目一者舉數之由故曰五帝本紀%
%
第一。又曰禮云動則左史書之言則右史書之正%
義云左陽故記動右隂故記言言爲尚書事爲春秋%
%
按春秋時置左右%
史故云史記也%
\stoptext
--
Best regards,
ℤhichu ℂhen
Shanghai Institute of Applied Physics
No. 2019, Jialuo Road
Jiading, Shanghai, P.R.China
Tel: +86-21-39194888
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Character rotation font feature available?
2016-02-14 20:42 Character rotation font feature available? Zhichu Chen
@ 2016-02-14 21:30 ` Marco Patzer
2016-02-15 5:19 ` Zhichu Chen
0 siblings, 1 reply; 3+ messages in thread
From: Marco Patzer @ 2016-02-14 21:30 UTC (permalink / raw)
To: ntg-context
On Mon, 15 Feb 2016 04:42:31 +0800
Zhichu Chen <chenzhichu@sinap.ac.cn> wrote:
> I have some special needs that requires all the characters be rotated
> by 90 degrees. I've searched around the web and maybe adding
> /FontMatrix [0 1 -1 0 0 0]
> to the font descriptor dictionary is helpful. But I can't find a
> \pdf??? primitive that can achieve this. (Am I wrong about this?)
>
> Another solution might be the "vrt2" font feature. There's no
> difference between the results with or without enabling the feature.
> But I do see the font has the feature by using the shell command:
> otfinfo -f <fontname.otf>
I don't know exactly how it's supposed to look like, especially
kerning, vertical spacing, etc. Just making sure you know about
\applytocharacters:
\starttext
\applytocharacters\rotate{Foo Bar}
\stoptext
as well as \handletokens Foo Bar\with\rotate
Maybe that's already sufficient for your use case.
Marco
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Character rotation font feature available?
2016-02-14 21:30 ` Marco Patzer
@ 2016-02-15 5:19 ` Zhichu Chen
0 siblings, 0 replies; 3+ messages in thread
From: Zhichu Chen @ 2016-02-15 5:19 UTC (permalink / raw)
To: ntg-context
Hi Marco,
On 02/15/2016 05:30 AM, Marco Patzer wrote:
> On Mon, 15 Feb 2016 04:42:31 +0800
> Zhichu Chen <chenzhichu@sinap.ac.cn> wrote:
>
>> I have some special needs that requires all the characters be rotated
>> by 90 degrees. I've searched around the web and maybe adding
>> /FontMatrix [0 1 -1 0 0 0]
>> to the font descriptor dictionary is helpful. But I can't find a
>> \pdf??? primitive that can achieve this. (Am I wrong about this?)
>>
>> Another solution might be the "vrt2" font feature. There's no
>> difference between the results with or without enabling the feature.
>> But I do see the font has the feature by using the shell command:
>> otfinfo -f <fontname.otf>
> I don't know exactly how it's supposed to look like, especially
> kerning, vertical spacing, etc. Just making sure you know about
> \applytocharacters:
I didn't know the command, thank you for sharing.
>
> \starttext
> \applytocharacters\rotate{Foo Bar}
> \stoptext
>
> as well as \handletokens Foo Bar\with\rotate
>
> Maybe that's already sufficient for your use case.
>
> Marco
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
--
Best regards,
ℤhichu ℂhen
Shanghai Institute of Applied Physics
No. 2019, Jialuo Road
Jiading, Shanghai, P.R.China
Tel: +86-21-39194888
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-15 5:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-14 20:42 Character rotation font feature available? Zhichu Chen
2016-02-14 21:30 ` Marco Patzer
2016-02-15 5:19 ` Zhichu Chen
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).