Changeset 691 for trunk/docx4j/etc
- Timestamp:
- 03/19/09 16:26:34 (3 years ago)
- File:
-
- 1 edited
-
trunk/docx4j/etc/fop-fonts.patch (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/etc/fop-fonts.patch
r690 r691 1 Index: /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/CustomFont.java1 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java 2 2 =================================================================== 3 --- /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/CustomFont.java (revision 631408) 4 +++ /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/CustomFont.java (working copy) 3 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (revision 711795) 4 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (working copy) 5 @@ -151,7 +151,10 @@ 6 } 7 EmbedFontInfo fontInfo = new EmbedFontInfo(null, customFont.isKerningEnabled(), 8 fontTripletList, embedUrl, subFontName); 9 + fontInfo.setPanose(customFont.getPanose()); 10 fontInfo.setPostScriptName(customFont.getFontName()); 11 + fontInfo.setEmbeddable(customFont.isEmbeddable()); 12 + 13 if (fontCache != null) { 14 fontCache.addFont(fontInfo); 15 } 16 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/CIDFontType.java 17 =================================================================== 18 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/CIDFontType.java (revision 711795) 19 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/CIDFontType.java (working copy) 20 @@ -19,7 +19,8 @@ 21 22 package org.apache.fop.fonts; 23 24 -import org.apache.avalon.framework.ValuedEnum; 25 +//import org.apache.avalon.framework.ValuedEnum; 26 +import org.apache.fop.fonts.ValuedEnum; 27 28 /** 29 * This class enumerates all supported CID font types. 30 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/CustomFont.java 31 =================================================================== 32 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/CustomFont.java (revision 711795) 33 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/CustomFont.java (working copy) 5 34 @@ -17,6 +17,11 @@ 6 35 … … 15 44 16 45 import java.io.IOException; 17 @@ -57,6 +62,26 @@ 18 private Map kerning; 46 @@ -58,6 +63,26 @@ 19 47 20 48 private boolean useKerning = true; 21 + 22 + private boolean isEmbeddable = true; 49 50 + private boolean isEmbeddable = true; 51 + 23 52 + public boolean isEmbeddable() { 24 53 + return isEmbeddable; 25 54 + } 55 + 26 56 + public void setEmbeddable(boolean isEmbeddable) { 27 57 + this.isEmbeddable = isEmbeddable; 28 58 + } 29 + 30 + 31 + private Panose panose = null; 32 + 33 + public Panose getPanose() { 59 + 60 + private Panose panose = null; 61 + 62 + public Panose getPanose() { 34 63 + return panose; 35 64 + } … … 39 68 + } 40 69 + 41 42 70 /** {@inheritDoc} */ 43 71 public String getFontName() { 44 @@ -448,4 +473,5 @@ 45 } 46 } 47 48 + 49 } 50 Index: /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/EmbedFontInfo.java 72 return fontName; 73 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/EmbedFontInfo.java 51 74 =================================================================== 52 --- /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/EmbedFontInfo.java (revision 631408)53 +++ /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/EmbedFontInfo.java (working copy)75 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/EmbedFontInfo.java (revision 711795) 76 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/EmbedFontInfo.java (working copy) 54 77 @@ -17,6 +17,11 @@ 55 78 56 79 /* $Id$ */ 57 80 58 81 +/* NOTICE: This file has been changed by Plutext Pty Ltd for use in docx4j. 59 82 + * … … 63 86 package org.apache.fop.fonts; 64 87 65 import java.io. Serializable;66 @@ - 38,6 +43,32@@67 protected boolean kerning;68 /** the list of associated font triplets */69 protected List fontTriplets;70 + 71 + private boolean isEmbeddable = true;88 import java.io.IOException; 89 @@ -48,14 +53,41 @@ 90 91 private transient boolean embedded = true; 92 93 + private boolean isEmbeddable = true; 94 + 72 95 + public boolean isEmbeddable() { 73 96 + return isEmbeddable; 74 97 + } 98 + 75 99 + public void setEmbeddable(boolean isEmbeddable) { 76 100 + this.isEmbeddable = isEmbeddable; 77 + } 78 + 79 + protected Panose panose = null;80 + 81 + public Panose getPanose() {101 + } 102 + 103 + protected Panose panose = null; 104 + 105 + public Panose getPanose() { 82 106 + return panose; 83 107 + } … … 87 111 + } 88 112 + 89 + protected String postScriptName = null;90 + public String getPostScriptName() {91 + return postScriptName;92 + }93 + public void setPostScriptName(String postScriptName) {94 + this.postScriptName = postScriptName;95 + }96 97 113 /** 98 * Main constructor 99 Index: /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/Enum.java 114 - * Main constructor 115 - * @param metricsFile Path to the xml file containing font metrics 116 - * @param kerning True if kerning should be enabled 117 - * @param fontTriplets List of font triplets to associate with this font 118 - * @param embedFile Path to the embeddable font file (may be null) 119 - * @param subFontName the sub-fontname used for TrueType Collections (null otherwise) 120 - */ 121 + * Main constructor 122 + * 123 + * @param metricsFile 124 + * Path to the xml file containing font metrics 125 + * @param kerning 126 + * True if kerning should be enabled 127 + * @param fontTriplets 128 + * List of font triplets to associate with this font 129 + * @param embedFile 130 + * Path to the embeddable font file (may be null) 131 + * @param subFontName 132 + * the sub-fontname used for TrueType Collections (null 133 + * otherwise) 134 + */ 135 public EmbedFontInfo(String metricsFile, boolean kerning, 136 List/*<FontTriplet>*/ fontTriplets, String embedFile, String subFontName) { 137 this.metricsFile = metricsFile; 138 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/Enum.java 100 139 =================================================================== 101 --- /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/Enum.java (revision 0)102 +++ /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/Enum.java (revision 0)140 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/Enum.java (revision 0) 141 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/Enum.java (revision 0) 103 142 @@ -0,0 +1,182 @@ 104 143 +/* … … 123 162 + */ 124 163 + 125 +// moved from avalon.framework164 +//package org.apache.avalon.framework; 126 165 +package org.apache.fop.fonts; 127 166 + … … 178 217 + * 179 218 + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> 180 + * @version CVS $Revision: 1.28 $ $Date: 2004/02/11 14:34:24$219 + * @version $Id$ 181 220 + */ 182 221 +public abstract class Enum … … 230 269 + * @return the equality status 231 270 + */ 232 + public finalboolean equals( Object o )271 + public boolean equals( Object o ) 233 272 + { 234 273 + if( this == o ) … … 237 276 + return false; 238 277 + 239 + final Enum enum b= (Enum)o;240 + 241 + if( !getClass().equals( enum b.getClass() ) )278 + final Enum enumerated = (Enum)o; 279 + 280 + if( !getClass().equals( enumerated.getClass() ) ) 242 281 + return false; 243 + if( m_name != null ? !m_name.equals( enum b.m_name ) : enumb.m_name != null )282 + if( m_name != null ? !m_name.equals( enumerated.m_name ) : enumerated.m_name != null ) 244 283 + return false; 245 284 + … … 284 323 + } 285 324 +} 286 Index: /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/MultiByteFont.java325 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/FontType.java 287 326 =================================================================== 288 --- /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/MultiByteFont.java (revision 631408) 289 +++ /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/MultiByteFont.java (working copy) 327 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/FontType.java (revision 711795) 328 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/FontType.java (working copy) 329 @@ -19,7 +19,8 @@ 330 331 package org.apache.fop.fonts; 332 333 -import org.apache.avalon.framework.ValuedEnum; 334 +//import org.apache.avalon.framework.ValuedEnum; 335 +import org.apache.fop.fonts.ValuedEnum; 336 337 /** 338 * This class enumerates all supported font types. 339 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/MultiByteFont.java 340 =================================================================== 341 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/MultiByteFont.java (revision 711795) 342 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/MultiByteFont.java (working copy) 290 343 @@ -17,6 +17,11 @@ 291 344 … … 300 353 301 354 //Java 302 @@ -40,8 +45,9 @@ 303 private String namePrefix = null; // Quasi unique prefix 304 305 private BFEntry[] bfentries = null; 306 + 307 308 - /** 309 + /** 310 * Default constructor 311 */ 312 public MultiByteFont() { 313 @@ -133,12 +139,16 @@ 355 @@ -118,10 +123,13 @@ 314 356 } 315 357 } 316 358 317 - /** 318 - * {@inheritDoc} 319 - */ 359 - /** {@inheritDoc} */ 320 360 - public boolean isEmbeddable() { 321 361 - return !(getEmbedFileName() == null && getEmbedResourceName() == null); 322 362 - } 323 +324 363 +// Comment out - this overrides the value derived by TTFFile, which 325 364 +// is not what we want. 326 365 + 327 +// /** 328 +// * {@inheritDoc} 329 +// */ 366 +// /** {@inheritDoc} */ 330 367 +// public boolean isEmbeddable() { 331 368 +// return !(getEmbedFileName() == null && getEmbedResourceName() == null); 332 369 +// } 333 370 334 /** 335 * {@inheritDoc}336 Index: /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/Panose.java371 /** {@inheritDoc} */ 372 public CIDSubset getCIDSubset() { 373 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/Panose.java 337 374 =================================================================== 338 --- /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/Panose.java (revision 0)339 +++ /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/Panose.java (revision 0)340 @@ -0,0 +1, 409@@375 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/Panose.java (revision 0) 376 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/Panose.java (revision 0) 377 @@ -0,0 +1,376 @@ 341 378 +/* 342 379 + * Copyright 2006 The FOray Project. … … 362 399 + 363 400 +/* 364 + * $LastChangedRevision: 10 097$365 + * $LastChangedDate: 200 7-07-24 15:05:09 -0600 (Tue, 24 Jul 2007) $401 + * $LastChangedRevision: 10482 $ 402 + * $LastChangedDate: 2008-03-23 02:59:39 +1100 (Sun, 23 Mar 2008) $ 366 403 + * $LastChangedBy$ 367 404 + */ … … 372 409 + */ 373 410 + 411 +//package org.foray.font.format; 374 412 +package org.apache.fop.fonts; 375 413 + 376 +import java.io.Serializable;377 414 + 378 415 + 379 416 +/** 380 + * A PANOSE classification number.381 + * 417 + * A PANOSE-1 classification number. 418 + * 382 419 + * <p>References:</p> 383 420 + * <ul> … … 393 430 + * </ul> 394 431 + */ 395 +public class Panose implements Serializable { 396 + 397 + /** 398 + * Serialization Version UID. Change this value if you want to make sure the user's cache 399 + * file is purged after an update. 400 + */ 401 + private static final long serialVersionUID = 605232520271754718L; 402 + 432 +public final class Panose { 433 + 403 434 + /** 404 435 + * Enumeration of the fields that comprise a PANOSE description. … … 469 500 + 470 501 + } 471 + 502 + 503 + /** 504 + * Constant indicating the minimum italic value for the letterform field. 505 + * This is based on an analysis of the MS ClearType Collection fonts: 506 + * <ul> 507 + * <li>consolas [ 2 11 6 9 2 2 4 3 2 4 ] bold 6 ital 3</li> 508 + * <li>consolas-bold [ 2 11 7 9 2 2 4 3 2 4 ] bold 7 ital 3</li> 509 + * <li>consolas-italic [ 2 11 6 9 2 2 4 10 2 4 ] bold 6 ital 10</li> 510 + * <li>consolas-bolditalic [ 2 11 7 9 2 2 4 10 2 4 ] bold 7 ital 10</li> 511 + * 512 + * <li>cordianew [ 2 11 3 4 2 2 2 2 2 4 ] bold 3 ital 2</li> 513 + * <li>cordianew-bolditalic [ 2 11 6 4 2 2 2 9 2 4 ] bold 6 ital 9</li> 514 + * 515 + * <li>calibri [ 2 15 5 2 2 2 4 3 2 4 ] bold 5 ital 3</li> 516 + * <li>calibri-bold [ 2 15 7 2 3 4 4 3 2 4 ] bold 7 ital 3</li> 517 + * <li>calibri-bolditalic [ 2 15 7 2 3 4 4 10 2 4 ] bold 7 ital 10</li> 518 + * 519 + * <li>constantia [ 2 3 6 2 5 3 6 3 3 3 ] bold 6 ital 3</li> 520 + * <li>constantia-bold [ 2 3 7 2 6 3 6 3 3 3 ] bold 7 ital 3 (note the 6 at index 4)</li> 521 + * <li>constantia-italic [ 2 3 6 2 5 3 6 10 3 3 ] bold 6 ital 10</li> 522 + * 523 + * <li>candara-bold [ 2 14 7 2 3 3 3 2 2 4 ] bold 7 ital 2</li> 524 + * <li>candara-italic [ 2 14 5 2 3 3 3 9 2 4 ] bold 5 ital 9</li> 525 + * <li>candara-bolditalic [ 2 14 7 2 3 3 3 9 2 4 ] bold 7 ital 9</li> 526 + * 527 + * <li>cambria-bold [ 2 4 8 3 5 4 6 3 2 4 ] bold 8 ital 3</li> 528 + * <li>cambria-italic [ 2 4 5 3 5 4 6 10 2 4 ] bold 5 ital 10</li> 529 + * </ul> 530 + */ 531 + private static final byte LETTERFORM_MIN_ITALIC = 9; 532 + 533 + /** 534 + * Constant indicating the minimum bold value for the weight field. 535 + * This is based on an analysis of the MS ClearType Collection fonts, which can be found at 536 + * {@link #LETTERFORM_MIN_ITALIC}. 537 + */ 538 + private static final byte WEIGHT_MIN_BOLD = 7; 539 + 472 540 + /** An array of weights indicating that all elements in a comparison between two PANOSE values 473 541 + * shall be considered to be of the same weight. */ … … 476 544 + * parameter. However, there is no way to protect the data inside it from corruption, so we 477 545 + * have elected to keep it private and to allow "null" to be interpreted as the same value. */ 478 + 479 +// /** Constant indicating the size of the "panose" field, in bytes. */ 480 +// public static final byte ARRAY_SIZE = 10; 481 + 482 + /** Max difference for it to be considered an acceptable match. 483 + * Note that this value will depend on the weights in the 484 + * difference function. 485 + */ 486 + public static final int MATCH_THRESHOLD = 30; 487 + 488 + 546 + 489 547 + /** The encapsulated array of PANOSE numbers. */ 490 548 + private byte[] panoseArray; 491 +492 549 + 493 550 + /** … … 496 553 + */ 497 554 + private Panose(final byte[] panoseArray) { 498 + this.panoseArray = panoseArray; 499 + } 500 + 501 + /** 502 + * Creates a new Panose instance. 555 + /* Clone the incoming array to protect our data from subsequent changes made to the original 556 + * array. */ 557 + this.panoseArray = panoseArray.clone(); 558 + } 559 + 560 + /** 561 + * Creates a new Panose instance, first checking it for validity. 503 562 + * @param panoseArray The array of bytes recording the PANOSE 504 563 + * classification. 505 564 + * @return The newly-created instance. 565 + * @throws FontException If <code>panoseArray</code> contains an illegal value. 566 + * @see #forceInstance(byte[]) 506 567 + */ 507 568 + public static Panose makeInstance(final byte[] panoseArray) { … … 510 571 + throw new IllegalArgumentException("Illegal Panose Array: " + panoseValidationMessage); 511 572 + } 573 + return new Panose(panoseArray); 574 + } 575 + 576 + /** 577 + * Creates a new Panose instance without any error checking. 578 + * @param panoseArray The array of bytes recording the PANOSE classification. 579 + * @return The newly-created instance. 580 + * @see #makeInstance(byte[]) 581 + */ 582 + public static Panose forceInstance(final byte[] panoseArray) { 512 583 + return new Panose(panoseArray); 513 584 + } … … 575 646 + return difference; 576 647 + } 577 + 578 + /* 579 + * consolas [ 2 11 6 9 2 2 4 3 2 4 ] bold 6 ital 3 580 + consolas-bold [ 2 11 7 9 2 2 4 3 2 4 ] bold 7 ital 3 581 + consolas-italic [ 2 11 6 9 2 2 4 10 2 4 ] bold 6 ital 10 582 + consolas-bolditalic[ 2 11 7 9 2 2 4 10 2 4 ] bold 7 ital 10 583 + 584 + cordianew [ 2 11 3 4 2 2 2 2 2 4 ] bold 3 ital 2 585 + cordianew-bolditalic[ 2 11 6 4 2 2 2 9 2 4 ] bold 6 ital 9 586 + 587 + calibri [ 2 15 5 2 2 2 4 3 2 4 ] bold 5 ital 3 588 + calibri-bold [ 2 15 7 2 3 4 4 3 2 4 ] bold 7 ital 3 589 + calibri-bolditalic [ 2 15 7 2 3 4 4 10 2 4 ] bold 7 ital 10 590 + 591 + constantia [ 2 3 6 2 5 3 6 3 3 3 ] bold 6 ital 3 592 + constantia-bold [ 2 3 7 2 6 3 6 3 3 3 ] bold 7 ital 3 593 + ^ note this 594 + constantia-italic [ 2 3 6 2 5 3 6 10 3 3 ] bold 6 ital 10 595 + 596 + candara-bold [ 2 14 7 2 3 3 3 2 2 4 ] bold 7 ital 2 597 + candara-italic [ 2 14 5 2 3 3 3 9 2 4 ] bold 5 ital 9 598 + candara-bolditalic [ 2 14 7 2 3 3 3 9 2 4 ] bold 7 ital 9 599 + 600 + cambria-bold [ 2 4 8 3 5 4 6 3 2 4 ] bold 8 ital 3 601 + cambria-italic [ 2 4 5 3 5 4 6 10 2 4 ] bold 5 ital 10 602 + 603 + */ 604 + 605 + public static Panose getBold(Panose thisPanose) { 606 + 607 + byte[] panoseArray = thisPanose.getPanoseArray(); 608 + 609 + if (panoseArray[2]==11) { 610 + // Already the maximum value - do nothing 611 + } else if (panoseArray[2]<8) { 612 + panoseArray[2]=9; 613 + // 8 = bold, and even though most of the MS ClearType Collection fonts have 7 here, 614 + // experience (Times New Roman) shows it is better to be on the high side, to stop 615 + // this Panose array from being equidistant between the normal weight and the 616 + // bold weight. 617 + 618 + } else { 619 + // Do nothing, rather than increase the Weight 620 + } 621 + 622 + return Panose.makeInstance(panoseArray); 623 + 624 + } 625 + 626 + public static Panose getItalic(Panose thisPanose) { 627 + 628 + byte[] panoseArray = thisPanose.getPanoseArray(); 629 + 630 + if (panoseArray[7]==15) { 631 + // Already the maximum value - do nothing 632 + } else if (panoseArray[7]<9) { 633 + panoseArray[7]=10; // Most fonts have 9 or 10 here, so use 10 on the same reasoning as above. 634 + } else { 635 + // Do nothing, rather than increase the Letterform setting 636 + } 637 + 638 + return Panose.makeInstance(panoseArray); 639 + 640 + } 641 + 642 + 648 + 643 649 + /** 644 650 + * Examines an array of weights, throwing various unchecked exceptions if the data is not valid. … … 662 668 + } 663 669 + } 664 + 665 +// /** 666 +// * Tests the validity of a panose description. 667 +// * @param panoseDescription The panose values to be tested. 668 +// * @return True for a valid PANOSE description, or false if the input is 669 +// * null, does not have 10 elements, or any of the elements do not contain 670 +// * valid ASCII numerals (0 through 9). 671 +// */ 672 +// public static boolean validPanose(final byte[] panoseDescription) { 673 +// if (panoseDescription == null) { 674 +// System.out.println("null byte[]" ); 675 +// return false; 676 +// } 677 +// if (panoseDescription.length != Panose.ARRAY_SIZE) { 678 +// System.out.println("Invalid length " + panoseDescription.length ); 679 +// return false; 680 +// } 681 +// for (int i = 0; i < panoseDescription.length; i++) { 682 +// final byte theByte = panoseDescription[i]; 683 +// String s = Byte.toString(theByte); 684 +// int n = Integer.parseInt(s); 685 +// if (n < 0) { 686 +// //System.out.println("Invalid value (too small) " + theByte + " in position " + i + " of " + toString(panoseDescription) ); 687 +// return false; 688 +// } 689 +// 690 +// if (n > validMaxValues[i]) { 691 +// System.out.println("Invalid value " + n + " > " + validMaxValues[i] + " in position " + i + " of " + toString(panoseDescription) ); 692 +// return false; 693 +// } 694 +// } 695 +// return true; 696 +// } 697 + 698 + 699 + 670 + 700 671 + /** 701 672 + * Tests the validity of a panose description. … … 728 699 + */ 729 700 + public String toString() { 730 + return toString(this.panoseArray); 701 + return toString(this.panoseArray); 731 702 + } 732 703 + … … 744 715 + } 745 716 + sb.append("]"); 746 + return sb.toString(); 747 + } 748 + 717 + return sb.toString(); 718 + } 719 + 720 + /** 721 + * Returns the bold version of this Panose instance. 722 + * @return If this already describes a bold font, returns this. Otherwise, returns a new 723 + * Panose instance that is identical to this, except describing a bold font. 724 + */ 725 + public Panose getBold() { 726 + final byte weightValue = this.getElement(Panose.Field.WEIGHT); 727 + if (weightValue >= Panose.WEIGHT_MIN_BOLD) { 728 + /* This Panose value is already bold. */ 729 + return this; 730 + } 731 + final byte[] newArray = this.panoseArray.clone(); 732 + newArray[Panose.Field.WEIGHT.getIndex()] = Panose.WEIGHT_MIN_BOLD; 733 + return Panose.forceInstance(newArray); 734 + } 735 + 736 + /** 737 + * Returns the italic version of this Panose instance. 738 + * @return If this already describes an italic font, returns this. Otherwise, returns a new 739 + * Panose instance that is identical to this, except describing an italic font. 740 + */ 741 + public Panose getItalic() { 742 + final byte letterformValue = this.getElement(Panose.Field.LETTERFORM); 743 + if (letterformValue >= Panose.LETTERFORM_MIN_ITALIC) { 744 + /* This Panose value is already italic. */ 745 + return this; 746 + } 747 + final byte[] newArray = this.panoseArray.clone(); 748 + newArray[Panose.Field.LETTERFORM.getIndex()] = Panose.LETTERFORM_MIN_ITALIC; 749 + return Panose.forceInstance(newArray); 750 + } 751 + 752 + 749 753 +} 750 Index: /home/ jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/truetype/TTFFile.java754 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/truetype/TTFFile.java 751 755 =================================================================== 752 --- /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/truetype/TTFFile.java (revision 631408) 753 +++ /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/truetype/TTFFile.java (working copy) 754 @@ -17,6 +17,11 @@ 755 756 /* $Id$ */ 757 758 +/* NOTICE: This file has been changed by Plutext Pty Ltd for use in docx4j. 759 + * 760 + * This notice is included to meet the condition in clause 4(b) of the License. 761 + */ 762 + 763 package org.apache.fop.fonts.truetype; 764 765 import java.io.IOException; 766 @@ -30,7 +35,9 @@ 767 756 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/truetype/TTFFile.java (revision 711795) 757 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/truetype/TTFFile.java (working copy) 758 @@ -31,6 +31,7 @@ 768 759 import org.apache.xmlgraphics.fonts.Glyphs; 769 760 770 +import org.apache.fop.fonts.EmbedFontInfo;771 761 import org.apache.fop.fonts.FontUtil; 772 762 +import org.apache.fop.fonts.Panose; … … 774 764 /** 775 765 * Reads a TrueType file or a TrueType Collection. 776 @@ -48,9 +55,12 @@ 777 public static final boolean TRACE_ENABLED = false; 766 @@ -49,6 +50,9 @@ 778 767 779 768 private String encoding = "WinAnsiEncoding"; // Default encoding 769 770 + /** Array containing the Panose information. */ 771 + private Panose panose; 780 772 + 781 + /** Array containing the Panose information. */782 + private Panose panose;783 784 773 private short firstChar = 0; 785 - private boolean isEmbeddable = true; 786 + private boolean isEmbeddable = false; // until proven otherwise! 774 private boolean isEmbeddable = true; 787 775 private boolean hasSerifs = true; 788 /** 789 * Table directory 790 @@ -549,8 +559,10 @@ 791 */ 792 public String getPostScriptName() { 793 if (postScriptName.length() == 0) { 794 + System.out.println("TTFFile - Hmmm, Composed postscript name from fullname."); 795 return FontUtil.stripWhiteSpace(getFullName()); 796 } else { 797 +// System.out.println("TTFFile - Cool, there was a proper postScript name, namely: " + postScriptName); 798 return postScriptName; 799 } 800 } 801 @@ -743,6 +755,7 @@ 802 * @return boolean True if it may be embedded 803 */ 804 public boolean isEmbeddable() { 805 + 806 return isEmbeddable; 807 } 808 809 @@ -988,7 +1001,10 @@ 810 if (dirTabs.get("OS/2") != null) { 811 seekTab(in, "OS/2", 2 * 2); 812 this.usWeightClass = in.readTTFUShort(); 813 + 814 + // usWidthClass 815 in.skip(2); 816 + 817 int fsType = in.readTTFUShort(); 818 if (fsType == 2) { 819 isEmbeddable = false; 820 @@ -996,10 +1012,21 @@ 776 @@ -1006,8 +1010,15 @@ 821 777 isEmbeddable = true; 822 778 } 823 779 in.skip(11 * 2); 824 780 - in.skip(10); //panose array 781 - in.skip(4 * 4); //unicode ranges 825 782 + 826 + //in.skip(10); //panose array 783 + //in.skip(10); //panose array 827 784 + final byte[] panoseArray = new byte[10]; 828 + for (int i = 0; i < panoseArray.length; i++) {829 + panoseArray[i] = in.read();830 + }831 + this.panose = Panose.makeInstance(panoseArray);785 + for (int i = 0; i < panoseArray.length; i++) { 786 + panoseArray[i] = in.read(); 787 + } 788 + this.panose = Panose.makeInstance(panoseArray); 832 789 + 833 + 834 + /* Skip ulUnicodeRange1 - 4. */ 835 in.skip(4 * 4); //unicode ranges 790 + in.skip(4 * 4); // unicode ranges 836 791 in.skip(4); 837 792 in.skip(3 * 2); 838 +839 + /* Read sTypoAscender. */840 793 int v; 841 os2Ascender = in.readTTFShort(); //sTypoAscender 842 log.debug("sTypoAscender: " + os2Ascender 843 @@ -1568,4 +1655,8 @@ 844 ioe.printStackTrace(System.err); 794 @@ -1549,6 +1560,10 @@ 795 return null; 845 796 } 846 797 } 847 + 848 + public Panose getPanose() {798 + 799 + public Panose getPanose() { 849 800 + return panose; 850 + } 851 } 852 \ No newline at end of file 853 Index: /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/ValuedEnum.java 801 + } 802 803 /* 804 * Helper classes, they are not very efficient, but that really 805 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java 854 806 =================================================================== 855 --- /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/ValuedEnum.java (revision 0) 856 +++ /home/jharrop/workspace200711/fop/src/java/org/apache/fop/fonts/ValuedEnum.java (revision 0) 857 @@ -0,0 +1,205 @@ 807 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java (revision 711795) 808 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java (working copy) 809 @@ -130,6 +130,9 @@ 810 returnFont.setItalicAngle(Integer.parseInt(ttf.getItalicAngle())); 811 returnFont.setMissingWidth(0); 812 returnFont.setWeight(ttf.getWeightClass()); 813 + 814 + returnFont.setPanose(ttf.getPanose() ); 815 + returnFont.setEmbeddable(ttf.isEmbeddable() ); 816 817 if (isCid) { 818 multiFont.setCIDType(CIDFontType.CIDTYPE2); 819 Index: /home/dev/workspace/fop/src/java/org/apache/fop/fonts/ValuedEnum.java 820 =================================================================== 821 --- /home/dev/workspace/fop/src/java/org/apache/fop/fonts/ValuedEnum.java (revision 0) 822 +++ /home/dev/workspace/fop/src/java/org/apache/fop/fonts/ValuedEnum.java (revision 0) 823 @@ -0,0 +1,234 @@ 858 824 +/* 859 825 + * Copyright 1997-2004 The Apache Software Foundation … … 877 843 + */ 878 844 + 879 +// moved from avalon.framework845 +//package org.apache.avalon.framework; 880 846 +package org.apache.fop.fonts; 881 847 + … … 938 904 + * 939 905 + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> 940 + * @version CVS $Revision: 1.21 $ $Date: 2004/02/11 14:34:24$906 + * @version $Id$ 941 907 + */ 942 908 +public abstract class ValuedEnum … … 1050 1016 + 1051 1017 + /** 1018 + * Tests for equality. Two Enum:s are considered equal 1019 + * if they are of the same class, have the same name, and same value. 1020 + * 1021 + * @param o the other object 1022 + * @return the equality status 1023 + */ 1024 + public boolean equals( Object o ) 1025 + { 1026 + boolean prelim = super.equals( o ); 1027 + if( ! prelim ) 1028 + return false; 1029 + 1030 + if( !(o instanceof ValuedEnum) ) 1031 + return false; 1032 + 1033 + final ValuedEnum enumerated = (ValuedEnum) o; 1034 + return m_value == enumerated.m_value; 1035 + } 1036 + 1037 + public int hashCode() 1038 + { 1039 + int hash = super.hashCode(); 1040 + hash ^= m_value; 1041 + hash >>>= (m_value & 31 ); 1042 + return hash; 1043 + } 1044 + 1045 + 1046 + /** 1052 1047 + * Override toString method to produce human readable description. 1053 1048 + *
Note: See TracChangeset
for help on using the changeset viewer.
