apwfreetypelib

Check-in [6a644b50ad]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6a644b50ad617b50f8f7ecd54a52e881c25f470c
User & Date: arnulf 2015-02-06 21:44:50
Context
2015-02-07
16:49
fixes. check-in: 0f24cb935e user: arnulf tags: trunk
2015-02-06
21:44
fixes. check-in: 6a644b50ad user: arnulf tags: trunk
21:18
make glyph flags/tags a Set. fixes. check-in: ef8376af8c user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to aftbase/FTGlyphLoaderRec.java.

29
30
31
32
33
34
35




36
37
38
39
40
41
42
...
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
...
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
  /* ===================================================================== */

public class FTGlyphLoaderRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "FTGlyphLoaderRec";





  protected int max_points = 0;
  protected int max_contours = 0;
  protected int max_subglyphs = 0;
  protected boolean use_extra = false;
  protected FTGlyphLoadRec base = null;
  protected FTGlyphLoadRec current = null;
................................................................................
      /* check points & tags */
      new_max = base.getN_points() + current.getN_points() + n_points;
      old_max = max_points;
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("n_points: base.outline.n_points: %d current.outline.n_points: %d n_points: %d", base.getN_points(), current.getN_points(), n_points));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("FTGlyphLoaderCheckPoints: renew: old: %d new: %d", old_max, new_max));
      if (new_max > old_max) {
        new_max = FTCalc.FT_PAD_CEIL(new_max, 8);
        if (new_max > Flags.Outline.POINTS_MAX.getVal()) {
          return FTError.ErrorTag.GLYPH_ARRAY_TOO_LARGE;
        }
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "FT_RENEW_ARRAY: base.outline.points: "+base.getPoints()+"!");
        base.setPoints((FTVectorRec[]) FTUtil.FT_RENEW_ARRAY(base.getPoints(), FTUtilFlags.ArrayType.FT_VECTOR, old_max, new_max));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "after FT_RENEW_ARRAY: base.outline.points: "+base.getPoints()+"!");
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "FT_RENEW_ARRAY: base.outline.tags: "+base.getTags());
        base.setTags((Set<Flags.Curve>[])FTUtil.FT_RENEW_ARRAY(base.getTags(), FTUtilFlags.ArrayType.CURVE, old_max, new_max));
................................................................................
      /* check contours */
      old_max = max_contours;
      new_max = base.getN_contours() + current.getN_contours() + n_contours;
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("base.outline.n_contours: %d, current.outline.n_contours: %d, n_contours: %d", base.getN_contours(), current.getN_contours(), n_contours));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("FTGlyphLoaderCheckContours: renew: old: %d new: %d", old_max, new_max));
      if (new_max > old_max) {
        new_max = FTCalc.FT_PAD_CEIL(new_max, 4);
        if (new_max > Flags.Outline.CONTOURS_MAX.getVal()) {
          return FTError.ErrorTag.GLYPH_ARRAY_TOO_LARGE;
        }
        base.setContours((int[])FTUtil.FT_RENEW_ARRAY(base.getContours(), FTUtilFlags.ArrayType.INT, old_max, new_max));
        adjust = true;
        max_contours = new_max;
      }
      if (adjust) {







>
>
>
>







 







|







 







|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
  /* ===================================================================== */

public class FTGlyphLoaderRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "FTGlyphLoaderRec";

  private static final int CONTOURS_MAX = 0xFFFF;
  private static final int POINTS_MAX = 0xFFFF;


  protected int max_points = 0;
  protected int max_contours = 0;
  protected int max_subglyphs = 0;
  protected boolean use_extra = false;
  protected FTGlyphLoadRec base = null;
  protected FTGlyphLoadRec current = null;
................................................................................
      /* check points & tags */
      new_max = base.getN_points() + current.getN_points() + n_points;
      old_max = max_points;
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("n_points: base.outline.n_points: %d current.outline.n_points: %d n_points: %d", base.getN_points(), current.getN_points(), n_points));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("FTGlyphLoaderCheckPoints: renew: old: %d new: %d", old_max, new_max));
      if (new_max > old_max) {
        new_max = FTCalc.FT_PAD_CEIL(new_max, 8);
        if (new_max > POINTS_MAX) {
          return FTError.ErrorTag.GLYPH_ARRAY_TOO_LARGE;
        }
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "FT_RENEW_ARRAY: base.outline.points: "+base.getPoints()+"!");
        base.setPoints((FTVectorRec[]) FTUtil.FT_RENEW_ARRAY(base.getPoints(), FTUtilFlags.ArrayType.FT_VECTOR, old_max, new_max));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "after FT_RENEW_ARRAY: base.outline.points: "+base.getPoints()+"!");
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "FT_RENEW_ARRAY: base.outline.tags: "+base.getTags());
        base.setTags((Set<Flags.Curve>[])FTUtil.FT_RENEW_ARRAY(base.getTags(), FTUtilFlags.ArrayType.CURVE, old_max, new_max));
