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.

EmbedFontInfoTestCase.java 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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;
  19. import java.net.URI;
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. import org.junit.Before;
  23. import org.junit.Test;
  24. import static org.junit.Assert.assertEquals;
  25. import static org.junit.Assert.assertFalse;
  26. import static org.junit.Assert.assertTrue;
  27. /**
  28. * Testcase for {@link EmbedFontInfo}.
  29. */
  30. public class EmbedFontInfoTestCase {
  31. public EmbedFontInfoTestCase() { }
  32. private EmbedFontInfo sut;
  33. private final URI metricsURI = URI.create("test/resources/fonts/ttf/glb12.ttf.xml");
  34. private final URI embedURI = URI.create("test/resources/fonts/ttf/glb12.ttf");
  35. private final boolean kerning = false;
  36. private final boolean useAdvanced = false;
  37. private final String subFontName = "Gladiator Bold";
  38. private final EncodingMode encMode = EncodingMode.CID;
  39. private final EmbeddingMode embedMode = EmbeddingMode.AUTO;
  40. private final FontTriplet triplet = new FontTriplet(subFontName, "bold", Font.WEIGHT_BOLD);
  41. @Before
  42. public void setUp() {
  43. List<FontTriplet> triplets = new ArrayList<FontTriplet>();
  44. triplets.add(triplet);
  45. FontUris fontUris = new FontUris(embedURI, metricsURI);
  46. sut = new EmbedFontInfo(fontUris, kerning, useAdvanced, triplets, subFontName, encMode,
  47. embedMode, false, false);
  48. }
  49. @Test
  50. public void testImmutableGetters() {
  51. assertEquals(metricsURI, sut.getMetricsURI());
  52. assertEquals(embedURI, sut.getEmbedURI());
  53. assertEquals(kerning, sut.getKerning());
  54. assertEquals(subFontName, sut.getSubFontName());
  55. assertEquals(encMode, sut.getEncodingMode());
  56. assertEquals(1, sut.getFontTriplets().size());
  57. assertEquals(triplet, sut.getFontTriplets().get(0));
  58. assertTrue(sut.isEmbedded());
  59. }
  60. @Test
  61. public void testMutableGetterSetters() {
  62. String psName = "Test Name";
  63. sut.setPostScriptName(psName);
  64. assertEquals(psName, sut.getPostScriptName());
  65. sut.setEmbedded(false);
  66. assertFalse(sut.isEmbedded());
  67. }
  68. @Test
  69. public void testQuirkyBoundaryCasesIsEmbedded() {
  70. FontUris fontUris = new FontUris(null, metricsURI);
  71. sut = new EmbedFontInfo(fontUris, kerning, useAdvanced, sut.getFontTriplets(), subFontName);
  72. sut.setEmbedded(true);
  73. assertFalse(sut.isEmbedded());
  74. sut.setEmbedded(false);
  75. assertFalse(sut.isEmbedded());
  76. }
  77. }