[NTG-context] Character rotation font feature available?

Zhichu Chen chenzhichu at sinap.ac.cn
Sun Feb 14 21:42:31 CET 2016


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



More information about the ntg-context mailing list