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.

CIDFontType.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 org.apache.avalon.framework.ValuedEnum;
  20. /**
  21. * This class enumerates all supported CID font types.
  22. */
  23. public class CIDFontType extends ValuedEnum {
  24. /**
  25. * CID Font Type 0 (based on Type 1 format)
  26. */
  27. public static final CIDFontType CIDTYPE0 = new CIDFontType("CIDFontType0", 0);
  28. /**
  29. * CID Font Type 2 (based on TrueType format)
  30. */
  31. public static final CIDFontType CIDTYPE2 = new CIDFontType("CIDFontType2", 2);
  32. /**
  33. * Construct a CID font type.
  34. * @param name a type name
  35. * @param value a type value
  36. * @see org.apache.avalon.framework.Enum#Enum(String)
  37. */
  38. protected CIDFontType(String name, int value) {
  39. super(name, value);
  40. }
  41. /**
  42. * Returns the CIDFontType by name.
  43. * @param name Name of the CID font type to look up
  44. * @return FontType the CID font type
  45. */
  46. public static CIDFontType byName(String name) {
  47. if (name.equalsIgnoreCase(CIDFontType.CIDTYPE0.getName())) {
  48. return CIDFontType.CIDTYPE0;
  49. } else if (name.equalsIgnoreCase(CIDFontType.CIDTYPE2.getName())) {
  50. return CIDFontType.CIDTYPE2;
  51. } else {
  52. throw new IllegalArgumentException("Invalid CID font type: " + name);
  53. }
  54. }
  55. /**
  56. * Returns the CID FontType by value.
  57. * @param value Value of the CID font type to look up
  58. * @return FontType the CID font type
  59. */
  60. public static CIDFontType byValue(int value) {
  61. if (value == CIDFontType.CIDTYPE0.getValue()) {
  62. return CIDFontType.CIDTYPE0;
  63. } else if (value == CIDFontType.CIDTYPE2.getValue()) {
  64. return CIDFontType.CIDTYPE2;
  65. } else {
  66. throw new IllegalArgumentException("Invalid CID font type: " + value);
  67. }
  68. }
  69. }