Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

AFPFontCollection.java 3.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.Iterator;
  20. import java.util.List;
  21. import org.apache.fop.afp.AFPEventProducer;
  22. import org.apache.fop.events.EventBroadcaster;
  23. import org.apache.fop.fonts.Font;
  24. import org.apache.fop.fonts.FontCollection;
  25. import org.apache.fop.fonts.FontInfo;
  26. import org.apache.fop.fonts.FontTriplet;
  27. /**
  28. * A base collection of AFP fonts
  29. */
  30. public class AFPFontCollection implements FontCollection {
  31. private final EventBroadcaster eventBroadcaster;
  32. private final List/*<AFPFontInfo>*/ fontInfoList;
  33. /**
  34. * Main constructor
  35. *
  36. * @param eventBroadcaster the event broadcaster
  37. * @param fontInfoList the font info list
  38. */
  39. public AFPFontCollection(EventBroadcaster eventBroadcaster,
  40. List/*<AFPFontInfo>*/ fontInfoList) {
  41. this.eventBroadcaster = eventBroadcaster;
  42. this.fontInfoList = fontInfoList;
  43. }
  44. /** {@inheritDoc} */
  45. public int setup(int start, FontInfo fontInfo) {
  46. int num = 1;
  47. AFPEventProducer eventProducer = AFPEventProducer.Provider.get(eventBroadcaster);
  48. if (fontInfoList != null && fontInfoList.size() > 0) {
  49. for (Iterator it = fontInfoList.iterator(); it.hasNext();) {
  50. AFPFontInfo afpFontInfo = (AFPFontInfo)it.next();
  51. AFPFont afpFont = afpFontInfo.getAFPFont();
  52. List/*<FontTriplet>*/ tripletList = afpFontInfo.getFontTriplets();
  53. for (Iterator it2 = tripletList.iterator(); it2.hasNext();) {
  54. FontTriplet triplet = (FontTriplet)it2.next();
  55. fontInfo.addFontProperties("F" + num,
  56. triplet.getName(), triplet.getStyle(), triplet.getWeight());
  57. fontInfo.addMetrics("F" + num, afpFont);
  58. num++;
  59. }
  60. }
  61. if (fontInfo.fontLookup("any", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL) == null) {
  62. eventProducer.warnMissingDefaultFont(this, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
  63. }
  64. if (fontInfo.fontLookup("any", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL) == null) {
  65. eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
  66. }
  67. if (fontInfo.fontLookup("any", Font.STYLE_NORMAL, Font.WEIGHT_BOLD) == null) {
  68. eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
  69. }
  70. if (fontInfo.fontLookup("any", Font.STYLE_ITALIC, Font.WEIGHT_BOLD) == null) {
  71. eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
  72. }
  73. } else {
  74. eventProducer.warnDefaultFontSetup(this);
  75. // Go with a default base 12 configuration for AFP environments
  76. FontCollection base12FontCollection = new AFPBase12FontCollection();
  77. num = base12FontCollection.setup(num, fontInfo);
  78. }
  79. return num;
  80. }
  81. }