|
| 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 | +package org.apache.fontbox.ttf; |
| 18 | + |
| 19 | +/** |
| 20 | + * To improve performance of {@code FileSystemFontProvider.scanFonts(...)}, |
| 21 | + * this class is used both as a marker (to skip unused data) and as a storage for collected data. |
| 22 | + * <p> |
| 23 | + * Tables it needs:<ul> |
| 24 | + * <li>NamingTable.TAG |
| 25 | + * <li>HeaderTable.TAG |
| 26 | + * <li>OS2WindowsMetricsTable.TAG |
| 27 | + * <li>CFFTable.TAG (for OTF) |
| 28 | + * <li>"gcid" (for non-OTF) |
| 29 | + * </ul> |
| 30 | + * |
| 31 | + * @author Mykola Bohdiuk |
| 32 | + */ |
| 33 | +public final class FontHeaders |
| 34 | +{ |
| 35 | + static final int BYTES_GCID = 142; |
| 36 | + |
| 37 | + private String error; |
| 38 | + private String name; |
| 39 | + private Integer headerMacStyle; |
| 40 | + private OS2WindowsMetricsTable os2Windows; |
| 41 | + private String fontFamily; |
| 42 | + private String fontSubFamily; |
| 43 | + private byte[] nonOtfGcid142; |
| 44 | + // |
| 45 | + private boolean isOTFAndPostScript; |
| 46 | + private String otfRegistry; |
| 47 | + private String otfOrdering; |
| 48 | + private int otfSupplement; |
| 49 | + |
| 50 | + public String getError() |
| 51 | + { |
| 52 | + return error; |
| 53 | + } |
| 54 | + |
| 55 | + public String getName() |
| 56 | + { |
| 57 | + return name; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * null == no HeaderTable, {@code ttf.getHeader().getMacStyle()} |
| 62 | + */ |
| 63 | + public Integer getHeaderMacStyle() |
| 64 | + { |
| 65 | + return headerMacStyle; |
| 66 | + } |
| 67 | + |
| 68 | + public OS2WindowsMetricsTable getOS2Windows() |
| 69 | + { |
| 70 | + return os2Windows; |
| 71 | + } |
| 72 | + |
| 73 | + // only when LOGGER(FileSystemFontProvider).isTraceEnabled() tracing: FontFamily, FontSubfamily |
| 74 | + public String getFontFamily() |
| 75 | + { |
| 76 | + return fontFamily; |
| 77 | + } |
| 78 | + |
| 79 | + public String getFontSubFamily() |
| 80 | + { |
| 81 | + return fontSubFamily; |
| 82 | + } |
| 83 | + |
| 84 | + public boolean isOpenTypePostScript() |
| 85 | + { |
| 86 | + return isOTFAndPostScript; |
| 87 | + } |
| 88 | + |
| 89 | + public byte[] getNonOtfTableGCID142() |
| 90 | + { |
| 91 | + return nonOtfGcid142; |
| 92 | + } |
| 93 | + |
| 94 | + public String getOtfRegistry() |
| 95 | + { |
| 96 | + return otfRegistry; |
| 97 | + } |
| 98 | + |
| 99 | + public String getOtfOrdering() |
| 100 | + { |
| 101 | + return otfOrdering; |
| 102 | + } |
| 103 | + |
| 104 | + public int getOtfSupplement() |
| 105 | + { |
| 106 | + return otfSupplement; |
| 107 | + } |
| 108 | + |
| 109 | + void setError(String exception) |
| 110 | + { |
| 111 | + this.error = exception; |
| 112 | + } |
| 113 | + |
| 114 | + void setName(String name) |
| 115 | + { |
| 116 | + this.name = name; |
| 117 | + } |
| 118 | + |
| 119 | + void setHeaderMacStyle(Integer headerMacStyle) |
| 120 | + { |
| 121 | + this.headerMacStyle = headerMacStyle; |
| 122 | + } |
| 123 | + |
| 124 | + void setOs2Windows(OS2WindowsMetricsTable os2Windows) |
| 125 | + { |
| 126 | + this.os2Windows = os2Windows; |
| 127 | + } |
| 128 | + |
| 129 | + void setFontFamily(String fontFamily, String fontSubFamily) |
| 130 | + { |
| 131 | + this.fontFamily = fontFamily; |
| 132 | + this.fontSubFamily = fontSubFamily; |
| 133 | + } |
| 134 | + |
| 135 | + void setNonOtfGcid142(byte[] nonOtfGcid142) |
| 136 | + { |
| 137 | + this.nonOtfGcid142 = nonOtfGcid142; |
| 138 | + } |
| 139 | + |
| 140 | + void setIsOTFAndPostScript(boolean isOTFAndPostScript) |
| 141 | + { |
| 142 | + this.isOTFAndPostScript = isOTFAndPostScript; |
| 143 | + } |
| 144 | + |
| 145 | + // public because CFFParser is in a different package |
| 146 | + public void setOtfROS(String otfRegistry, String otfOrdering, int otfSupplement) |
| 147 | + { |
| 148 | + this.otfRegistry = otfRegistry; |
| 149 | + this.otfOrdering = otfOrdering; |
| 150 | + this.otfSupplement = otfSupplement; |
| 151 | + } |
| 152 | +} |
0 commit comments