"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "debugger/src/main/java/org/apache/pdfbox/debugger/fontencodingpane/SimpleFont.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

SimpleFont.java  (pdfbox-2.0.23-src):SimpleFont.java  (pdfbox-2.0.24-src)
skipping to change at line 19 skipping to change at line 19
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.pdfbox.debugger.fontencodingpane; package org.apache.pdfbox.debugger.fontencodingpane;
import org.apache.pdfbox.pdmodel.font.PDSimpleFont; import java.awt.geom.GeneralPath;
import org.apache.pdfbox.pdmodel.font.PDVectorFont;
import javax.swing.JPanel;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.swing.JPanel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.pdmodel.font.PDSimpleFont;
import org.apache.pdfbox.pdmodel.font.PDVectorFont;
/** /**
* @author Khyrul Bashar * @author Khyrul Bashar
* A class that shows the glyph table along with unicode characters for SimpleFo nt. * A class that shows the glyph table along with unicode characters for SimpleFo nt.
*/ */
class SimpleFont extends FontPane class SimpleFont extends FontPane
{ {
private static final Log LOG = LogFactory.getLog(SimpleFont.class);
public static final String NO_GLYPH = "None"; public static final String NO_GLYPH = "None";
private final FontEncodingView view; private final FontEncodingView view;
private int totalAvailableGlyph = 0; private int totalAvailableGlyph = 0;
/** /**
* Constructor. * Constructor.
* @param font PDSimpleFont instance. * @param font PDSimpleFont instance, but not a type 3 font.
* @throws IOException If fails to parse unicode characters. * @throws IOException If fails to parse unicode characters.
*/ */
SimpleFont(PDSimpleFont font) throws IOException SimpleFont(PDSimpleFont font) throws IOException
{ {
Object[][] tableData = getGlyphs(font); Object[][] tableData = getGlyphs(font);
double[] yBounds = getYBounds(tableData, 3); double[] yBounds = getYBounds(tableData, 3);
Map<String, String> attributes = new LinkedHashMap<String, String>(); Map<String, String> attributes = new LinkedHashMap<String, String>();
attributes.put("Font", font.getName()); attributes.put("Font", font.getName());
skipping to change at line 70 skipping to change at line 75
Object[][] glyphs = new Object[256][4]; Object[][] glyphs = new Object[256][4];
for (int index = 0; index <= 255; index++) for (int index = 0; index <= 255; index++)
{ {
glyphs[index][0] = index; glyphs[index][0] = index;
if (font.getEncoding().contains(index) || font.toUnicode(index) != n ull) if (font.getEncoding().contains(index) || font.toUnicode(index) != n ull)
{ {
String glyphName = font.getEncoding().getName(index); String glyphName = font.getEncoding().getName(index);
glyphs[index][1] = glyphName; glyphs[index][1] = glyphName;
glyphs[index][2] = font.toUnicode(index); glyphs[index][2] = font.toUnicode(index);
if (font instanceof PDVectorFont) try
{ {
// using names didn't work with the file from PDFBOX-3445 if (font instanceof PDVectorFont)
glyphs[index][3] = ((PDVectorFont) font).getPath(index); {
// using names didn't work with the file from PDFBOX-344
5
glyphs[index][3] = ((PDVectorFont) font).getPath(index);
}
else
{
// type 1 font isn't a vector font in 2.0
glyphs[index][3] = font.getPath(glyphName);
}
} }
else catch (IOException ex)
{ {
glyphs[index][3] = font.getPath(glyphName); LOG.error("Couldn't render code " + index + " ('" + glyphNam
e + "') of font " +
font.getName(), ex);
glyphs[index][3] = new GeneralPath();
} }
totalAvailableGlyph++; totalAvailableGlyph++;
} }
else else
{ {
glyphs[index][1] = NO_GLYPH; glyphs[index][1] = NO_GLYPH;
glyphs[index][2] = NO_GLYPH; glyphs[index][2] = NO_GLYPH;
glyphs[index][3] = font.getPath(".notdef"); glyphs[index][3] = font.getPath(".notdef");
} }
} }
return glyphs; return glyphs;
} }
private String getEncodingName(PDSimpleFont font) private String getEncodingName(PDSimpleFont font)
{ {
return font.getEncoding().getClass().getSimpleName(); return font.getEncoding().getClass().getSimpleName() + " / " + font.get Encoding().getEncodingName();
} }
@Override @Override
public JPanel getPanel() public JPanel getPanel()
{ {
return view.getPanel(); return view.getPanel();
} }
} }
 End of changes. 9 change blocks. 
11 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)