................................................................................
      /* check contours */
      old_max = max_contours;
      new_max = base.getN_contours() + current.getN_contours() + n_contours;
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("base.outline.n_contours: %d, current.outline.n_contours: %d, n_contours: %d", base.getN_contours(), current.getN_contours(), n_contours));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("FTGlyphLoaderCheckContours: renew: old: %d new: %d", old_max, new_max));
      if (new_max > old_max) {
        new_max = FTCalc.FT_PAD_CEIL(new_max, 4);
        if (new_max > CONTOURS_MAX) {
          return FTError.ErrorTag.GLYPH_ARRAY_TOO_LARGE;
        }
        base.setContours((int[])FTUtil.FT_RENEW_ARRAY(base.getContours(), FTUtilFlags.ArrayType.INT, old_max, new_max));
        adjust = true;
        max_contours = new_max;
      }
      if (adjust) {

Changes to aftbase/Flags.java.

386
387
388
389
390
391
392
393
394
395
396
397
398
399



400
401
402

403
404
405
406
407
408
409
...
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
...
599
600
601
602
603
604
605



606
607
608
609
610
611
612
      for (Load t : values()) {
        if ((value & t.getVal()) != 0) {
          flags.add(t);
        }
      }
      return flags;
    }
    public static String CurveSetToString(Set<Curve> flags) {
      StringBuffer str = new StringBuffer();
      for (Load t : values()) {
        if (flags.contains(t)) {
          str.append(" "+t.toString());
        }
      }



      return str.toString();
    }
    public static int CurveSetToInt(Set<Curve> flags) {

      int val = 0;
      for (Load t : values()) {
        if (flags.contains(t)) {
          val += t.getVal();
        }
      }
      return val;
................................................................................
    OWNER(0x1, "FT_OUTLINE_OWNER"),
    EVEN_ODD_FILL(0x2, "FT_OUTLINE_EVEN_ODD_FILL"),
    REVERSE_FILL(0x4, "FT_OUTLINE_REVERSE_FILL"),
    IGNORE_DROPOUTS(0x8, "FT_OUTLINE_IGNORE_DROPOUTS"),
    SMART_DROPOUTS(0x10, "FT_OUTLINE_SMART_DROPOUTS"),
    INCLUDE_STUBS(0x20, "FT_OUTLINE_INCLUDE_STUBS"),
    HIGH_PRECISION(0x100, "FT_OUTLINE_HIGH_PRECISION"),
    SINGLE_PASS(0x200, "FT_OUTLINE_SINGLE_PASS"),
    CONTOURS_MAX(0xFFFF, "FT_OUTLINE_CONTOURS_MAX"),
    POINTS_MAX(0xFFFF, "FT_OUTLINE_POINTS_MAX");
    private int val;
    private String str;
    private static SparseArray<Outline> tagToOutlineMapping;
    public static Outline getTableTag(int i) {
      if (tagToOutlineMapping == null) {
        initMapping();
      }
................................................................................
    public static String CurveSetToString(Set<Curve> flags) {
      StringBuffer str = new StringBuffer();
      for (Curve t : values()) {
        if (flags.contains(t)) {
          str.append(" "+t.toString());
        }
      }



      return str.toString();
    }
    public static int CurveSetToInt(Set<Curve> flags) {
      int val = 0;
      for (Curve t : values()) {
        if (flags.contains(t)) {
          val += t.getVal();







|






>
>
>


<
>







 







|
<
<







 







>
>
>







386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404

405
406
407
408
409
410
411
412
...
531
532
533
534
535
536
537
538


539
540
541
542
543
544
545
...
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
      for (Load t : values()) {
        if ((value & t.getVal()) != 0) {
          flags.add(t);
        }
      }
      return flags;
    }
    public static String LoadSetToString(Set<Load> flags) {
      StringBuffer str = new StringBuffer();
      for (Load t : values()) {
        if (flags.contains(t)) {
          str.append(" "+t.toString());
        }
      }
      if (flags.isEmpty()) {
        str.append(" "+DEFAULT);
      }
      return str.toString();
    }

    public static int LoadSetToInt(Set<Load> flags) {
      int val = 0;
      for (Load t : values()) {
        if (flags.contains(t)) {
          val += t.getVal();
        }
      }
      return val;
................................................................................
    OWNER(0x1, "FT_OUTLINE_OWNER"),
    EVEN_ODD_FILL(0x2, "FT_OUTLINE_EVEN_ODD_FILL"),
    REVERSE_FILL(0x4, "FT_OUTLINE_REVERSE_FILL"),
    IGNORE_DROPOUTS(0x8, "FT_OUTLINE_IGNORE_DROPOUTS"),
    SMART_DROPOUTS(0x10, "FT_OUTLINE_SMART_DROPOUTS"),
    INCLUDE_STUBS(0x20, "FT_OUTLINE_INCLUDE_STUBS"),
    HIGH_PRECISION(0x100, "FT_OUTLINE_HIGH_PRECISION"),
    SINGLE_PASS(0x200, "FT_OUTLINE_SINGLE_PASS");


    private int val;
    private String str;
    private static SparseArray<Outline> tagToOutlineMapping;
    public static Outline getTableTag(int i) {
      if (tagToOutlineMapping == null) {
        initMapping();
      }
................................................................................
    public static String CurveSetToString(Set<Curve> flags) {
      StringBuffer str = new StringBuffer();
      for (Curve t : values()) {
        if (flags.contains(t)) {
          str.append(" "+t.toString());
        }
      }
      if (flags.isEmpty()) {
        str.append(" "+CONIC);
      }
      return str.toString();
    }
    public static int CurveSetToInt(Set<Curve> flags) {
      int val = 0;
      for (Curve t : values()) {
        if (flags.contains(t)) {
          val += t.getVal();

Changes to afttruetype/TTTags.java.

1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
....
1184
1185
1186
1187
1188
1189
1190



1191
1192
1193
1194
1195
1196
1197
    }
    public int getVal() {
      return val;
    }
  }

  public enum GlyphFlags {
    Unknown(0x0, "TT_GLYPH_FLAGS_UNKNOWN"),
    ON_CURVE(0x1, "TT_GLYPH_FLAGS_ON_CURVE"),
    X_SHORT(0x2, "TT_GLYPH_FLAGS_X_SHORT"),
    Y_SHORT(0x4, "TT_GLYPH_FLAGS_Y_SHORT"),
    REPEAT(0x8, "TT_GLYPH_FLAGS_REPEAT"),
    X_SAME(0x10, "TT_GLYPH_FLAGS_X_SAME"),
    Y_SAME(0x20, "TT_GLYPH_FLAGS_Y_SAME"),
    RESERVED1(0x40, "TT_GLYPH_FLAGS_RESERVED1"),
................................................................................
    public static String GlyphFlagsSetToString(Set<GlyphFlags> flags) {
      StringBuffer str = new StringBuffer();
      for (GlyphFlags t : values()) {
        if (flags.contains(t)) {
          str.append(" "+t.toString());
        }
      }



      return str.toString();
    }
    public static int GlyphFlagsSetToInt(Set<GlyphFlags> flags) {
      int val = 0;
      for (GlyphFlags t : values()) {
        if (flags.contains(t)) {
          val += t.getVal();







|







 







>
>
>







1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
....
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
    }
    public int getVal() {
      return val;
    }
  }

  public enum GlyphFlags {
    NO_FLAGS(0x0, "TT_GLYPH_FLAGS_NO_FLAGS"),
    ON_CURVE(0x1, "TT_GLYPH_FLAGS_ON_CURVE"),
    X_SHORT(0x2, "TT_GLYPH_FLAGS_X_SHORT"),
    Y_SHORT(0x4, "TT_GLYPH_FLAGS_Y_SHORT"),
    REPEAT(0x8, "TT_GLYPH_FLAGS_REPEAT"),
    X_SAME(0x10, "TT_GLYPH_FLAGS_X_SAME"),
    Y_SAME(0x20, "TT_GLYPH_FLAGS_Y_SAME"),
    RESERVED1(0x40, "TT_GLYPH_FLAGS_RESERVED1"),
................................................................................
    public static String GlyphFlagsSetToString(Set<GlyphFlags> flags) {
      StringBuffer str = new StringBuffer();
      for (GlyphFlags t : values()) {
        if (flags.contains(t)) {
          str.append(" "+t.toString());
        }
      }
      if (flags.isEmpty()) {
        str.append(" "+NO_FLAGS);
      }
      return str.toString();
    }
    public static int GlyphFlagsSetToInt(Set<GlyphFlags> flags) {
      int val = 0;
      for (GlyphFlags t : values()) {
        if (flags.contains(t)) {
          val += t.getVal();

Changes to aftttinterpreter/TTInstructionFuncGrp3.java.

313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
      end_point = cur.pts.getContour(contour) - cur.pts.getFirst_point();
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("end_point: %d, contour: %d, first_point: %d", end_point, cur.pts.getContour(contour), cur.pts.getFirst_point()));
      first_point = point;
      if (TTUtil.BOUNDS(end_point, cur.pts.getN_points())) {
        end_point = cur.pts.getN_points() - 1;
      }
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("point: %d, end_point: %d", point, end_point));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tag1: point: "+point+" tags: "+Flags.Curve.CurveSetToString(cur.pts.getTag(point))+" mask: "+mask+" "+cur.pts.getTag(point).contains(mask)+" "+cur.pts.getTag(point).contains(Flags.Curve.TOUCH_X)+" "+cur.pts.getTag(point).contains(Flags.Curve.TOUCH_Y));
      while (point <= end_point && !cur.pts.getTag(point).contains(mask)) {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tag2: point: "+point+" "+Flags.Curve.CurveSetToString(cur.pts.getTag(point)));
        point++;
      }
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("point2: %d, end_point: %d", point, end_point));
      worker_ref = new FTReference<>();
      worker_ref.Set(V);
      if (point <= end_point) {
        first_touched = point;
        cur_touched   = point;
        point++;
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("point3: %d, end_point: %d, cur_touched: %d", point, end_point, cur_touched));
        while (point <= end_point) {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tag3: point: "+point+" "+Flags.Curve.CurveSetToString(cur.pts.getTag(point))+" "+mask+" "+cur.pts.getTag(point).contains(mask)+" "+cur.pts.getTag(point).contains(Flags.Curve.TOUCH_X)+" "+cur.pts.getTag(point).contains(Flags.Curve.TOUCH_X));
          if (cur.pts.getTag(point).contains(mask)) {
            _iup_worker_interpolate(worker_ref, cur_touched + 1, point - 1, cur_touched, point, useX);
            cur_touched = point;
          }
          point++;
        }
        if (cur_touched == first_touched) {







|













|







313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
      end_point = cur.pts.getContour(contour) - cur.pts.getFirst_point();
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("end_point: %d, contour: %d, first_point: %d", end_point, cur.pts.getContour(contour), cur.pts.getFirst_point()));
      first_point = point;
      if (TTUtil.BOUNDS(end_point, cur.pts.getN_points())) {
        end_point = cur.pts.getN_points() - 1;
      }
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("point: %d, end_point: %d", point, end_point));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tag1: point: "+point+" tags: "+Flags.Curve.CurveSetToString(cur.pts.getTag(point))+" mask: "+mask+" contains: "+cur.pts.getTag(point).contains(mask));
      while (point <= end_point && !cur.pts.getTag(point).contains(mask)) {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tag2: point: "+point+" "+Flags.Curve.CurveSetToString(cur.pts.getTag(point)));
        point++;
      }
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("point2: %d, end_point: %d", point, end_point));
      worker_ref = new FTReference<>();
      worker_ref.Set(V);
      if (point <= end_point) {
        first_touched = point;
        cur_touched   = point;
        point++;
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("point3: %d, end_point: %d, cur_touched: %d", point, end_point, cur_touched));
        while (point <= end_point) {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tag3: point: "+point+" tags: "+Flags.Curve.CurveSetToString(cur.pts.getTag(point))+" mask: "+mask+" contains: "+cur.pts.getTag(point).contains(mask));
          if (cur.pts.getTag(point).contains(mask)) {
            _iup_worker_interpolate(worker_ref, cur_touched + 1, point - 1, cur_touched, point, useX);
            cur_touched = point;
          }
          point++;
        }
        if (cur_touched == first_touched) {

Changes to aftttinterpreter/TTRunInstructions.java.

682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
          }
            /* increment instruction counter and check if we didn't */
            /* run this program for too long (e.g. infinite loops). */
          if (++ins_counter > MAX_RUNNABLE_OPCODES) {
            return FTError.ErrorTag.INTERP_EXECUTION_TOO_LONG;
          }
        }
if (numInstructions > 5097) {
  Debug(0, DebugTag.DBG_INTERP, TAG, String.format("ll4: %d %d", IP, codeSize));
  zp0.showLoaderZone("ZP0", this);
  zp2.showLoaderZone("ZP1", this);
}
//        showLoaderZone();
        if (IP >= codeSize) {
          if (callTop > 0) {







|







682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
          }
            /* increment instruction counter and check if we didn't */
            /* run this program for too long (e.g. infinite loops). */
          if (++ins_counter > MAX_RUNNABLE_OPCODES) {
            return FTError.ErrorTag.INTERP_EXECUTION_TOO_LONG;
          }
        }
if (numInstructions > 5100) {
  Debug(0, DebugTag.DBG_INTERP, TAG, String.format("ll4: %d %d", IP, codeSize));
  zp0.showLoaderZone("ZP0", this);
  zp2.showLoaderZone("ZP1", this);
}
//        showLoaderZone();
        if (IP >= codeSize) {
          if (callTop > 0) {