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.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced, triplets, embedURI, subFontName,
  46. encMode, embedMode);
  47. }
  48. @Test
  49. public void testImmutableGetters() {
  50. assertEquals(metricsURI, sut.getMetricsURI());
  51. assertEquals(embedURI, sut.getEmbedURI());
  52. assertEquals(kerning, sut.getKerning());
  53. assertEquals(subFontName, sut.getSubFontName());
  54. assertEquals(encMode, sut.getEncodingMode());
  55. assertEquals(1, sut.getFontTriplets().size());
  56. assertEquals(triplet, sut.getFontTriplets().get(0));
  57. assertTrue(sut.isEmbedded());
  58. }
  59. @Test
  60. public void testMutableGetterSetters() {
  61. String psName = "Test Name";
  62. sut.setPostScriptName(psName);
  63. assertEquals(psName, sut.getPostScriptName());
  64. sut.setEmbedded(false);
  65. assertFalse(sut.isEmbedded());
  66. }
  67. @Test
  68. public void testQuirkyBoundaryCasesIsEmbedded() {
  69. sut = new EmbedFontInfo(metricsURI, kerning, useAdvanced, sut.getFontTriplets(), null,
  70. subFontName, encMode, embedMode);
  71. sut.setEmbedded(true);
  72. assertFalse(sut.isEmbedded());
  73. sut.setEmbedded(false);
  74. assertFalse(sut.isEmbedded());
  75. }
  76. }