Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

CustomFontCollection.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 java.util.List;
  20. /**
  21. * Sets up a set of custom (embedded) fonts
  22. */
  23. public class CustomFontCollection implements FontCollection {
  24. private FontResolver fontResolver;
  25. private final List<EmbedFontInfo> embedFontInfoList;
  26. /**
  27. * Main constructor.
  28. * @param fontResolver a font resolver
  29. * @param customFonts the list of custom fonts
  30. */
  31. public CustomFontCollection(FontResolver fontResolver,
  32. List<EmbedFontInfo> customFonts) {
  33. this.fontResolver = fontResolver;
  34. if (this.fontResolver == null) {
  35. //Ensure that we have minimal font resolution capabilities
  36. this.fontResolver = FontManager.createMinimalFontResolver();
  37. }
  38. this.embedFontInfoList = customFonts;
  39. }
  40. /** {@inheritDoc} */
  41. public int setup(int num, FontInfo fontInfo) {
  42. if (embedFontInfoList == null) {
  43. return num; //No fonts to process
  44. }
  45. String internalName = null;
  46. //FontReader reader = null;
  47. for (int i = 0; i < embedFontInfoList.size(); i++) {
  48. EmbedFontInfo embedFontInfo = embedFontInfoList.get(i);
  49. //String metricsFile = configFontInfo.getMetricsFile();
  50. internalName = "F" + num;
  51. num++;
  52. /*
  53. reader = new FontReader(metricsFile);
  54. reader.useKerning(configFontInfo.getKerning());
  55. reader.setFontEmbedPath(configFontInfo.getEmbedFile());
  56. fontInfo.addMetrics(internalName, reader.getFont());
  57. */
  58. LazyFont font = new LazyFont(embedFontInfo, this.fontResolver);
  59. fontInfo.addMetrics(internalName, font);
  60. List<FontTriplet> triplets = embedFontInfo.getFontTriplets();
  61. for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) {
  62. FontTriplet triplet = triplets.get(tripletIndex);
  63. fontInfo.addFontProperties(internalName, triplet);
  64. }
  65. }
  66. return num;
  67. }
  68. }