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.

Typeface.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /**
  20. * Base class for font classes
  21. */
  22. public abstract class Typeface implements FontMetrics {
  23. /**
  24. * Used to identify whether a font has been used (a character map operation is used as
  25. * the trigger). This could just as well be a boolean but is a long out of statistical interest.
  26. */
  27. private long charMapOps = 0;
  28. /**
  29. * Get the encoding of the font.
  30. * @return the encoding
  31. */
  32. public abstract String getEncodingName();
  33. /**
  34. * Map a Unicode character to a code point in the font.
  35. * @param c character to map
  36. * @return the mapped character
  37. */
  38. public abstract char mapChar(char c);
  39. /**
  40. * Used for keeping track of character mapping operations in order to determine if a font
  41. * was used at all or not.
  42. */
  43. protected void notifyMapOperation() {
  44. this.charMapOps++;
  45. }
  46. /**
  47. * Indicates whether this font had to do any character mapping operations. If that was
  48. * not the case, it's an indication that the font has never actually been used.
  49. * @return true if the font had to do any character mapping operations
  50. */
  51. public boolean hadMappingOperations() {
  52. return (this.charMapOps > 0);
  53. }
  54. /**
  55. * Determines whether this font contains a particular character/glyph.
  56. * @param c character to check
  57. * @return True if the character is supported, Falso otherwise
  58. */
  59. public abstract boolean hasChar(char c);
  60. /**
  61. * Determines whether the font is a multibyte font.
  62. * @return True if it is multibyte
  63. */
  64. public boolean isMultiByte() {
  65. return false;
  66. }
  67. /** {@inheritDoc} */
  68. public int getMaxAscent(int size) {
  69. return getAscender(size);
  70. }
  71. }