時間限制 4000 ms ・ 記憶體限制 256 MB

題目描述

給glyphID0..N−1的有向無環組裝表,每component只能引用較小ID。每glyph宣告兩個phantom metric points L=(lx,ly)、R=(rx,ry),不屬輪廓點、不占pointindex。simple glyph給按順序的points和嚴格升序contour-end indices;空simple合法。composite glyph給依序components;從空輪廓開始接每個child已完整展開的points與contours,不能因child重複引用就共用可變點串。每component帶有理2×2矩陣A(四個整數各除2),無可逆性限制。

XY模式給整數dx,dy、scaled位、round位。scaled0時translation t=(dx,dy),scaled1時t=A(dx,dy);round1只對t的兩座標分別捨入nearest整數、恰半取偶數,包含負值。先算完整t再round,不round A本身或child transformed points。POINT模式給parentPointIndex及childPointIndex,parent索引指本composite已加入的真輪廓點,child索引指child完整展開後真輪廓點(均0起)。令t=parentPoint−A childPoint,使指定兩點精確貼合;POINT沒有scaled/round欄,不碰phantom points。輸入promise所有POINT索引合法,所以第一component不能用POINT。

每child point p加到parent的新座標是A p+t,contour-end indices加原parent點數偏移。child的兩phantom metrics亦作同一A p+t;每component另有useMetrics0/1。若1,本composite最終metrics改為此component變換後的child metrics;多個1以最後component為準。若都0則保留本glyph宣告metrics(不因其他components平移/縮放而變)。被選metrics不能插入輪廓影響後續POINT索引。simple自己的宣告metrics直接保留。這是明訂TrueType-inspired精確組裝,不處理字型檔、安全解析、hinting指令或rasterization。

輸入輸出與限制

輸入N1..8。每glyph先S或C與四個metric整數。S接一行P K,再P行x y,最後一行K個contour ends(K0寫-);P0必K0,P>0 ends最後P−1。C接M1..4,再M行child a b c d useMetrics mode args;矩陣第一row(a,b)/2,第二row(c,d)/2;XY接dx dy scaled round,POINT接parentIndex childIndex。所有原座標/metric/dx/dy在−4..4,矩陣整數−3..3。每個展開glyph points≤80、contours≤40;每simple P≤8。所有references/indices/contours合法。輸每glyph依ID一段:GLYPH id P K,再P行最簡分數x y,再ENDS及K個ends(K0只ENDS),再METRICS lx ly rx ry四分數。全部分數p/q、整數也/1。

範例說明

第一例child兩點為(−1,0)、(1,2)。先原位接一份,再旋轉90度並令child第0點貼到parent第1點,translation為(1,3),新兩點為(1,2)、(−1,4)。useMetrics使phantom點成為(1,3)、(1,7),不插入四個輪廓點之間。

第二例child無輪廓但有metrics(1,0)、(3,0)。矩陣為半倍縮放,scaled offset(−3,−1)先變(−3/2,−1/2),ties-even得到(−2,0)。最終metrics(−3/2,0)、(−1/2,0),仍然沒有輪廓點。

範例測資

範例輸入 1

2
S 0 0 4 0
2 1
-1 0
1 2
1
C 0 0 0 0
2
0 2 0 0 2 0 XY 0 0 0 0
0 0 -2 2 0 1 POINT 1 0

範例輸出 1

GLYPH 0 2 1
-1/1 0/1
1/1 2/1
ENDS 1
METRICS 0/1 0/1 4/1 0/1
GLYPH 1 4 2
-1/1 0/1
1/1 2/1
1/1 2/1
-1/1 4/1
ENDS 1 3
METRICS 1/1 3/1 1/1 7/1

範例輸入 2

2
S 1 0 3 0
0 0
-
C 0 0 0 0
1
0 1 0 0 1 1 XY -3 -1 1 1

範例輸出 2

GLYPH 0 0 0
ENDS
METRICS 1/1 0/1 3/1 0/1
GLYPH 1 0 0
ENDS
METRICS -3/2 0/1 -1/2 0/1
請先登入後再提交程式碼

討論與題解

載入討論區…

更多