1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* $Id$ */ 19 package org.apache.fop.render.pcl.fonts; 20 21 import java.io.ByteArrayOutputStream; 22 import java.io.File; 23 import java.net.URI; 24 import java.util.HashMap; 25 26 import org.junit.Assert; 27 import org.junit.Test; 28 29 import org.apache.fop.apps.FOUserAgent; 30 import org.apache.fop.apps.FopFactory; 31 import org.apache.fop.fonts.CMapSegment; 32 import org.apache.fop.fonts.EmbeddingMode; 33 import org.apache.fop.fonts.FontType; 34 import org.apache.fop.fonts.MultiByteFont; 35 import org.apache.fop.render.java2d.CustomFontMetricsMapper; 36 37 public class PCLSoftFontManagerTestCase { 38 @Test testSplitCompositeGlyphs()39 public void testSplitCompositeGlyphs() throws Exception { 40 FOUserAgent ua = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent(); 41 PCLSoftFontManager pclSoftFontManager = new PCLSoftFontManager(new HashMap()); 42 MultiByteFont mbf = new MultiByteFont(ua.getResourceResolver(), EmbeddingMode.SUBSET); 43 mbf.setEmbedURI(new URI("test/resources/fonts/ttf/DejaVuLGCSerif.ttf")); 44 mbf.setFontType(FontType.TRUETYPE); 45 CMapSegment cMapSegment1 = new CMapSegment('a', 'a', 1); 46 CMapSegment cMapSegment2 = new CMapSegment('\u00E0', '\u00E0', 2); 47 mbf.setCMap(new CMapSegment[] {cMapSegment1, cMapSegment2}); 48 mbf.mapChar('a'); 49 mbf.mapChar('\u00E0'); 50 CustomFontMetricsMapper font = new CustomFontMetricsMapper(mbf); 51 ByteArrayOutputStream bos = pclSoftFontManager.makeSoftFont(font, ""); 52 String[] fontStrings = bos.toString().split("DejaVu changes are in public domain"); 53 Assert.assertEquals(fontStrings.length, 3); 54 } 55 } 56