diff --git a/test/meson.build b/test/meson.build index 37ea0232..ad473def 100644 --- a/test/meson.build +++ b/test/meson.build @@ -17,6 +17,7 @@ test_file = [ 'testSwCanvas.cpp', 'testSwCanvasBase.cpp', 'testSwEngine.cpp', + 'testText.cpp' ] tests = executable('tvgUnitTests', diff --git a/test/resources/Arial.ttf b/test/resources/Arial.ttf new file mode 100644 index 00000000..7ff88f22 Binary files /dev/null and b/test/resources/Arial.ttf differ diff --git a/test/resources/NanumGothicCoding.ttf b/test/resources/NanumGothicCoding.ttf new file mode 100644 index 00000000..d1cbe11b Binary files /dev/null and b/test/resources/NanumGothicCoding.ttf differ diff --git a/test/resources/test9.json b/test/resources/test9.json index 95c14168..16b078f9 100644 --- a/test/resources/test9.json +++ b/test/resources/test9.json @@ -1 +1 @@ -{"assets":[],"layers":[{"ddd":0,"ind":0,"ty":1,"nm":"品蓝色 纯色 1","ks":{"o":{"k":[{"i":{"x":[0.667],"y":[0.667]},"o":{"x":[0.167],"y":[0.167]},"n":["0p667_0p667_0p167_0p167"],"t":0,"s":[100],"e":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.537],"y":[0]},"n":["0p667_1_0p537_0"],"t":5,"s":[100],"e":[0]},{"t":17}]},"r":{"k":0},"p":{"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":5,"s":[400,320,0],"e":[408,274,0],"to":[1.33333337306976,-7.66666650772095,0],"ti":[-1.33333337306976,7.66666650772095,0]},{"t":17}]},"a":{"k":[400,300,0]},"s":{"k":[{"i":{"x":[0.518,0.518,0.667],"y":[1,1,0.667]},"o":{"x":[0.16,0.16,0.333],"y":[0.329,0.329,0.333]},"n":["0p518_1_0p16_0p329","0p518_1_0p16_0p329","0p667_0p667_0p333_0p333"],"t":5,"s":[0,0,100],"e":[160,160,100]},{"t":17}]}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"f","pt":{"k":{"i":[[0,0],[3.675,0],[0,0],[2.623,1.039],[10.49,18.686],[8.393,0],[0,0],[5.767,-5.706],[-0.526,-6.747],[8.391,-4.158],[2.101,0],[0,0],[0,-4.152],[0,0],[-4.196,0],[0,0],[-1.574,1.04],[-1.051,-0.52],[-31.47,0],[-9.441,41.527],[-2.097,6.748],[5.768,7.267]],"o":[[-7.342,-8.823],[0,0],[-12.065,0],[14.688,-23.358],[-5.772,-9.866],[0,0],[-3.671,-0.52],[-3.672,3.633],[4.198,46.715],[-1.572,-1.556],[0,0],[-4.198,0],[0,0],[0,4.155],[0,0],[2.097,0],[0.525,1.036],[0,0],[31.47,0],[2.098,-9.345],[3.671,-14.014],[0,0]],"v":[[521.158,276.64],[498.604,267.817],[454.021,267.817],[433.565,265.741],[435.663,188.92],[414.159,173.864],[413.112,173.864],[395.279,178.534],[390.561,194.626],[337.06,270.932],[331.816,268.856],[280.411,268.856],[272.544,276.642],[272.544,419.386],[280.411,427.172],[332.339,427.172],[338.111,425.096],[340.208,427.172],[464.514,426.652],[517.49,333.736],[523.785,308.82],[521.16,276.637]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 1"}],"sw":800,"sh":600,"sc":"#00b1ff","ip":0,"op":50,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":1,"nm":"品蓝色 纯色 3","ks":{"o":{"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":11,"s":[0],"e":[100]},{"t":15}]},"r":{"k":0},"p":{"k":[400,300,0]},"a":{"k":[400,300,0]},"s":{"k":[100,100,100]}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"a","pt":{"k":{"i":[[0,0],[3.675,0],[0,0],[2.623,1.039],[10.49,18.686],[8.393,0],[0,0],[5.767,-5.706],[-0.526,-6.747],[8.391,-4.158],[2.101,0],[0,0],[0,-4.152],[0,0],[-4.196,0],[0,0],[-1.574,1.04],[-1.051,-0.52],[-31.47,0],[-9.441,41.527],[-2.097,6.748],[5.768,7.267]],"o":[[-7.342,-8.823],[0,0],[-12.065,0],[14.688,-23.358],[-5.772,-9.866],[0,0],[-3.671,-0.52],[-3.672,3.633],[4.198,46.715],[-1.572,-1.556],[0,0],[-4.198,0],[0,0],[0,4.155],[0,0],[2.097,0],[0.525,1.036],[0,0],[31.47,0],[2.098,-9.345],[3.671,-14.014],[0,0]],"v":[[521.158,276.64],[498.604,267.817],[454.021,267.817],[433.565,265.741],[435.663,188.92],[414.159,173.864],[413.112,173.864],[395.279,178.534],[390.561,194.626],[337.06,270.932],[331.816,268.856],[280.411,268.856],[272.544,276.642],[272.544,419.386],[280.411,427.172],[332.339,427.172],[338.111,425.096],[340.208,427.172],[464.514,426.652],[517.49,333.736],[523.785,308.82],[521.16,276.637]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 3"},{"inv":false,"mode":"s","pt":{"k":{"i":[[0,0],[2.097,-9.861],[18.887,0],[6.816,0],[0,0],[-1.052,0.52],[5.769,62.291],[0.525,0],[-3.147,0],[0,0],[-2.098,-4.669],[12.067,-18.166],[-1.052,-2.596],[-21.503,0],[0,0],[-2.101,-2.597],[2.618,-8.822]],"o":[[-2.098,7.267],[-7.343,32.183],[-30.419,0],[0,0],[1.047,0],[2.624,-1.036],[0,-2.597],[0.525,-0.52],[0,0],[2.098,0],[8.392,15.571],[-4.199,6.23],[4.198,7.267],[0,0],[2.098,0],[3.671,2.597],[0,0]],"v":[[508.045,304.672],[501.75,330.626],[463.984,411.599],[339.679,412.119],[339.679,287.025],[342.303,286.505],[406.292,193.589],[406.292,189.956],[411.537,189.435],[413.634,189.435],[420.977,196.702],[418.353,259.51],[416.781,273.524],[452.971,283.903],[498.081,283.903],[507.524,286.5],[508.049,304.668]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 1"},{"inv":false,"mode":"s","pt":{"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[323.943,411.599],[287.753,411.599],[287.753,284.428],[323.943,284.428]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 2"}],"sw":800,"sh":600,"sc":"#00b1ff","ip":0,"op":50,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":1,"nm":"品蓝色 纯色 2","ks":{"o":{"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":11,"s":[0],"e":[27]},{"t":16}]},"r":{"k":0},"p":{"k":[400,300,0]},"a":{"k":[400,300,0]},"s":{"k":[100,100,100]}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"f","pt":{"k":{"i":[[0,0],[3.675,0],[0,0],[2.623,1.039],[10.49,18.686],[8.393,0],[0,0],[5.767,-5.706],[-0.526,-6.747],[8.391,-4.158],[2.101,0],[0,0],[0,-4.152],[0,0],[-4.196,0],[0,0],[-1.574,1.04],[-1.051,-0.52],[-31.47,0],[-9.441,41.527],[-2.097,6.748],[5.768,7.267]],"o":[[-7.342,-8.823],[0,0],[-12.065,0],[14.688,-23.358],[-5.772,-9.866],[0,0],[-3.671,-0.52],[-3.672,3.633],[4.198,46.715],[-1.572,-1.556],[0,0],[-4.198,0],[0,0],[0,4.155],[0,0],[2.097,0],[0.525,1.036],[0,0],[31.47,0],[2.098,-9.345],[3.671,-14.014],[0,0]],"v":[[521.158,276.64],[498.604,267.817],[454.021,267.817],[433.565,265.741],[435.663,188.92],[414.159,173.864],[413.112,173.864],[395.279,178.534],[390.561,194.626],[337.06,270.932],[331.816,268.856],[280.411,268.856],[272.544,276.642],[272.544,419.386],[280.411,427.172],[332.339,427.172],[338.111,425.096],[340.208,427.172],[464.514,426.652],[517.49,333.736],[523.785,308.82],[521.16,276.637]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 1"}],"sw":800,"sh":600,"sc":"#00b1ff","ip":0,"op":50,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":1,"nm":"灰色 纯色 1","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[400,300,0]},"a":{"k":[400,300,0]},"s":{"k":[100,100,100]}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"a","pt":{"k":{"i":[[0,0],[3.675,0],[0,0],[2.623,1.039],[10.49,18.686],[8.393,0],[0,0],[5.767,-5.706],[-0.526,-6.747],[8.391,-4.158],[2.101,0],[0,0],[0,-4.152],[0,0],[-4.196,0],[0,0],[-1.574,1.04],[-1.051,-0.52],[-31.47,0],[-9.441,41.527],[-2.097,6.748],[5.768,7.267]],"o":[[-7.342,-8.823],[0,0],[-12.065,0],[14.688,-23.358],[-5.772,-9.866],[0,0],[-3.671,-0.52],[-3.672,3.633],[4.198,46.715],[-1.572,-1.556],[0,0],[-4.198,0],[0,0],[0,4.155],[0,0],[2.097,0],[0.525,1.036],[0,0],[31.47,0],[2.098,-9.345],[3.671,-14.014],[0,0]],"v":[[521.158,276.64],[498.604,267.817],[454.021,267.817],[433.565,265.741],[435.663,188.92],[414.159,173.864],[413.112,173.864],[395.279,178.534],[390.561,194.626],[337.06,270.932],[331.816,268.856],[280.411,268.856],[272.544,276.642],[272.544,419.386],[280.411,427.172],[332.339,427.172],[338.111,425.096],[340.208,427.172],[464.514,426.652],[517.49,333.736],[523.785,308.82],[521.16,276.637]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 3"},{"inv":false,"mode":"s","pt":{"k":{"i":[[0,0],[2.097,-9.861],[18.887,0],[6.816,0],[0,0],[-1.052,0.52],[5.769,62.291],[0.525,0],[-3.147,0],[0,0],[-2.098,-4.669],[12.067,-18.166],[-1.052,-2.596],[-21.503,0],[0,0],[-2.101,-2.597],[2.618,-8.822]],"o":[[-2.098,7.267],[-7.343,32.183],[-30.419,0],[0,0],[1.047,0],[2.624,-1.036],[0,-2.597],[0.525,-0.52],[0,0],[2.098,0],[8.392,15.571],[-4.199,6.23],[4.198,7.267],[0,0],[2.098,0],[3.671,2.597],[0,0]],"v":[[508.045,304.672],[501.75,330.626],[463.984,411.599],[339.679,412.119],[339.679,287.025],[342.303,286.505],[406.292,193.589],[406.292,189.956],[411.537,189.435],[413.634,189.435],[420.977,196.702],[418.353,259.51],[416.781,273.524],[452.971,283.903],[498.081,283.903],[507.524,286.5],[508.049,304.668]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 1"},{"inv":false,"mode":"s","pt":{"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[323.943,411.599],[287.753,411.599],[287.753,284.428],[323.943,284.428]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 2"}],"sw":800,"sh":600,"sc":"#8c8c8c","ip":0,"op":37,"st":0,"bm":0,"sr":1}],"v":"4.5.4","ddd":0,"ip":0,"op":50,"fr":25,"w":800,"h":600} \ No newline at end of file +{"v":"5.4.2","fr":25,"ip":0,"op":75,"w":1080,"h":1080,"nm":"Submit_Loading","ddd":0,"assets":[],"fonts":{"list":[{"fName":"OmnesMedium","fFamily":"Omnes","fStyle":"Medium","ascent":69.1024780273438}]},"layers":[{"ddd":0,"ind":2,"ty":5,"nm":"START 3","parent":5,"sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":20,"s":[100],"e":[0]},{"t":27}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[-229,-101,0],"ix":2},"a":{"a":0,"k":[1.821,-23.131,0],"ix":1},"s":{"a":0,"k":[194.254,194.254,100],"ix":6}},"ao":0,"t":{"d":{"k":[{"s":{"s":71,"f":"OmnesMedium","t":"START","j":2,"tr":0,"lh":85.2,"ls":0,"fc":[1,1,1]},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":18,"op":75,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":5,"nm":"START 2","parent":5,"sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":19,"s":[100],"e":[0]},{"t":27}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[-229,-101,0],"ix":2},"a":{"a":0,"k":[1.821,-23.131,0],"ix":1},"s":{"a":0,"k":[194.254,194.254,100],"ix":6}},"ao":0,"t":{"d":{"k":[{"s":{"s":71,"f":"OmnesMedium","t":"START","j":2,"tr":0,"lh":85.2,"ls":0,"fc":[0.549,0.549,0.549]},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":8,"op":18,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":5,"nm":"START","parent":5,"sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":19,"s":[100],"e":[0]},{"t":27}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[-229,-101,0],"ix":2},"a":{"a":0,"k":[1.821,-23.131,0],"ix":1},"s":{"a":0,"k":[194.254,194.254,100],"ix":6}},"ao":0,"t":{"d":{"k":[{"s":{"s":71,"f":"OmnesMedium","t":"START","j":2,"tr":0,"lh":85.2,"ls":0,"fc":[1,1,1]},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":0,"op":8,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[540,540,0],"ix":2},"a":{"a":0,"k":[-229,-101,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":12,"s":[100,100,100],"e":[90,90,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":14,"s":[90,90,100],"e":[100,100,100]},{"t":16}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":1,"k":[{"i":{"x":[0.338,0.667],"y":[1,1]},"o":{"x":[0.669,0.333],"y":[0,0]},"n":["0p338_1_0p669_0","0p667_1_0p333_0"],"t":16,"s":[928,300],"e":[300,300]},{"t":45}],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":1,"k":[{"i":{"x":[0.168],"y":[1]},"o":{"x":[0.839],"y":[0]},"n":["0p168_1_0p839_0"],"t":16,"s":[160],"e":[180]},{"t":45}],"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"tm","s":{"a":0,"k":100,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.333],"y":[0]},"n":["0_1_0p333_0"],"t":46,"s":[0],"e":[100]},{"t":63}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[0.376470618154,0.772549079446,0.396078461292,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":15,"ix":5},"lc":2,"lj":1,"ml":4,"ml2":{"a":0,"k":4,"ix":8},"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.375670878092,0.772549019608,0.394347516228,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":7,"s":[100],"e":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":8,"s":[0],"e":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":18,"s":[0],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":19,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":43,"s":[100],"e":[0]},{"t":45}],"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-229,-101],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":4,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":75,"st":0,"bm":0},{"ddd":0,"ind":6,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":43,"s":[0],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":45,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":63,"s":[100],"e":[0]},{"t":70}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[540,540,0],"ix":2},"a":{"a":0,"k":[-229,-101,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[300,300],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":180,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"tm","s":{"a":0,"k":100,"ix":1},"e":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[0.756862745098,0.756862745098,0.756862745098,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":15,"ix":5},"lc":2,"lj":1,"ml":4,"ml2":{"a":0,"k":4,"ix":8},"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[-229,-101],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":4,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":28,"op":75,"st":0,"bm":0},{"ddd":0,"ind":7,"ty":1,"nm":"bg","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[540,540,0],"ix":2},"a":{"a":0,"k":[540,540,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"sw":1080,"sh":1080,"sc":"#ffffff","ip":0,"op":75,"st":0,"bm":0}],"markers":[],"chars":[{"ch":"S","size":71,"style":"Medium","w":55.4,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-2.216,-2.115],[-10.071,0],[0,11.984],[11.078,2.518],[0,7.15],[-8.157,0],[-3.424,-4.935],[0,3.726],[2.618,2.014],[8.56,0],[0,-11.078],[-10.071,-2.316],[0,-7.352],[9.064,0],[3.726,5.438],[0,-3.424]],"o":[[3.928,3.625],[15.207,0],[0,-12.589],[-9.064,-2.115],[0,-6.042],[7.553,0],[0.201,0.302],[0,-1.913],[-3.625,-2.921],[-13.898,0],[0,13.193],[8.661,2.014],[0,6.445],[-8.963,0],[-0.302,-0.403],[0,1.913]],"v":[[6.546,-5.438],[27.695,1.309],[52.167,-18.127],[30.414,-37.564],[15.005,-47.937],[28.5,-57.907],[45.923,-49.146],[50.757,-54.886],[46.829,-61.13],[28.4,-66.467],[4.935,-47.534],[25.479,-28.5],[41.794,-17.422],[27.594,-7.251],[7.956,-17.221],[3.223,-11.682]],"c":true},"ix":2},"nm":"S","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"S","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Omnes"},{"ch":"T","size":71,"style":"Medium","w":60.5,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-2.921,0],[0,0],[0,3.122],[0,0],[0,0],[0,2.82],[0,0],[3.122,0],[0,0],[0,-2.82],[0,0],[-3.122,0],[0,0]],"o":[[0,3.122],[0,0],[3.021,0],[0,0],[0,0],[3.122,0],[0,0],[0,-2.82],[0,0],[-3.122,0],[0,0],[0,2.82],[0,0],[0,0]],"v":[[24.673,-4.33],[29.105,0.403],[30.515,0.403],[35.147,-4.33],[35.147,-55.893],[52.972,-55.893],[57.706,-60.324],[57.706,-60.828],[52.972,-65.158],[6.848,-65.158],[2.014,-60.828],[2.014,-60.324],[6.848,-55.893],[24.673,-55.893]],"c":true},"ix":2},"nm":"T","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"T","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Omnes"},{"ch":"A","size":71,"style":"Medium","w":63,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-3.021,0],[-1.309,3.625],[0,0],[0,0],[0,0],[-2.316,0],[0.302,0.806],[0,0],[4.834,0],[0.806,-2.115],[0,0]],"o":[[2.216,0],[0,0],[0,0],[0,0],[1.41,3.726],[3.122,0],[0,0],[-0.806,-2.115],[-4.733,0],[0,0],[-0.302,0.906]],"v":[[6.949,0.504],[12.689,-4.23],[18.43,-19.135],[44.513,-19.135],[50.253,-4.33],[56.396,0.504],[62.137,-2.618],[38.773,-62.439],[31.622,-65.762],[24.472,-62.439],[1.309,-2.618]],"c":true},"ix":2},"nm":"A","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[20.947,-27.493],[31.421,-55.087],[41.895,-27.493]],"c":true},"ix":2},"nm":"A","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"A","np":5,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Omnes"},{"ch":"R","size":71,"style":"Medium","w":58.9,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-2.82,0],[0,0],[0,2.82],[0,0],[0,0],[0,0],[-2.719,0],[0.504,0.604],[0,0],[-1.309,0.302],[0,9.769],[15.912,0],[0,0],[0,-3.525],[0,0]],"o":[[0,0],[3.021,0],[0,0],[0,0],[0,0],[2.216,2.921],[4.33,0],[0,0],[1.41,-0.101],[9.97,-2.115],[0,-12.891],[0,0],[-3.323,0],[0,0],[0,3.424]],"v":[[11.279,0.403],[12.689,0.403],[17.221,-4.33],[17.221,-25.479],[24.371,-25.479],[42.197,-3.625],[48.944,0.403],[54.987,-3.827],[35.953,-26.486],[40.082,-27.09],[55.389,-45.621],[31.018,-65.158],[12.488,-65.158],[6.949,-59.317],[6.949,-4.935]],"c":true},"ix":2},"nm":"R","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,-7.553],[9.567,0]],"o":[[0,0],[0,0],[9.567,0],[0,7.05],[0,0]],"v":[[17.12,-33.636],[17.12,-56.598],[30.515,-56.598],[44.916,-45.117],[30.817,-33.636]],"c":true},"ix":2},"nm":"R","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"R","np":5,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Omnes"}]} \ No newline at end of file diff --git a/test/testText.cpp b/test/testText.cpp new file mode 100644 index 00000000..0a7e4dca --- /dev/null +++ b/test/testText.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved. + + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include "config.h" +#include "catch.hpp" + +using namespace tvg; +using namespace std; + +#ifdef THORVG_TTF_LOADER_SUPPORT + +TEST_CASE("Text Creation", "[tvgText]") +{ + auto text = Text::gen(); + REQUIRE(text); + + REQUIRE(text->identifier() == Text::identifier()); + REQUIRE(text->identifier() != Shape::identifier()); + REQUIRE(text->identifier() != Scene::identifier()); + REQUIRE(text->identifier() != Picture::identifier()); +} + +TEST_CASE("Load TTF Data", "[tvgText]") +{ + Initializer::init(0); + + auto text = Text::gen(); + REQUIRE(text); + + REQUIRE(Text::unload(TEST_DIR"/invalid.ttf") == tvg::Result::InsufficientCondition); + + REQUIRE(Text::load(TEST_DIR"/Arial.ttf") == tvg::Result::Success); + REQUIRE(Text::load(TEST_DIR"/invalid.ttf") == tvg::Result::InvalidArguments); + REQUIRE(Text::unload(TEST_DIR"/Arial.ttf") == tvg::Result::Success); + REQUIRE(Text::load("") == tvg::Result::InvalidArguments); + REQUIRE(Text::load(TEST_DIR"/NanumGothicCoding.ttf") == tvg::Result::Success); + + Initializer::term(); +} + +TEST_CASE("Text Font", "[tvgText]") +{ + Initializer::init(0); + + auto text = Text::gen(); + REQUIRE(text); + + REQUIRE(Text::load(TEST_DIR"/Arial.ttf") == tvg::Result::Success); + + REQUIRE(text->font("Arial", 80) == tvg::Result::Success); + REQUIRE(text->font("Arial", 1) == tvg::Result::Success); + REQUIRE(text->font("Arial", 50) == tvg::Result::Success); + REQUIRE(text->font("InvalidFont", 80) == tvg::Result::InsufficientCondition); + + Initializer::term(); +} + + +TEST_CASE("Text Basic", "[tvgText]") +{ + Initializer::init(0); + + auto canvas = SwCanvas::gen(); + + auto text = Text::gen(); + REQUIRE(text); + + REQUIRE(Text::load(TEST_DIR"/Arial.ttf") == tvg::Result::Success); + REQUIRE(text->font("Arial", 80) == tvg::Result::Success); + + REQUIRE(text->text("THORVG Text") == tvg::Result::Success); + REQUIRE(text->text("ABCDEFGHIJIKLMOPQRSTUVWXYZ") == tvg::Result::Success); + REQUIRE(text->text("") == tvg::Result::Success); + REQUIRE(text->text(nullptr) == tvg::Result::Success); + + REQUIRE(text->fill(255, 255, 255) == tvg::Result::Success); + + REQUIRE(canvas->push(std::move(text)) == Result::Success); + + Initializer::term(); +} + +#endif