You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CIDFontWidthsEntry.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package org.apache.fop.render.pdf;
  2. /**
  3. * This object is used for widths in CIDFonts .
  4. * The entry of Widths for a CIDFont allows two defferent formats .
  5. * For more details , see PDF specification p.213 .
  6. */
  7. public class CIDFontWidthsEntry {
  8. int[] widths = null;
  9. int width = 0;
  10. int start = 0;
  11. int end = 0;
  12. /**
  13. * C [ W1 W2 ... Wn ] format entry .
  14. */
  15. CIDFontWidthsEntry(int start, int[] widths) {
  16. this.start = start;
  17. this.end = start+widths.length;
  18. this.widths=widths;
  19. }
  20. /**
  21. * Cfirst Clast W format entry .
  22. */
  23. CIDFontWidthsEntry(int start, int end, int width) {
  24. this.start = start;
  25. this.end = end;
  26. this.width = width;
  27. }
  28. /**
  29. * Get widths for specified code point .
  30. */
  31. public int getWidth(int codePoint) throws ArrayIndexOutOfBoundsException {
  32. if (codePoint<start || end<codePoint)
  33. throw new ArrayIndexOutOfBoundsException();
  34. return ( widths == null ) ? width : widths[codePoint-start];
  35. }
  36. public void toString(StringBuffer sb) {
  37. sb.append(start);
  38. if ( widths == null ) {
  39. sb.append(" ");
  40. sb.append(end);
  41. sb.append(" ");
  42. sb.append(width);
  43. sb.append("\n");
  44. } else {
  45. sb.append(" [ ");
  46. for ( int i = 0; i < widths.length; i++ ) {
  47. sb.append(widths[i]);
  48. sb.append(" ");
  49. }
  50. sb.append("]\n");
  51. }
  52. }
  53. }