You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Type1FontLoaderTestCase.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. /* $Id$ */
  18. package org.apache.fop.fonts.type1;
  19. import java.awt.Rectangle;
  20. import java.io.File;
  21. import java.io.FileInputStream;
  22. import java.io.FileOutputStream;
  23. import java.io.IOException;
  24. import org.junit.Assert;
  25. import org.junit.Test;
  26. import org.apache.commons.io.IOUtils;
  27. import org.apache.fop.apps.io.InternalResourceResolver;
  28. import org.apache.fop.apps.io.ResourceResolverFactory;
  29. import org.apache.fop.fonts.CustomFont;
  30. import org.apache.fop.fonts.EmbeddingMode;
  31. import org.apache.fop.fonts.EncodingMode;
  32. import org.apache.fop.fonts.FontLoader;
  33. import org.apache.fop.fonts.FontUris;
  34. public class Type1FontLoaderTestCase {
  35. @Test
  36. public void testBoundingBox() throws IOException {
  37. File pfb = new File("test/resources/fonts/type1/c0419bt_.pfb");
  38. File pfbNoAFM = File.createTempFile("fop", "pfb");
  39. File pfm = File.createTempFile("fop", "pfm");
  40. try {
  41. IOUtils.copy(new FileInputStream(pfb), new FileOutputStream(pfbNoAFM));
  42. FileOutputStream fos = new FileOutputStream(pfm);
  43. fos.write(new byte[512]);
  44. fos.close();
  45. FontUris fontUris = new FontUris(pfbNoAFM.toURI(), null, null, pfm.toURI());
  46. InternalResourceResolver resourceResolver =
  47. ResourceResolverFactory.createDefaultInternalResourceResolver(new File(".").toURI());
  48. CustomFont x = FontLoader.loadFont(fontUris, null, true, EmbeddingMode.AUTO, EncodingMode.AUTO, true, true,
  49. resourceResolver, false, false, true);
  50. Assert.assertEquals(x.getBoundingBox(0, 12).getBounds(), new Rectangle(-240, -60, 0, 60));
  51. } finally {
  52. pfbNoAFM.delete();
  53. pfm.delete();
  54. }
  55. }
  56. }