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.

AFPFont.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.afp.fonts;
  19. import java.util.HashSet;
  20. import java.util.Map;
  21. import java.util.Set;
  22. import org.apache.fop.fonts.FontType;
  23. import org.apache.fop.fonts.Typeface;
  24. /**
  25. * All implementations of AFP fonts should extend this base class,
  26. * the object implements the FontMetrics information.
  27. * <p/>
  28. */
  29. public abstract class AFPFont extends Typeface {
  30. /** The font name */
  31. protected final String name;
  32. private final boolean embeddable;
  33. /**
  34. * Constructor for the base font requires the name.
  35. * @param name the name of the font
  36. * @param embeddable whether this font is to be embedded
  37. */
  38. public AFPFont(String name, boolean embeddable) {
  39. this.name = name;
  40. this.embeddable = embeddable;
  41. }
  42. /** {@inheritDoc} */
  43. public String getFontName() {
  44. return this.name;
  45. }
  46. /** {@inheritDoc} */
  47. public String getEmbedFontName() {
  48. return this.name;
  49. }
  50. /** {@inheritDoc} */
  51. public String getFullName() {
  52. return getFontName();
  53. }
  54. /** {@inheritDoc} */
  55. public Set<String> getFamilyNames() {
  56. Set<String> s = new HashSet<String>();
  57. s.add(this.name);
  58. return s;
  59. }
  60. /**
  61. * Returns the type of the font.
  62. * @return the font type
  63. */
  64. public FontType getFontType() {
  65. return FontType.OTHER;
  66. }
  67. /**
  68. * Indicates if the font has kerning information.
  69. * @return True, if kerning is available.
  70. */
  71. public boolean hasKerningInfo() {
  72. return false;
  73. }
  74. /**
  75. * Returns the kerning map for the font.
  76. * @return the kerning map
  77. */
  78. public Map<Integer, Map<Integer, Integer>> getKerningInfo() {
  79. return null;
  80. }
  81. /**
  82. * Returns the character set for a given size
  83. * @param size the font size
  84. * @return the character set object
  85. */
  86. public abstract CharacterSet getCharacterSet(int size);
  87. /**
  88. * Indicates if this font may be embedded.
  89. * @return True, if embedding is possible/permitted
  90. */
  91. public boolean isEmbeddable() {
  92. return this.embeddable;
  93. }
  94. /**
  95. * Maps mapped code points to Unicode code points.
  96. * @param character the mapped code point
  97. * @return the corresponding Unicode code point
  98. */
  99. protected static final char toUnicodeCodepoint(int character) {
  100. //AFP fonts use Unicode directly as their mapped code points, so we can simply cast to char
  101. return (char)character;
  102. }
  103. /** {@inheritDoc} */
  104. public String toString() {
  105. return "name=" + name;
  106. }
  107. }