|
| 1 | +/* |
| 2 | +
|
| 3 | + Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | + contributor license agreements. See the NOTICE file distributed with |
| 5 | + this work for additional information regarding copyright ownership. |
| 6 | + The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 | + (the "License"); you may not use this file except in compliance with |
| 8 | + the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, software |
| 13 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + See the License for the specific language governing permissions and |
| 16 | + limitations under the License. |
| 17 | +
|
| 18 | + */ |
| 19 | +package org.apache.batik.svggen.font; |
| 20 | + |
| 21 | +import org.junit.Assert; |
| 22 | +import org.junit.Test; |
| 23 | + |
| 24 | +import java.io.ByteArrayOutputStream; |
| 25 | +import java.io.PrintStream; |
| 26 | + |
| 27 | +public class SVGFontTestCase { |
| 28 | + @Test |
| 29 | + public void testWriteFontAsSVGFragment() throws Exception { |
| 30 | + Font font = new Font(); |
| 31 | + font.read("samples/tests/resources/ttf/glb12.ttf"); |
| 32 | + ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
| 33 | + SVGFont.writeFontAsSVGFragment(new PrintStream(bos), font, "abc&", 0,0, false, false); |
| 34 | + Assert.assertEquals("<font id=\"abc&\" horiz-adv-x=\"1024\" ><font-face\n" + |
| 35 | + " font-family=\"Gladiator\"\n" + |
| 36 | + " units-per-em=\"2048\"\n" + |
| 37 | + " panose-1=\"2 0 8 3 0 0 0 0 0 0\"\n" + |
| 38 | + " ascent=\"1567\"\n" + |
| 39 | + " descent=\"-481\"\n" + |
| 40 | + " alphabetic=\"0\" />\n" + |
| 41 | + "<missing-glyph horiz-adv-x=\"886\" d=\"M68 0V1365H750V0H68ZM136 68H682V1297H136V68Z\" />\n" + |
| 42 | + "</font>\n", bos.toString()); |
| 43 | + } |
| 44 | +} |
0 commit comments