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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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", 1);
  32. /**
  33. * @see org.apache.avalon.framework.Enum#Enum(String)
  34. */
  35. protected CIDFontType(String name, int value) {
  36. super(name, value);
  37. }
  38. /**
  39. * Returns the CIDFontType by name.
  40. * @param name Name of the CID font type to look up
  41. * @return FontType the CID font type
  42. */
  43. public static CIDFontType byName(String name) {
  44. if (name.equalsIgnoreCase(CIDFontType.CIDTYPE0.getName())) {
  45. return CIDFontType.CIDTYPE0;
  46. } else if (name.equalsIgnoreCase(CIDFontType.CIDTYPE2.getName())) {
  47. return CIDFontType.CIDTYPE2;
  48. } else {
  49. throw new IllegalArgumentException("Invalid CID font type: " + name);
  50. }
  51. }
  52. /**
  53. * Returns the CID FontType by value.
  54. * @param value Value of the CID font type to look up
  55. * @return FontType the CID font type
  56. */
  57. public static CIDFontType byValue(int value) {
  58. if (value == CIDFontType.CIDTYPE0.getValue()) {
  59. return CIDFontType.CIDTYPE0;
  60. } else if (value == CIDFontType.CIDTYPE2.getValue()) {
  61. return CIDFontType.CIDTYPE2;
  62. } else {
  63. throw new IllegalArgumentException("Invalid CID font type: " + value);
  64. }
  65. }
  66. }