apwfreetypelib

Check-in [03db9e61be]
Login

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

Overview
Comment:fixes, new code an moving code.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:03db9e61be545a0de2476c0856d66ba732c8ba71
User & Date: arnulf 2015-01-18 15:06:28
Context
2015-01-24
17:02
fixes for op codes. check-in: 75468acc05 user: arnulf tags: trunk
2015-01-18
15:06
fixes, new code an moving code. check-in: 03db9e61be user: arnulf tags: trunk
12:57
initial version. check-in: f1dc43dee0 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to aftbase/FTCMapRec.java.

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import android.util.Log;

import org.apwtcl.apwfreetypelib.afttruetype.TTCMap12Rec;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMap13Rec;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMap14Rec;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMap4Rec;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMapRec;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTArrayUtil;

  /* ===================================================================== */
  /*    FTCMapRec                                                          */
  /*                                                                       */
  /* ===================================================================== */

public class FTCMapRec extends FTCharMapRec {
................................................................................
        cmap = null;
        if (cmap_ref != null) {
          cmap_ref.Set(cmap);
        }
        return error;
      }
      /* add it to our list of charmaps */
      face.charmaps = (FTCharMapRec[])FTArrayUtil.FT_RENEW_ARRAY(face.charmaps, "charmaps", face.getNum_charmaps(), face.getNum_charmaps() + 1);
      face.charmaps[face.getNum_charmaps()] = (FTCharMapRec)cmap;
      face.setNum_charmaps((face.getNum_faces() + 1));
      if (cmap_ref != null) {
        cmap_ref.Set(cmap);
      }
    return error;
  }
 
}







|
|
|
|







 







|









16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import android.util.Log;

import org.apwtcl.apwfreetypelib.afttruetype.TTCMap12Rec;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMap13Rec;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMap14Rec;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMap4Rec;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMapRec;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTUtil;
import org.apwtcl.apwfreetypelib.aftutil.FTUtilFlags;

  /* ===================================================================== */
  /*    FTCMapRec                                                          */
  /*                                                                       */
  /* ===================================================================== */

public class FTCMapRec extends FTCharMapRec {
................................................................................
        cmap = null;
        if (cmap_ref != null) {
          cmap_ref.Set(cmap);
        }
        return error;
      }
      /* add it to our list of charmaps */
      face.charmaps = (FTCharMapRec[])FTUtil.FT_RENEW_ARRAY(face.charmaps, FTUtilFlags.ArrayType.CHARMAPS, face.getNum_charmaps(), face.getNum_charmaps() + 1);
      face.charmaps[face.getNum_charmaps()] = (FTCharMapRec)cmap;
      face.setNum_charmaps((face.getNum_faces() + 1));
      if (cmap_ref != null) {
        cmap_ref.Set(cmap);
      }
    return error;
  }
 
}

Changes to aftbase/FTGlyphLoaderRec.java.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
...
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftbase;

import android.util.Log;

import org.apwtcl.apwfreetypelib.afttruetype.TTFaceRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTGlyphLoaderFuncs;
import org.apwtcl.apwfreetypelib.afttruetype.TTGlyphZoneRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTInterpBase;
import org.apwtcl.apwfreetypelib.aftutil.FTArrayUtil;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTMatrixRec;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTTrace;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;

  /* ===================================================================== */
  /*    FTGlyphLoaderRec                                                   */
  /*                                                                       */
  /* ===================================================================== */

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

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

  private int max_points = 0;
  private int max_contours = 0;
  private int max_subglyphs = 0;
  private boolean use_extra = false;
  private FTGlyphLoadRec base = null;
  private FTGlyphLoadRec current = null;
  private int base_idx;
  private int current_idx;

  /* ==================== FTGlyphLoaderRec ================================== */
  public FTGlyphLoaderRec() {
    oid++;
    id = oid;
    base = new FTGlyphLoadRec();
    current = new FTGlyphLoadRec();
................................................................................
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[]) FTArrayUtil.FT_RENEW_ARRAY(base.getPoints(), "FTUnitVector", 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((Flags.Curve[])FTArrayUtil.FT_RENEW_ARRAY(base.getTags(), "byte", old_max, new_max));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "after FT_RENEW_ARRAY: base.outline.tags: "+base.getTags());
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "FT_RENEW_ARRAY base.extra_points: "+base.getExtra_points()+"!use_extra: "+use_extra+"!");
        if (use_extra) {
          base.setExtra_points((FTVectorRec[])FTArrayUtil.FT_RENEW_ARRAY(base.getExtra_points(), "FTUnitVector", old_max * 2, new_max * 2));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "after FT_RENEW_ARRAY base.extra_points: "+base.getExtra_points()+"!use_extra: "+use_extra+"!");
          for (k = 0; k < old_max; k++) {
            base.getExtra_points()[new_max + k].x = base.getExtra_points()[old_max + k].x;
            base.getExtra_points()[new_max + k].y = base.getExtra_points()[old_max + k].y;
          }
          base.setExtra_points2(new FTVectorRec[new_max]);
          for (k = old_max; k < old_max * 2; k++) {
................................................................................
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[])FTArrayUtil.FT_RENEW_ARRAY(base.getContours(), "int", old_max, new_max));
        adjust = true;
        max_contours = new_max;
      }
      if (adjust) {
        GlyphLoaderAdjustPoints();
      }
      if (error != FTError.ErrorTag.ERR_OK) {







<
<
<
<
<
|
<
<
<
<
<
<












|
|
|
|
|
|
|
|







 







|


|



|







 







|







11
12
13
14
15
16
17





18






19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
...
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
...
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftbase;

import android.util.Log;






import org.apwtcl.apwfreetypelib.aftutil.*;







  /* ===================================================================== */
  /*    FTGlyphLoaderRec                                                   */
  /*                                                                       */
  /* ===================================================================== */

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;
  protected int base_idx;
  protected int current_idx;

  /* ==================== FTGlyphLoaderRec ================================== */
  public FTGlyphLoaderRec() {
    oid++;
    id = oid;
    base = new FTGlyphLoadRec();
    current = new FTGlyphLoadRec();
................................................................................
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((Flags.Curve[])FTUtil.FT_RENEW_ARRAY(base.getTags(), FTUtilFlags.ArrayType.BYTE, old_max, new_max));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "after FT_RENEW_ARRAY: base.outline.tags: "+base.getTags());
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "FT_RENEW_ARRAY base.extra_points: "+base.getExtra_points()+"!use_extra: "+use_extra+"!");
        if (use_extra) {
          base.setExtra_points((FTVectorRec[])FTUtil.FT_RENEW_ARRAY(base.getExtra_points(), FTUtilFlags.ArrayType.FT_VECTOR, old_max * 2, new_max * 2));
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "after FT_RENEW_ARRAY base.extra_points: "+base.getExtra_points()+"!use_extra: "+use_extra+"!");
          for (k = 0; k < old_max; k++) {
            base.getExtra_points()[new_max + k].x = base.getExtra_points()[old_max + k].x;
            base.getExtra_points()[new_max + k].y = base.getExtra_points()[old_max + k].y;
          }
          base.setExtra_points2(new FTVectorRec[new_max]);
          for (k = old_max; k < old_max * 2; k++) {
................................................................................
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) {
        GlyphLoaderAdjustPoints();
      }
      if (error != FTError.ErrorTag.ERR_OK) {

Changes to aftbase/FTGlyphSlotRec.java.

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
    FTDriverClassRec clazz = driver.getDriver_clazz();
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    library = driver.library;
    internal = new FTSlotInternalRec();
    if ((driver.module_clazz.module_flags & Flags.Module.DRIVER_NO_OUTLINES.getVal()) == 0L) {
      FTReference<FTGlyphLoaderRec> loader_ref = new FTReference<FTGlyphLoaderRec>();
      loader_ref.Set(internal.loader);
      switch(face.getDriver().getDriver_clazz().module_type) {
        case TT_DRIVER:
          internal.loader = new TTGlyphLoaderRec();
          error = FTGlyphLoaderRec.FTGlyphLoaderNew(loader_ref);
          break;
        default:
          return FTError.ErrorTag.INTERP_INVALID_ARGUMENT;
      }
      internal.loader = loader_ref.Get();
      if (internal.loader == null) {
        error = FTError.ErrorTag.UNEXPECTED_NULL_VALUE;
      }
    }
    if (error == FTError.ErrorTag.ERR_OK) {
      error = clazz.initSlot(this);
    }
    return error;
................................................................................

  /* =====================================================================
   * ft_glyphslot_free_bitmap
   * =====================================================================
   */
  private void ft_glyphslot_free_bitmap() {
    if ((internal != null) &&
        (internal.flags.getVal() & FTTags.GlyphFormat.OWN_BITMAP.getVal()) != 0) {
//        FT_FREE( slot.bitmap.buffer );
      internal.flags = FTTags.GlyphFormat.getTableTag(internal.flags.getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal());
    } else {
        /* assume that the bitmap buffer was stolen or not */
        /* allocated from the heap                         */
      bitmap.setBuffer(null);
    }
  }

................................................................................
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    FTDriverRec driver = face.getDriver();

    Debug(0, DebugTag.DBG_INIT, TAG, "ft_glyphslot_done");
    if (internal != null) {
      /* free glyph loader */
      if ((driver.getDriver_clazz().module_flags & Flags.Module.DRIVER_NO_OUTLINES.getVal()) == 0L) {
        internal.loader.FTGlyphLoaderDone();
        internal.loader = null;
      }
    }
    return error;
  }

  /* =====================================================================
   * FTNewGlyphSlot







|


|
<




<
|







 







|

|







 







|
|







104
105
106
107
108
109
110
111
112
113
114

115
116
117
118

119
120
121
122
123
124
125
126
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
    FTDriverClassRec clazz = driver.getDriver_clazz();
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    library = driver.library;
    internal = new FTSlotInternalRec();
    if ((driver.module_clazz.module_flags & Flags.Module.DRIVER_NO_OUTLINES.getVal()) == 0L) {
      FTReference<FTGlyphLoaderRec> loader_ref = new FTReference<FTGlyphLoaderRec>();
      loader_ref.Set(internal.getLoader());
      switch(face.getDriver().getDriver_clazz().module_type) {
        case TT_DRIVER:
          internal.setLoader(new TTGlyphLoaderRec());

          break;
        default:
          return FTError.ErrorTag.INTERP_INVALID_ARGUMENT;
      }

      if (internal.getLoader() == null) {
        error = FTError.ErrorTag.UNEXPECTED_NULL_VALUE;
      }
    }
    if (error == FTError.ErrorTag.ERR_OK) {
      error = clazz.initSlot(this);
    }
    return error;
................................................................................

  /* =====================================================================
   * ft_glyphslot_free_bitmap
   * =====================================================================
   */
  private void ft_glyphslot_free_bitmap() {
    if ((internal != null) &&
        (internal.getFlags().getVal() & FTTags.GlyphFormat.OWN_BITMAP.getVal()) != 0) {
//        FT_FREE( slot.bitmap.buffer );
      internal.setFlags(FTTags.GlyphFormat.getTableTag(internal.getFlags().getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal()));
    } else {
        /* assume that the bitmap buffer was stolen or not */
        /* allocated from the heap                         */
      bitmap.setBuffer(null);
    }
  }

................................................................................
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    FTDriverRec driver = face.getDriver();

    Debug(0, DebugTag.DBG_INIT, TAG, "ft_glyphslot_done");
    if (internal != null) {
      /* free glyph loader */
      if ((driver.getDriver_clazz().module_flags & Flags.Module.DRIVER_NO_OUTLINES.getVal()) == 0L) {
        internal.getLoader().FTGlyphLoaderDone();
        internal.setLoader(null);
      }
    }
    return error;
  }

  /* =====================================================================
   * FTNewGlyphSlot

Changes to aftbase/FTSlotInternalRec.java.

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86


87
88
89



90

























































  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTMatrixRec;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;

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

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

    public final static int FT_GLYPH_OWN_BITMAP  = 0x1;

    public FTGlyphLoaderRec loader = null;
    public FTTags.GlyphFormat flags = FTTags.GlyphFormat.NONE;
    public boolean glyph_transformed = false;
    public FTMatrixRec glyph_matrix = null;
    public FTVectorRec glyph_delta = null;
    public Object[] glyph_hints = null;

    /* ==================== FTSlotInternalRec ================================== */
    public FTSlotInternalRec() {
      oid++;
      id = oid;
    }
    
    /* ==================== mySelf ================================== */
    public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
    /* ==================== toString ===================================== */
    public String toString() {
      return mySelf()+"!";
    }

    /* ==================== toDebugString ===================================== */
    public String toDebugString() {
      StringBuffer str = new StringBuffer(mySelf()+"\n");


      return str.toString();
    }
 



}
































































|

|
|

<
<
|
|
|
|
|
|

|
|
|
|
|

|
|



|
|



|
|
|
>
>
|
|
|
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
47
48
49
50
51
52
53
54
55
56
57
58


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTMatrixRec;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;

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

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



  private FTGlyphLoaderRec loader = null;
  private FTTags.GlyphFormat flags = FTTags.GlyphFormat.NONE;
  private boolean glyph_transformed = false;
  private FTMatrixRec glyph_matrix = null;
  private FTVectorRec glyph_delta = null;
  private Object[] glyph_hints = null;

  /* ==================== FTSlotInternalRec ================================== */
  public FTSlotInternalRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
  /* ==================== toString ===================================== */
  public String toString() {
      return mySelf()+"!";
    }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("..flags: "+flags+'\n');
    str.append("..glyph_transformed: "+glyph_transformed+'\n');
    return str.toString();
  }

  /* ==================== getLoader ================================== */
  public FTGlyphLoaderRec getLoader() {
    return loader;
  }

  /* ==================== setLoader ================================== */
  public void setLoader(FTGlyphLoaderRec loader) {
    this.loader = loader;
  }

  /* ==================== getFlags ================================== */
  public FTTags.GlyphFormat getFlags() {
    return flags;
  }

  /* ==================== setFlags ================================== */
  public void setFlags(FTTags.GlyphFormat flags) {
    this.flags = flags;
  }

  /* ==================== isGlyph_transformed ================================== */
  public boolean isGlyph_transformed() {
    return glyph_transformed;
  }

  /* ==================== setGlyph_transformed ================================== */
  public void setGlyph_transformed(boolean glyph_transformed) {
    this.glyph_transformed = glyph_transformed;
  }

  /* ==================== getGlyph_matrix ================================== */
  public FTMatrixRec getGlyph_matrix() {
    return glyph_matrix;
  }

  /* ==================== setGlyph_matrix ================================== */
  public void setGlyph_matrix(FTMatrixRec glyph_matrix) {
    this.glyph_matrix = glyph_matrix;
  }

  /* ==================== getGlyph_delta ================================== */
  public FTVectorRec getGlyph_delta() {
    return glyph_delta;
  }

  /* ==================== setGlyph_delta ================================== */
  public void setGlyph_delta(FTVectorRec glyph_delta) {
    this.glyph_delta = glyph_delta;
  }

  /* ==================== getGlyph_hints ================================== */
  public Object[] getGlyph_hints() {
    return glyph_hints;
  }

  /* ==================== setGlyph_hints ================================== */
  public void setGlyph_hints(Object[] glyph_hints) {
    this.glyph_hints = glyph_hints;
  }

}

Changes to aftraster/FTRaster1RendererClass.java.

217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
...
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
    height = (int)((cbox.getyMax() - cbox.getyMin()) >> 6);
    if (width > 0xFFFF || height > 0xFFFF) {
      error = FTError.ErrorTag.GLYPH_INVALID_ARGUMENT;
      return error;
    }
    bitmap = slot.getBitmap();
      /* release old bitmap buffer */
    if ((slot.getInternal().flags.getVal() & FTTags.GlyphFormat.OWN_BITMAP.getVal()) != 0) {
//        FT_FREE(bitmap.buffer);
      slot.getInternal().flags = FTTags.GlyphFormat.getTableTag(slot.getInternal().flags.getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal());
    }
      /* allocate new one, depends on pixel format */
    if ((mode & FTTags.RenderMode.MONO.getVal()) == 0) {
        /* we pad to 32 bits, only for backwards compatibility with FT 1.x */
      pitch = FTCalc.FT_PAD_CEIL(width, 4);
      bitmap.setPixel_mode(FTTags.PixelMode.GRAY);
      bitmap.setNum_grays(256);
................................................................................
      bitmap.setPixel_mode(FTTags.PixelMode.MONO);
    }
    bitmap.setWidth(width);
    bitmap.setRows(height);
    bitmap.setPitch(pitch);
    // realloc cout = pitch, item_size ) height
    bitmap.setBuffer(new byte[pitch * height]);
    slot.getInternal().flags = FTTags.GlyphFormat.getTableTag(slot.getInternal().flags.getVal() | FTTags.GlyphFormat.OWN_BITMAP.getVal());
    Debug(0, DebugTag.DBG_INIT, TAG, String.format("cbox_xMin: %d %dn", -cbox.getxMin(), -cbox.getyMin()));
      /* translate outline to render it into the bitmap */
    outline.OutlineTranslate(-cbox.getxMin(), -cbox.getyMin());
      /* set up parameters */
    params.target = bitmap;
    params.source = outline;
    params.flags  = 0;







|

|







 







|







217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
...
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
    height = (int)((cbox.getyMax() - cbox.getyMin()) >> 6);
    if (width > 0xFFFF || height > 0xFFFF) {
      error = FTError.ErrorTag.GLYPH_INVALID_ARGUMENT;
      return error;
    }
    bitmap = slot.getBitmap();
      /* release old bitmap buffer */
    if ((slot.getInternal().getFlags().getVal() & FTTags.GlyphFormat.OWN_BITMAP.getVal()) != 0) {
//        FT_FREE(bitmap.buffer);
      slot.getInternal().setFlags(FTTags.GlyphFormat.getTableTag(slot.getInternal().getFlags().getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal()));
    }
      /* allocate new one, depends on pixel format */
    if ((mode & FTTags.RenderMode.MONO.getVal()) == 0) {
        /* we pad to 32 bits, only for backwards compatibility with FT 1.x */
      pitch = FTCalc.FT_PAD_CEIL(width, 4);
      bitmap.setPixel_mode(FTTags.PixelMode.GRAY);
      bitmap.setNum_grays(256);
................................................................................
      bitmap.setPixel_mode(FTTags.PixelMode.MONO);
    }
    bitmap.setWidth(width);
    bitmap.setRows(height);
    bitmap.setPitch(pitch);
    // realloc cout = pitch, item_size ) height
    bitmap.setBuffer(new byte[pitch * height]);
    slot.getInternal().setFlags(FTTags.GlyphFormat.getTableTag(slot.getInternal().getFlags().getVal() | FTTags.GlyphFormat.OWN_BITMAP.getVal()));
    Debug(0, DebugTag.DBG_INIT, TAG, String.format("cbox_xMin: %d %dn", -cbox.getxMin(), -cbox.getyMin()));
      /* translate outline to render it into the bitmap */
    outline.OutlineTranslate(-cbox.getxMin(), -cbox.getyMin());
      /* set up parameters */
    params.target = bitmap;
    params.source = outline;
    params.flags  = 0;

Changes to aftraster/FTSmoothRendererClass.java.

130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
...
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
      error = FTError.ErrorTag.RENDER_RASTER_OVERFLOW;
      return error;
    }
    bitmap = slot.getBitmap();
    width_org = width;
    height_org = height;
      /* release old bitmap buffer */
    if ((slot.getInternal().flags.getVal() & FTTags.GlyphFormat.OWN_BITMAP.getVal()) != 0) {
//        FT_FREE(bitmap.buffer);
      slot.getInternal().flags = FTTags.GlyphFormat.getTableTag(slot.getInternal().flags.getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal());
    }
      /* allocate new one */
    pitch = width;
    Debug(0, DebugTag.DBG_INIT, TAG, String.format("ft_smooth_render_generic: pitch: %d, width: %d, height: %d", pitch, width, height));
    if (hmul) {
      width = width * 3;
      pitch = FTCalc.FT_PAD_CEIL(width, 4);
................................................................................
    bitmap.setPitch(pitch);
      /* translate outline to render it into the bitmap */
    slot.getOutline().OutlineTranslate(-x_shift, -y_shift);
    have_outline_shifted = true;
    bitmap.setBuffer(new byte[pitch * height]);

    have_buffer = true;
    slot.getInternal().flags = FTTags.GlyphFormat.getTableTag(slot.getInternal().flags.getVal() | FTTags.GlyphFormat.OWN_BITMAP.getVal());
      /* set up parameters */
    params.target = bitmap;
    params.source = slot.getOutline();
    params.flags = FTRasterParams.FT_RASTER_FLAG_AA;
      /* render outline into bitmap */
    error = render.rasterRender(render.raster, params);
    if (error != FTError.ErrorTag.ERR_OK) {
................................................................................
        slot.getOutline().OutlineTranslate(x_shift, y_shift);
      }
      if (have_translated_origin) {
        slot.getOutline().OutlineTranslate(-origin.x, -origin.y);
      }
      if (have_buffer) {
//          FT_FREE( bitmap.buffer );
        slot.getInternal().flags = FTTags.GlyphFormat.getTableTag(slot.getInternal().flags.getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal());
      }
      return error;
    }
      /* expand it horizontally */
    if (hmul) {
//        FT_Byte*  line = bitmap.buffer;
      int lineIdx = 0;
................................................................................
      slot.getOutline().OutlineTranslate(x_shift, y_shift);
    }
    if (have_translated_origin) {
      slot.getOutline().OutlineTranslate(-origin.x, -origin.y);
    }
    if (have_buffer) {
//        FT_FREE( bitmap.buffer );
      slot.getInternal().flags = FTTags.GlyphFormat.getTableTag(slot.getInternal().flags.getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal());
    }
    return error;
  }

  /* =====================================================================
   * ft_smooth_render
   * =====================================================================







|

|







 







|







 







|







 







|







130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
...
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
      error = FTError.ErrorTag.RENDER_RASTER_OVERFLOW;
      return error;
    }
    bitmap = slot.getBitmap();
    width_org = width;
    height_org = height;
      /* release old bitmap buffer */
    if ((slot.getInternal().getFlags().getVal() & FTTags.GlyphFormat.OWN_BITMAP.getVal()) != 0) {
//        FT_FREE(bitmap.buffer);
      slot.getInternal().setFlags(FTTags.GlyphFormat.getTableTag(slot.getInternal().getFlags().getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal()));
    }
      /* allocate new one */
    pitch = width;
    Debug(0, DebugTag.DBG_INIT, TAG, String.format("ft_smooth_render_generic: pitch: %d, width: %d, height: %d", pitch, width, height));
    if (hmul) {
      width = width * 3;
      pitch = FTCalc.FT_PAD_CEIL(width, 4);
................................................................................
    bitmap.setPitch(pitch);
      /* translate outline to render it into the bitmap */
    slot.getOutline().OutlineTranslate(-x_shift, -y_shift);
    have_outline_shifted = true;
    bitmap.setBuffer(new byte[pitch * height]);

    have_buffer = true;
    slot.getInternal().setFlags(FTTags.GlyphFormat.getTableTag(slot.getInternal().getFlags().getVal() | FTTags.GlyphFormat.OWN_BITMAP.getVal()));
      /* set up parameters */
    params.target = bitmap;
    params.source = slot.getOutline();
    params.flags = FTRasterParams.FT_RASTER_FLAG_AA;
      /* render outline into bitmap */
    error = render.rasterRender(render.raster, params);
    if (error != FTError.ErrorTag.ERR_OK) {
................................................................................
        slot.getOutline().OutlineTranslate(x_shift, y_shift);
      }
      if (have_translated_origin) {
        slot.getOutline().OutlineTranslate(-origin.x, -origin.y);
      }
      if (have_buffer) {
//          FT_FREE( bitmap.buffer );
        slot.getInternal().setFlags(FTTags.GlyphFormat.getTableTag(slot.getInternal().getFlags().getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal()));
      }
      return error;
    }
      /* expand it horizontally */
    if (hmul) {
//        FT_Byte*  line = bitmap.buffer;
      int lineIdx = 0;
................................................................................
      slot.getOutline().OutlineTranslate(x_shift, y_shift);
    }
    if (have_translated_origin) {
      slot.getOutline().OutlineTranslate(-origin.x, -origin.y);
    }
    if (have_buffer) {
//        FT_FREE( bitmap.buffer );
      slot.getInternal().setFlags(FTTags.GlyphFormat.getTableTag(slot.getInternal().getFlags().getVal() & ~FTTags.GlyphFormat.OWN_BITMAP.getVal()));
    }
    return error;
  }

  /* =====================================================================
   * ft_smooth_render
   * =====================================================================

Changes to aftsfnt/TTLoad.java.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftsfnt;

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.*;
import org.apwtcl.apwfreetypelib.afttruetype.*;
import org.apwtcl.apwfreetypelib.aftutil.*;

/* ===================================================================== */
/*    TTLoad                                 */
/*                                     */
/* ===================================================================== */







<







11
12
13
14
15
16
17

18
19
20
21
22
23
24
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftsfnt;

import android.util.Log;


import org.apwtcl.apwfreetypelib.afttruetype.*;
import org.apwtcl.apwfreetypelib.aftutil.*;

/* ===================================================================== */
/*    TTLoad                                 */
/*                                     */
/* ===================================================================== */

Changes to afttruetype/TTCMap0Class.java.

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
   */


import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTCMapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTTags;
import org.apwtcl.apwfreetypelib.aftbase.FTUtil;
import org.apwtcl.apwfreetypelib.aftbase.FTValidatorRec;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTStreamRec;

public class TTCMap0Class extends TTCMapClassRec {
  private static int oid = 0;








<
<







32
33
34
35
36
37
38


39
40
41
42
43
44
45
   */


import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTCMapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTTags;


import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTStreamRec;

public class TTCMap0Class extends TTCMapClassRec {
  private static int oid = 0;

Changes to afttruetype/TTCMap4Class.java.

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTCMapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTTags;
import org.apwtcl.apwfreetypelib.aftbase.FTUtil;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTStreamRec;

public class TTCMap4Class extends TTCMapClassRec {
  private static int oid = 0;







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTCMapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTTags;
import org.apwtcl.apwfreetypelib.aftutil.FTUtil;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTStreamRec;

public class TTCMap4Class extends TTCMapClassRec {
  private static int oid = 0;

Changes to afttruetype/TTDriverClass.java.

247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
   *
   * =====================================================================
   */
  private FTError.ErrorTag tt_slot_init(FTGlyphSlotRec slot) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

Debug(0, DebugTag.DBG_INIT, TAG, "tt_slot_init");
    error = slot.getInternal().loader.FTGlyphLoaderCreateExtra();
    return error;
  }

  /* =====================================================================
   * tt_glyph_load
   *
   * <Description>







|







247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
   *
   * =====================================================================
   */
  private FTError.ErrorTag tt_slot_init(FTGlyphSlotRec slot) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

Debug(0, DebugTag.DBG_INIT, TAG, "tt_slot_init");
    error = slot.getInternal().getLoader().FTGlyphLoaderCreateExtra();
    return error;
  }

  /* =====================================================================
   * tt_glyph_load
   *
   * <Description>

Changes to afttruetype/TTGlyphLoaderRec.java.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78



79
80
81
82
83
84

85
86
87
88
89
90
91
92
93
94
95

96


97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
114
115


116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

138
139
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164



165
166
167
168
169
170

171
172

173
174
175
176
177
178
179
180
181
182

183
184
185
186


187
188
189
190
191


192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210


211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231

232
233
234
235
236
237
238
239
240
241
242
243


244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326


327
328

329
330
331
332
333
334
335
 */

package org.apwtcl.apwfreetypelib.afttruetype;

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTGlyphLoaderRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTFaceRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTGlyphLoaderFuncs;
import org.apwtcl.apwfreetypelib.afttruetype.TTGlyphZoneRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTInterpBase;
import org.apwtcl.apwfreetypelib.aftutil.FTArrayUtil;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTMatrixRec;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTTrace;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;

  /* ===================================================================== */
  /*    TTGlyphLoaderRec                                                   */
  /*                                                                       */
  /* ===================================================================== */

public class TTGlyphLoaderRec extends FTGlyphLoaderRec {
................................................................................
  }

  /* =====================================================================
   * tt_load_simple_glyph
   * =====================================================================
   */
  public FTError.ErrorTag tt_load_simple_glyph(TTLoaderRec loader) {
    System.out.println("tt_load_simple_glyph");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
/*
    long pIdx = loader.cursor;
    long limit = loader.limit;
    FTGlyphLoaderRec gloader = loader.gloader;
    int n_contours = loader.n_contours;
    TTFaceRec face = (TTFaceRec)loader.face;



    short n_ins;
    int n_points;
    byte flagIdx;
    byte flagLimit;
    byte c;
    byte count;

    int vecIdx;
    int vecLimit;
    long x;
    short contourIdx;
    short contourLimit;
    short prev_cont;
    int xy_size = 0;
    FTStreamRec stream = loader.stream;
    if (FTGlyphLoaderRec.glyph_debug > 2) {
      System.out.println(String.format("loader.n_contours: %d "+(loader.gloader == null ? "<null>" : loader.gloader.current.outline), loader.n_contours));
    }




      /* check that we can add the contours to the glyph */
/*
    error = FTGlyphLoaderRec.FT_GLYPHLOADER_CHECK_POINTS(gloader, 0, n_contours);
    if (error != 0) {
      return error;
    }
      /* reading the contours' endpoints & number of points */

/*    contourIdx = 0;
    contourLimit = (short)n_contours;

      /* check space for contours array + instructions count */
/*
    if (n_contours >= 0xFFF || pIdx + (n_contours + 1) * 2 > limit) {
      error = FT_Error.GLYPH_INVALID_OUTLINE;
      return error;
    }
    long start_pos = stream.pos();
    if (FTGlyphLoaderRec.glyph_debug > 2) {
      System.out.println(String.format("start: %d start_pos: %d\n",  0, start_pos));


    }
    prev_cont = stream.readShort(stream);
    if (n_contours > 0) {
      gloader.current.outline.contours[0] = prev_cont;
    }
    if (prev_cont < 0) {
      error = FT_Error.GLYPH_INVALID_OUTLINE;
      return error;
    }
    for (contourIdx = 1; contourIdx < contourLimit; contourIdx++) {
      gloader.current.outline.contours[contourIdx] = stream.readShort(stream);
      if (gloader.current.outline.contours[contourIdx] <= prev_cont) {
          /* unordered contours: this is invalid */
/*
        error = FT_Error.GLYPH_INVALID_OUTLINE;
        return error;
      }
      prev_cont = gloader.current.outline.contours[contourIdx];
    }
    n_points = 0;
    if (n_contours > 0) {
      n_points = gloader.current.outline.contours[contourIdx - 1] + 1;

      if (n_points < 0) {
        error = FT_Error.GLYPH_INVALID_OUTLINE;
        return error;
      }
    }
    if (FTGlyphLoaderRec.glyph_debug > 2) {
      System.out.println(String.format("start2: offset %d pos: %d\n",  stream.pos() - start_pos, stream.pos()));
      for(int i = 0; i < contourLimit; i++) {
        System.out.println(String.format("i: %d cont: %d", i, gloader.current.outline.contours[i]));

      }
    }
      /* note that we will add four phantom points later */
/*
    error = FTGlyphLoaderRec.FT_GLYPHLOADER_CHECK_POINTS(gloader, n_points + 4, 0);
    if (error != 0) {
      return error;
    }
      /* reading the bytecode instructions */
/*
    loader.glyph.control_len = 0;
    loader.glyph.control_data = 0;
    if (pIdx + 2 > limit) {
      error = FT_Error.GLYPH_INVALID_OUTLINE;
      return error;
    }
    if (FTGlyphLoaderRec.glyph_debug > 2) {
      System.out.println(String.format("start3: offset: %d pos: %d\n",  stream.pos() - start_pos, stream.pos()));



    }
    n_ins = stream.readShort(stream);
    if (FTGlyphLoaderRec.glyph_debug > 2) {
      System.out.println(String.format("start4: offset: %d pos: %d\n",  stream.pos() - start_pos, stream.pos()));
    }
    pIdx += 2;

    FT_Trace.Trace(7, TAG, String.format("  Instructions size: %d", n_ins));
    if (n_ins > face.max_profile.maxSizeOfInstructions) {

      FT_Trace.Trace(7, TAG, String.format("tt_load_simple_glyph: too many instructions (%d)", n_ins));
      error = FT_Error.GLYPH_TOO_MANY_HINTS;
      return error;
    }
    if ((limit - pIdx) < n_ins) {
      FT_Trace.Trace(7, TAG, "tt_load_simple_glyph: instruction count mismatch");
      error = FT_Error.GLYPH_TOO_MANY_HINTS;
      return error;
    }
    if ((loader.load_flags & FTGlyphLoaderFlags.FT_LOAD_NO_AUTOHINT) == 0) {

      int i;

      loader.glyph.control_len = n_ins;
      loader.glyph.control_data = loader.exec.glyphIns;


      for (i = 0; i < n_ins; i++) {
        loader.exec.glyphIns[i] = (byte)stream.readByte(stream);
        if (FTGlyphLoaderRec.glyph_debug > 2) {
          System.out.println(String.format("ins: %d 0x%02x\n", i, loader.exec.glyphIns[i] & 0xFF));
        }


      }
//        FT_MEM_COPY( loader.exec.glyphIns, p, (FT_Long)n_ins );
    }
    pIdx += n_ins;
    if (FTGlyphLoaderRec.glyph_debug > 2) {
      System.out.println(String.format("start5: offset: %d pos: %d\n",  stream.pos() - start_pos, stream.pos()));
    }
      /* reading the point tags */
/*
    flagIdx = 0;
    flagLimit = (byte)n_points;
    if (FTGlyphLoaderRec.glyph_debug > 2) {
      System.out.println(String.format("tags: %d %d flagIdx: %d, flagLimit: %d\n",  stream.pos() - start_pos, stream.pos(), flagIdx, flagLimit));
    }
//      FT_ASSERT(flag != NULL);
    while (flagIdx < flagLimit) {
      if (pIdx + 1 > limit) {
        error = FT_Error.GLYPH_INVALID_OUTLINE;
        return error;


      }
      c = stream.readByte(stream);
      gloader.current.outline.tags[flagIdx++] = (byte)(c & 0xFF);
      if ((c & 8) != 0) {
        if (pIdx + 1 > limit) {
          error = FT_Error.GLYPH_INVALID_OUTLINE;
          return error;
        }
        count = (byte)stream.readByte(stream);
        if (flagIdx + (int)count > flagLimit) {
          error = FT_Error.GLYPH_INVALID_OUTLINE;
          return error;
        }
        for (; count > 0; count--) {
          gloader.current.outline.tags[flagIdx++] = (byte)(c & 0xFF);
        }
      }
    }
    if (FTGlyphLoaderRec.glyph_debug > 2) {
      for(int t = 0; t < flagIdx; t++) {
        System.out.println(String.format("Tag: t: %d 0x%02x", t, gloader.current.outline.tags[t] % 0xFF));

      }
      System.out.println(String.format("x coords: %d %d\n",  stream.pos() - start_pos, stream.pos()));
    }
      /* reading the X coordinates */
/*
    vecIdx = 0;
    vecLimit = n_points;
    flagIdx = 0;
    x = 0;
    if (pIdx + xy_size > limit) {
      error = FT_Error.GLYPH_INVALID_OUTLINE;
      return error;


    }
    for (vecIdx = 0; vecIdx < vecLimit; vecIdx++, flagIdx++) {
      long y = 0L;
      byte f = gloader.current.outline.tags[flagIdx];
      if (FTGlyphLoaderRec.glyph_debug > 2) {
        System.out.println(String.format("x pos: %d %d\n",  stream.pos() - start_pos, stream.pos()));
      }

      if ((f & 2) != 0) {
        if (pIdx + 1 > limit) {
          error = FT_Error.GLYPH_INVALID_OUTLINE;
          return error;
        }
        y = (long)stream.readByte(stream) & 0xFF;
        pIdx += 1;
        if ((f & 16) == 0) {
          y = -y;
        }
      } else {
        if ((f & 16) == 0) {
          if (pIdx + 2 > limit) {
            error = FT_Error.GLYPH_INVALID_OUTLINE;
            return error;
          }
          y = (long)stream.readShort(stream);
          pIdx += 2;
        }
      }
      x += y;
      gloader.current.outline.points[vecIdx].x = x;
      if (FTGlyphLoaderRec.glyph_debug > 2) {
        System.out.println(String.format("load coords i: %d x: %d", vecIdx, x));
      }
        /* the cast is for stupid compilers */
/*
      gloader.current.outline.tags[flagIdx] = (byte)(f & ~(2 | 16));
    }
      /* reading the Y coordinates */
/*
    vecIdx = 0;
    vecLimit = n_points;
    flagIdx = 0;;
    x = 0;
    for (vecIdx = 0; vecIdx < vecLimit; vecIdx++, flagIdx++) {
      long y = 0L;
      byte f = gloader.current.outline.tags[flagIdx];

      if (FTGlyphLoaderRec.glyph_debug > 2) {
        System.out.println(String.format("vecIdx: %d %d f: 0x%02x", vecIdx, flagIdx, f));
      }
      if ((f & 4) != 0) {
        if (pIdx + 1 > limit) {
          error = FT_Error.GLYPH_INVALID_OUTLINE;
          return error;
        }
        y = (long)stream.readByte(stream) & 0xFF;
        pIdx += 1;
        if ((f & 32) == 0) {
          y = -y;
        }
      } else {
        if ((f & 32) == 0) {
          if (pIdx + 2 > limit) {
            error = FT_Error.GLYPH_INVALID_OUTLINE;
            return error;
          }
          y = (long)stream.readShort(stream);
          pIdx += 2;
        }
      }
      x += y;
      gloader.current.outline.points[vecIdx].y = x;
      if (FTGlyphLoaderRec.glyph_debug > 2) {
        System.out.println(String.format("load coords i: %d y: %d", vecIdx, x));
      }
        /* the cast is for stupid compilers */
/*
      gloader.current.outline.tags[flagIdx] = (byte)(f & FT_CurveTags.FT_CURVE_TAG_ON);
    }
    gloader.current.outline.n_points = (short)n_points;
    gloader.current.outline.n_contours = (short) n_contours;
    loader.cursor = pIdx;
    if (FTGlyphLoaderRec.glyph_debug > 2) {


      for (int i = 0; i < n_points; i++) {
        System.out.println(String.format("point i:%d  %d %d", i, gloader.current.outline.points[i].x, gloader.current.outline.points[i].y));

      }
    }
*/
    return error;
  }

}







<
<
<
<
<
|
|

<
<

<







 







|

<
<
<
<
|
|
>
>
>
|

|
<
<
<
>
|
|
<
<
<
<
<
<
<
<
|
>

>
>

<
|
|


|
<
<
<
>

<
<
<
<
|
<
<
<
>
>

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


<
>

|



<
<
|
<
>
|
|

<
|
|


<
<
<
<
<
<
<
|
<
<
>
>
>
|
<
<
<
<
<
>
|
<
>
|
|


<
<
<
<
<
<
>


<
<
>
>

<
<
<
<
>
>



<
<
<
|
|
<
|
|
<
<
<
<
|
<
<
<
>
>
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
>
|
<
|
|
<
<
|
<
<
<
<
<
>
>

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
>
|
<
>
|
<
<




12
13
14
15
16
17
18





19
20
21


22

23
24
25
26
27
28
29
..
56
57
58
59
60
61
62
63
64




65
66
67
68
69
70
71
72



73
74
75








76
77
78
79
80
81

82
83
84
85
86



87
88




89



90
91
92


















93
94

95
96
97
98
99
100


101

102
103
104
105

106
107
108
109







110


111
112
113
114





115
116

117
118
119
120
121






122
123
124


125
126
127




128
129
130
131
132



133
134

135
136




137



138
139
140


















141

142
143

144
145


146





147
148
149


















































































150
151
152

153
154


155
156
157
158
 */

package org.apwtcl.apwfreetypelib.afttruetype;

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTGlyphLoaderRec;





import org.apwtcl.apwfreetypelib.aftbase.Flags;
import org.apwtcl.apwfreetypelib.aftttinterpreter.TTOpCode;
import org.apwtcl.apwfreetypelib.aftutil.FTError;


import org.apwtcl.apwfreetypelib.aftutil.FTTrace;


  /* ===================================================================== */
  /*    TTGlyphLoaderRec                                                   */
  /*                                                                       */
  /* ===================================================================== */

public class TTGlyphLoaderRec extends FTGlyphLoaderRec {
................................................................................
  }

  /* =====================================================================
   * tt_load_simple_glyph
   * =====================================================================
   */
  public FTError.ErrorTag tt_load_simple_glyph(TTLoaderRec loader) {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tt_load_simple_glyph");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;




    int n_contours = loader.getN_contours();
    TTFaceRec ttface = (TTFaceRec)loader.getFace();
    TTGlyphSimpleRec ttglyph;
    int contour_idx;
    int contour_limit;
    int n_ins;
    int n_points;
    int flag_idx;



    int flag_limit;
    int vec_idx;
    int vec_limit;









Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("loader.n_contours: %d ", loader.getN_contours()));

    ttglyph = (TTGlyphSimpleRec)ttface.getGlyf_table().getGlyphs()[loader.getGlyph_index()];

      /* check that we can add the contours to the glyph */

    error = FT_GLYPHLOADER_CHECK_POINTS(0, n_contours);
    if (error != FTError.ErrorTag.ERR_OK) {
      return error;
    }
      /* loading the contours' endpoints & number of points */



    contour_limit = n_contours;
      /* check space for contours array + instructions count */








    for (contour_idx = 0; contour_idx < contour_limit; contour_idx++) {
      current.getContours()[contour_idx] = ttglyph.getContours()[contour_idx];
    }


















    n_points = 0;
    if (n_contours > 0) {

      n_points = current.getContours()[contour_idx - 1] + 1;
      if (n_points < 0) {
        error = FTError.ErrorTag.GLYPH_INVALID_OUTLINE;
        return error;
      }
    }


    for(int i = 0; i < contour_limit; i++) {

Debug(9, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("i: %d contour: %d", i, current.getContours()[i]));
    }

      /* note that we will add four phantom points later */

    error = FT_GLYPHLOADER_CHECK_POINTS(n_points + 4, 0);
    if (error != FTError.ErrorTag.ERR_OK) {
      return error;
    }










      /* loading the bytecode instructions */
    loader.getGlyph().setControl_len(0);
    loader.getGlyph().setControl_data(null);






    n_ins = ttglyph.getInstructions_length();
    FTTrace.Trace(7, TAG, String.format("  Instructions size: %d", n_ins));

    if (n_ins > ttface.getMax_profile().getMaxSizeOfInstructions()) {
      FTTrace.Trace(7, TAG, String.format("tt_load_simple_glyph: too many instructions (%d)", n_ins));
      error = FTError.ErrorTag.GLYPH_TOO_MANY_HINTS;
      return error;
    }






    if ((loader.getLoad_flags().getVal() & Flags.Load.NO_AUTOHINT.getVal()) == 0) {
      int i;



      loader.getGlyph().setControl_len(n_ins);
      loader.getGlyph().setControl_data(loader.getExec().glyphIns);
      for (i = 0; i < n_ins; i++) {




        loader.getExec().glyphIns[i] = TTOpCode.OpCode.getTableTag(ttglyph.getInstructions()[i]);
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("ins: %d ", i)+loader.getExec().glyphIns[i]);
      }
//        FT_MEM_COPY( loader.exec.glyphIns, p, (FT_Long)n_ins );
    }




      /* loading the point tags */

    flag_idx = 0;
    flag_limit = n_points;




    while (flag_idx < flag_limit) {



      current.getTags()[flag_idx++] = Flags.Curve.getTableTag(ttglyph.getTags()[flag_idx]);
      flag_idx++;
    }


















for(int t = 0; t < flag_idx; t++) {

Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("Tag: t: %d: ", t)+current.getTags()[t]);
}


      /* loading the X and y coordinates */


    vec_limit = n_points;





    for (vec_idx = 0; vec_idx < vec_limit; vec_idx++) {
      current.getPoints()[vec_idx] = ttglyph.getPoints()[vec_idx];
    }


















































































    current.setN_points(n_points);
    current.setN_contours(n_contours);
for (int i = 0; i < n_points; i++) {

Debug(0, DebugTag.DBG_LOAD_FACE, TAG, String.format("point i:%d  %d %d", i, current.getPoints()[i].x, current.getPoints()[i].y));
}


    return error;
  }

}

Changes to afttruetype/TTLoaderRec.java.

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
...
396
397
398
399
400
401
402
403
404
405
406

407
408
409
410
411
412


413
414
415
416
417
418
419
...
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785

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

  private FTFaceRec face = null;
  private FTSizeRec size = null;
  private FTGlyphSlotRec glyph = null;
  private FTGlyphLoaderRec gloader = null;
  private Flags.Load load_flags = Flags.Load.DEFAULT;
  private int glyph_index = 0;
  private FTStreamRec stream = null;
  private int byte_len = 0;
  private int n_contours = 0;
  private FTBBoxRec bbox = null;
  private int left_bearing = 0;
................................................................................
    return str.toString();
  }

  /* =====================================================================
   * tt_loader_init
   * =====================================================================
   */
  public FTError.ErrorTag tt_loader_init(TTSizeRec size, FTGlyphSlotRec glyph,
          Flags.Load load_flags, boolean glyf_table_only) {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tt_loader_init");
    TTFaceRec face;
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    boolean pedantic = (load_flags.getVal() & Flags.Load.PEDANTIC.getVal()) != 0;

    face = (TTFaceRec)glyph.getFace();
    /* load execution context */
    if ((load_flags.getVal() & Flags.Load.NO_HINTING.getVal()) == 0 && !glyf_table_only) {
      TTExecContextRec exec;
      boolean grayscale;
      boolean reexecute = false;

Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "fill TTSizeRec\n");
................................................................................
        if (error != FTError.ErrorTag.ERR_OK) {
          return error;
        }
      }
      /* query new execution context */

      exec = size.isDebug() ? size.getContext()
                         : ((TTDriverRec)face.getDriver()).context;
      if (exec == null) {
        return FTError.ErrorTag.GLYPH_COULD_NOT_FIND_CONTEXT;
      }
      grayscale = (((load_flags.getVal() >> 16) & 15) != FTTags.RenderMode.MONO.getVal());
      FTReference<TTExecContextRec> exec_ref = new FTReference<TTExecContextRec>();
      exec_ref.Set(exec);
      exec.TTLoadContext(face, size);
      exec = exec_ref.Get();
      {
        /* a change from mono to grayscale rendering (and vice versa) */
        /* requires a re-execution of the CVT program                 */
        if (grayscale != exec.grayscale) {
          FTTrace.Trace(7, TAG, "tt_loader_init: grayscale change, re-executing `prep' table");
          exec.grayscale = grayscale;
................................................................................
          reexecute = true;
        }
      }
      if (reexecute) {
        int i;

        for (i = 0; i < size.getCvt_size(); i++) {
          size.getCvt()[i] = TTUtil.FTMulFix(face.getCvt_table().getCvtValue(i), size.getTtmetrics().getScale());
        }
        size.tt_size_run_prep(pedantic);
      }
      /* see whether the cvt program has disabled hinting */
      if ((exec.graphics_state.instruct_control & 1) != 0) {
        load_flags = Flags.Load.getTableTag(load_flags.getVal() | Flags.Load.NO_HINTING.getVal());
      }
................................................................................
    }
    /* seek to the beginning of the glyph table -- for Type 42 fonts     */
    /* the table might be accessed from a Postscript stream or something */
    /* else...                                                           */
    {
      FTReference<Integer> length_ref = new FTReference<Integer>();
      length_ref.Set(new Integer(0));
      error = face.gotoTable(TTTags.Table.glyf, face.getStream(), length_ref);

      if (error == FTError.ErrorTag.GLYPH_TABLE_MISSING) {
        this.glyf_offset = 0;
      } else {
        if (error != FTError.ErrorTag.ERR_OK) {
          Log.e(TAG, "tt_loader_init: could not access glyph table");
          return error;
        } else {
          this.glyf_offset = face.getStream().pos();
        }
      }
    }
    /* get face's glyph loader */
    if (!glyf_table_only) {
      FTReference<FTGlyphLoaderRec> gloader_ref = new FTReference<FTGlyphLoaderRec>(); 
      glyph.getInternal().loader.GlyphLoaderRewind();
      this.gloader = glyph.getInternal().loader;
    }
    this.load_flags = load_flags;
    this.face = face;
    this.size = size;
    this.glyph = glyph;
    this.stream = face.getStream();
    return FTError.ErrorTag.ERR_OK;
  }

  /* =====================================================================
   * tt_get_metrics
   *
   * Return the vertical metrics in font units for a given glyph.
................................................................................
    pp4.y = pp3.y - vadvance;
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("loader_set_pp3: loader.pp1.x: %d, loader.pp1.y: %d, loader.pp2.x: %d, loader.pp2.y: %d, loader.pp3.x: %d, loader.pp3.y: %d, loader.pp4.x: %d, loader.pp4.y: %d\n", pp1.x, pp1.y, pp2.x, pp2.y, pp3.x, pp3.y, pp4.x, pp4.y));
    /***********************************************************************/
    /***********************************************************************/
    /***********************************************************************/
    /* if it is a simple glyph, load it */
    if (n_contours > 0) {



      error = ttface.readSimpleGlyph(this);

      if (error != FTError.ErrorTag.ERR_OK) {
        if (opened_frame) {
          ttface.forgetGlyphFrame(this);
        }
        return error;
      }


      /* all data have been read */
      ttface.forgetGlyphFrame(this);
      opened_frame = false;
      error = TTGlyphLoaderFuncs.TTProcessSimpleGlyph(this);
      if (error != FTError.ErrorTag.ERR_OK) {
        if (opened_frame) {
          ttface.forgetGlyphFrame(this);
................................................................................

  /* ==================== setGlyph ================================== */
  public void setGlyph(FTGlyphSlotRec glyph) {
    this.glyph = glyph;
  }

  /* ==================== getGloader ================================== */
  public FTGlyphLoaderRec getGloader() {
    return gloader;
  }

  /* ==================== setGloader ================================== */
  public void setGloader(FTGlyphLoaderRec gloader) {
    this.gloader = gloader;
  }

  /* ==================== getLoad_flags ================================== */
  public Flags.Load getLoad_flags() {
    return load_flags;
  }







|







 







|
<

|



|







 







|






|







 







|







 







|








|





|
|
<


|


|







 







<
<
<
<
>






>
>







 







|




|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
129
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144
145
146
147
148
149
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219

220
221
222
223
224
225
226
227
228
229
230
231
232
...
394
395
396
397
398
399
400




401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
...
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782

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

  private FTFaceRec face = null;
  private FTSizeRec size = null;
  private FTGlyphSlotRec glyph = null;
  private TTGlyphLoaderRec gloader = null;
  private Flags.Load load_flags = Flags.Load.DEFAULT;
  private int glyph_index = 0;
  private FTStreamRec stream = null;
  private int byte_len = 0;
  private int n_contours = 0;
  private FTBBoxRec bbox = null;
  private int left_bearing = 0;
................................................................................
    return str.toString();
  }

  /* =====================================================================
   * tt_loader_init
   * =====================================================================
   */
  public FTError.ErrorTag tt_loader_init(TTSizeRec size, FTGlyphSlotRec glyph, Flags.Load load_flags, boolean glyf_table_only) {

Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tt_loader_init");
    TTFaceRec ttface;
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    boolean pedantic = (load_flags.getVal() & Flags.Load.PEDANTIC.getVal()) != 0;

    ttface = (TTFaceRec)glyph.getFace();
    /* load execution context */
    if ((load_flags.getVal() & Flags.Load.NO_HINTING.getVal()) == 0 && !glyf_table_only) {
      TTExecContextRec exec;
      boolean grayscale;
      boolean reexecute = false;

Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "fill TTSizeRec\n");
................................................................................
        if (error != FTError.ErrorTag.ERR_OK) {
          return error;
        }
      }
      /* query new execution context */

      exec = size.isDebug() ? size.getContext()
                         : ((TTDriverRec)ttface.getDriver()).context;
      if (exec == null) {
        return FTError.ErrorTag.GLYPH_COULD_NOT_FIND_CONTEXT;
      }
      grayscale = (((load_flags.getVal() >> 16) & 15) != FTTags.RenderMode.MONO.getVal());
      FTReference<TTExecContextRec> exec_ref = new FTReference<TTExecContextRec>();
      exec_ref.Set(exec);
      exec.TTLoadContext(ttface, size);
      exec = exec_ref.Get();
      {
        /* a change from mono to grayscale rendering (and vice versa) */
        /* requires a re-execution of the CVT program                 */
        if (grayscale != exec.grayscale) {
          FTTrace.Trace(7, TAG, "tt_loader_init: grayscale change, re-executing `prep' table");
          exec.grayscale = grayscale;
................................................................................
          reexecute = true;
        }
      }
      if (reexecute) {
        int i;

        for (i = 0; i < size.getCvt_size(); i++) {
          size.getCvt()[i] = TTUtil.FTMulFix(ttface.getCvt_table().getCvtValue(i), size.getTtmetrics().getScale());
        }
        size.tt_size_run_prep(pedantic);
      }
      /* see whether the cvt program has disabled hinting */
      if ((exec.graphics_state.instruct_control & 1) != 0) {
        load_flags = Flags.Load.getTableTag(load_flags.getVal() | Flags.Load.NO_HINTING.getVal());
      }
................................................................................
    }
    /* seek to the beginning of the glyph table -- for Type 42 fonts     */
    /* the table might be accessed from a Postscript stream or something */
    /* else...                                                           */
    {
      FTReference<Integer> length_ref = new FTReference<Integer>();
      length_ref.Set(new Integer(0));
      error = ttface.gotoTable(TTTags.Table.glyf, ttface.getStream(), length_ref);

      if (error == FTError.ErrorTag.GLYPH_TABLE_MISSING) {
        this.glyf_offset = 0;
      } else {
        if (error != FTError.ErrorTag.ERR_OK) {
          Log.e(TAG, "tt_loader_init: could not access glyph table");
          return error;
        } else {
          this.glyf_offset = ttface.getStream().pos();
        }
      }
    }
    /* get face's glyph loader */
    if (!glyf_table_only) {
      glyph.getInternal().getLoader().GlyphLoaderRewind();
      this.gloader = (TTGlyphLoaderRec)glyph.getInternal().getLoader();

    }
    this.load_flags = load_flags;
    this.face = ttface;
    this.size = size;
    this.glyph = glyph;
    this.stream = ttface.getStream();
    return FTError.ErrorTag.ERR_OK;
  }

  /* =====================================================================
   * tt_get_metrics
   *
   * Return the vertical metrics in font units for a given glyph.
................................................................................
    pp4.y = pp3.y - vadvance;
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("loader_set_pp3: loader.pp1.x: %d, loader.pp1.y: %d, loader.pp2.x: %d, loader.pp2.y: %d, loader.pp3.x: %d, loader.pp3.y: %d, loader.pp4.x: %d, loader.pp4.y: %d\n", pp1.x, pp1.y, pp2.x, pp2.y, pp3.x, pp3.y, pp4.x, pp4.y));
    /***********************************************************************/
    /***********************************************************************/
    /***********************************************************************/
    /* if it is a simple glyph, load it */
    if (n_contours > 0) {




      error = gloader.tt_load_simple_glyph(this);
      if (error != FTError.ErrorTag.ERR_OK) {
        if (opened_frame) {
          ttface.forgetGlyphFrame(this);
        }
        return error;
      }


      /* all data have been read */
      ttface.forgetGlyphFrame(this);
      opened_frame = false;
      error = TTGlyphLoaderFuncs.TTProcessSimpleGlyph(this);
      if (error != FTError.ErrorTag.ERR_OK) {
        if (opened_frame) {
          ttface.forgetGlyphFrame(this);
................................................................................

  /* ==================== setGlyph ================================== */
  public void setGlyph(FTGlyphSlotRec glyph) {
    this.glyph = glyph;
  }

  /* ==================== getGloader ================================== */
  public TTGlyphLoaderRec getGloader() {
    return gloader;
  }

  /* ==================== setGloader ================================== */
  public void setGloader(TTGlyphLoaderRec gloader) {
    this.gloader = gloader;
  }

  /* ==================== getLoad_flags ================================== */
  public Flags.Load getLoad_flags() {
    return load_flags;
  }

Changes to afttruetype/TTLocaRec.java.

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  /*    A structure used to model a TrueType loca table.  All fields       */
  /*    comply to the TrueType specification.                              */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTUtil;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTStreamRec;
import org.apwtcl.apwfreetypelib.aftutil.FTTrace;

public class TTLocaRec extends FTDebug {







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  /*    A structure used to model a TrueType loca table.  All fields       */
  /*    comply to the TrueType specification.                              */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftutil.FTUtil;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTStreamRec;
import org.apwtcl.apwfreetypelib.aftutil.FTTrace;

public class TTLocaRec extends FTDebug {

Changes to afttruetype/TTNameTableRec.java.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.afttruetype;

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTUtil;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTStreamRec;
import org.apwtcl.apwfreetypelib.aftutil.FTTrace;









|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.afttruetype;

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftutil.FTUtil;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTStreamRec;
import org.apwtcl.apwfreetypelib.aftutil.FTTrace;


Deleted aftutil/FTArrayUtil.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
/* =====================================================================
 *  This Java implementation is derived from FreeType code
 *  Portions of this software are copyright (C) 2014 The FreeType
 *  Project (www.freetype.org).  All rights reserved.
 *
 *  Copyright (C) of the Java implementation 2014
 *  Arnulf Wiedemann: arnulf (at) wiedemann-pri (dot) de
 *
 *  See the file "license.terms" for information on usage and
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftutil;

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTCharMapRec;

  /* ===================================================================== */
  /*    FTUtil                                                          */
  /*                                                                       */
  /* ===================================================================== */

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

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

    /* ==================== FTUtil ================================== */
    public FTArrayUtil() {
      oid++;
      id = oid;
    }
    
    /* ==================== mySelf ================================== */
    public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
    /* ==================== toString ===================================== */
    public String toString() {
      return mySelf()+"!";
    }

    /* ==================== toDebugString ===================================== */
    public String toDebugString() {
      StringBuffer str = new StringBuffer(mySelf()+"\n");
      return str.toString();
    }
 
    /* =====================================================================
     * FT_RENEW_ARRAY
     * =====================================================================
     */
    public static Object FT_RENEW_ARRAY(Object obj, String type, int curCount, int newCount) {
      int i;
      int j;
      int k;

      if (curCount < 0 || newCount < 0) {
        Log.e(TAG, String.format("curCount < 0 || newCount < 0, curCount: %d, newCount: %d", curCount, newCount));
	  return null;
      }
      if (curCount == 0) {
        if (obj != null) {
          Log.e(TAG, String.format("curCount == 0 obj != null"));
	  return null;
	}
      }
      switch (type) {
        case "FTUnitVector": 
          FTVectorRec[] vec_array = (FTVectorRec[]) obj;
          if (vec_array == null) {
            // easy just allocate
            vec_array = new FTVectorRec[newCount];
            for (i = 0; i < newCount; i++) {
              vec_array[i] = new FTVectorRec();
            }
            obj = (Object)vec_array;
          } else {
            if (vec_array.length >= newCount) {
              // nothing to do
            } else {
              if (curCount == 0) {
                vec_array = new FTVectorRec[newCount];
                for (j = 0; j < newCount; j++) {
                  vec_array[j] = new FTVectorRec();
                }
                obj = (Object)vec_array;
              } else {
                FTVectorRec[] tmp1 = new FTVectorRec[curCount];
                tmp1 = java.util.Arrays.copyOf(vec_array, curCount);
                vec_array = new FTVectorRec[newCount];
                for (k = 0; k < curCount; k++) {
                  vec_array[k] = tmp1[k];
                }
                for (k = curCount; k < newCount; k++) {
                  vec_array[k] = new FTVectorRec();
                }
                obj = (Object)vec_array;
              }
            }
          }
          break;
        case "byte": 
          byte[] byte_array = (byte[]) obj;
          if (byte_array == null) {
            // easy just allocate
            byte_array = new byte[newCount];
            for (i = 0; i < newCount; i++) {
              byte_array[i] = 0;
            }
            obj = (Object)byte_array;
          } else {
            if (byte_array.length >= newCount) {
              // nothing to do
            } else {
              if (curCount == 0) {
                byte_array = new byte[newCount];
                for (j = 0; j < newCount; j++) {
                  byte_array[j] = 0;
                }
                obj = (Object)byte_array;
              } else {
                byte[] tmp2 = new byte[curCount];
                tmp2 = java.util.Arrays.copyOf(byte_array, curCount);
                byte_array = new byte[newCount];
                for (k = 0; k < curCount; k++) {
                  byte_array[k] = tmp2[k];
                }
                for (k = curCount; k < newCount; k++) {
                  byte_array[k] = 0;
                }
                obj = (Object)byte_array;
              }
            }
          }
          break;
        case "short": 
          short[] short_array = (short[]) obj;
          if (short_array == null) {
            // easy just allocate
            short_array = new short[newCount];
            for (i = 0; i < newCount; i++) {
              short_array[i] = 0;
            }
            obj = (Object)short_array;
          } else {
            if (short_array.length >= newCount) {
              // nothing to do
            } else {
              if (curCount == 0) {
                short_array = new short[newCount];
                for (j = 0; j < newCount; j++) {
                  short_array[j] = 0;
                }
                obj = (Object)short_array;
              } else {
                short[] tmp3 = new short[curCount];
                tmp3 = java.util.Arrays.copyOf(short_array, curCount);
                short_array = new short[newCount];
                for (k = 0; k < curCount; k++) {
                  short_array[k] = tmp3[k];
                }
                for (k = curCount; k < newCount; k++) {
                  short_array[k] = 0;
                }
                obj = (Object)short_array;
              }
            }
          }
          break;
        case "long": 
          obj = null;
          Log.e(TAG, "bad type: "+type+" in FT_RENEW_ARRAY (not yet implemented)");
          break;
        case "charmaps": 
          FTCharMapRec[] charmaps_array = (FTCharMapRec[]) obj;
          if (charmaps_array == null) {
            // easy just allocate
            charmaps_array = new FTCharMapRec[newCount];
            for (i = 0; i < newCount; i++) {
              charmaps_array[i] = new FTCharMapRec();
            }
            obj = (Object)charmaps_array;
          } else {
            if (charmaps_array.length >= newCount) {
              // nothing to do
            } else {
              if (curCount == 0) {
                charmaps_array = new FTCharMapRec[newCount];
                for (j = 0; j < newCount; j++) {
                  charmaps_array[j] = new FTCharMapRec();
                }
                obj = (Object)charmaps_array;
              } else {
                FTCharMapRec[] tmp3 = new FTCharMapRec[curCount];
                tmp3 = java.util.Arrays.copyOf(charmaps_array, curCount);
                charmaps_array = new FTCharMapRec[newCount];
                for (k = 0; k < curCount; k++) {
                  charmaps_array[k] = tmp3[k];
                }
                for (k = curCount; k < newCount; k++) {
                  charmaps_array[k] = new FTCharMapRec();
                }
                obj = (Object)charmaps_array;
              }
            }
          }
          break;
        default:
          Log.e(TAG, "bad type: "+type+" in FT_RENEW_ARRAY");
          return null;
      }
      return obj;
    }

    /* =====================================================================
     * FT_BYTE
     * =====================================================================
     */
    public static int FT_BYTE(byte[] p, int idx) {
      return p[idx] & 0xFF;
    }

    /* =====================================================================
     * FT_BYTE_U16
     * =====================================================================
     */
    public static int FT_BYTE_U16(byte[] p, int idx, int shift) {
      return (FT_BYTE(p, idx) << shift) & 0xFFFF;
    }

    /* =====================================================================
     * FT_BYTE_U32
     * =====================================================================
     */
    public static Long FT_BYTE_U32(byte[] p, int idx, int shift) {
      return (long)(FT_BYTE(p, idx) << shift) & 0xFFFFFFFF;
    }


    /* =====================================================================
     * FT_PEEK_SHORT
     * =====================================================================
     */
    public static int FT_PEEK_SHORT(byte[] p, int idx) {
      return FT_BYTE_U16(p, idx+0, 8) | FT_BYTE_U16(p, idx+1, 0);
    }

    /* =====================================================================
     * FT_PEEK_USHORT
     * =====================================================================
     */
    public static int FT_PEEK_USHORT(byte[] p, int idx) {
      return (FT_BYTE_U16(p, idx+0, 8) | FT_BYTE_U16(p, idx+1, 0)) & 0xFFFF;
    }

    /* =====================================================================
     * FT_NEXT_ULONG
     * =====================================================================
     */
    public static long FT_NEXT_ULONG(byte[] array, FTReference<Integer> offset_ref, int limit) {
      int offset = offset_ref.Get();
      if (offset + 4 > limit) {
        Log.e(TAG, "FT_NEXT_ULONG offset > limit!!");
        return 0L;
      } else {
//Debug(0, DBG_LOAD_GLYPH, TAG, String.format("LL!%d, %d, %d, %d", (array[offset] & 0xFF) << 24, (array[offset + 1] & 0xFF) << 16, (array[offset + 2] & 0xFF) << 8, (array[offset + 3] & 0xFF)));
        long val = ((array[offset] & 0xFF) << 24) | ((array[offset + 1] & 0xFF) << 16) | ((array[offset + 2] & 0xFF) << 8) | (array[offset + 3] & 0xFF);
        offset += 4;
        offset_ref.Set(offset);
        return val;
      }
    }

    /* =====================================================================
     * FT_NEXT_USHORT
     * =====================================================================
     */
    public static int FT_NEXT_USHORT(byte[] array, FTReference<Integer> offset_ref, int limit) {
      int offset = offset_ref.Get();
      if (offset + 2 > limit) {
        Log.e(TAG, "FT_NEXT_USHORT offset > limit!!");
        return 0;
      } else {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("sh: offset: %d b0: %d b1: %d bb0: %d bb1: %d", offset, array[offset], array[offset + 1], array[offset] & 0xFF << 8, array[offset + 1] % 0xFF));
        int val = ((((array[offset] & 0xFF) << 8) + ((array[offset + 1] & 0xFF))) & 0xFFFF);
        offset += 2;
        offset_ref.Set(offset);
        return val;
      }
    }

    /* =====================================================================
     * FT_NEXT_SHORT
     * =====================================================================
     */
    public static short FT_NEXT_SHORT(byte[] array, FTReference<Integer> offset_ref, int limit) {
      int offset = offset_ref.Get();
      if (offset + 2 > limit) {
        Log.e(TAG, "FT_NEXT_USHORT offset > limit!!");
        return 0;
      } else {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("sh: offset: %d b0: %d b1: %d bb0: %d bb1: %d", offset, array[offset], array[offset + 1], array[offset] & 0xFF << 8, array[offset + 1] % 0xFF));
        short val = (short)((array[offset] << 8) + ((array[offset + 1] & 0xFF)));
        offset += 2;
        offset_ref.Set(offset);
        return val;
      }
    }

}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































































































































Name change from aftbase/FTUtil.java to aftutil/FTUtil.java.

7
8
9
10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
165
166
167
168
169
170
171
172
173
174
175
176
177


































178
179
180
181
182
183
184
185
186
187
188
 *  Arnulf Wiedemann: arnulf (at) wiedemann-pri (dot) de
 *
 *  See the file "license.terms" for information on usage and
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftbase;

import android.util.Log;


import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;

  /* ===================================================================== */
  /*    FTUtil                                                          */
  /*                                                                       */
................................................................................
      return str.toString();
    }
 
    /* =====================================================================
     * FT_RENEW_ARRAY
     * =====================================================================
     */
    public static Object FT_RENEW_ARRAY(Object obj, String type, int curCount, int newCount) {
      int i;
      int j;
      int k;

      if (curCount < 0 || newCount < 0) {
        Log.e(TAG, String.format("curCount < 0 || newCount < 0, curCount: %d, newCount: %d", curCount, newCount));
	  return null;
      }
      if (curCount == 0) {
        if (obj != null) {
          Log.e(TAG, String.format("curCount == 0 obj != null"));
	  return null;
	}
      }
      switch (type) {
        case "FTUnitVector": 
          FTVectorRec[] vec_array = (FTVectorRec[]) obj;
          if (vec_array == null) {
            // easy just allocate
            vec_array = new FTVectorRec[newCount];
            for (i = 0; i < newCount; i++) {
              vec_array[i] = new FTVectorRec();
            }
................................................................................
                  vec_array[k] = new FTVectorRec();
                }
                obj = (Object)vec_array;
              }
            }
          }
          break;
        case "byte": 
          byte[] byte_array = (byte[]) obj;
          if (byte_array == null) {
            // easy just allocate
            byte_array = new byte[newCount];
            for (i = 0; i < newCount; i++) {
              byte_array[i] = 0;
            }
................................................................................
                  byte_array[k] = 0;
                }
                obj = (Object)byte_array;
              }
            }
          }
          break;
        case "short": 
          short[] short_array = (short[]) obj;
          if (short_array == null) {
            // easy just allocate
            short_array = new short[newCount];
            for (i = 0; i < newCount; i++) {
              short_array[i] = 0;
            }
................................................................................
                short_array = new short[newCount];
                for (k = 0; k < curCount; k++) {
                  short_array[k] = tmp3[k];
                }
                for (k = curCount; k < newCount; k++) {
                  short_array[k] = 0;
                }
                obj = (Object)short_array;
              }
            }
          }
          break;
        case "long": 


































          obj = null;
          Log.e(TAG, "bad type: "+type+" in FT_RENEW_ARRAY (not yet implemented)");
          break;
        case "charmaps": 
          FTCharMapRec[] charmaps_array = (FTCharMapRec[]) obj;
          if (charmaps_array == null) {
            // easy just allocate
            charmaps_array = new FTCharMapRec[newCount];
            for (i = 0; i < newCount; i++) {
              charmaps_array[i] = new FTCharMapRec();
            }







|



>







 







|






|




|
|


|







 







|







 







|







 







|




|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
...
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
 *  Arnulf Wiedemann: arnulf (at) wiedemann-pri (dot) de
 *
 *  See the file "license.terms" for information on usage and
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftutil;

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTCharMapRec;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;

  /* ===================================================================== */
  /*    FTUtil                                                          */
  /*                                                                       */
................................................................................
      return str.toString();
    }
 
    /* =====================================================================
     * FT_RENEW_ARRAY
     * =====================================================================
     */
    public static Object FT_RENEW_ARRAY(Object obj, FTUtilFlags.ArrayType type, int curCount, int newCount) {
      int i;
      int j;
      int k;

      if (curCount < 0 || newCount < 0) {
        Log.e(TAG, String.format("curCount < 0 || newCount < 0, curCount: %d, newCount: %d", curCount, newCount));
        return null;
      }
      if (curCount == 0) {
        if (obj != null) {
          Log.e(TAG, String.format("curCount == 0 obj != null"));
          return null;
        }
      }
      switch (type) {
        case FT_VECTOR:
          FTVectorRec[] vec_array = (FTVectorRec[]) obj;
          if (vec_array == null) {
            // easy just allocate
            vec_array = new FTVectorRec[newCount];
            for (i = 0; i < newCount; i++) {
              vec_array[i] = new FTVectorRec();
            }
................................................................................
                  vec_array[k] = new FTVectorRec();
                }
                obj = (Object)vec_array;
              }
            }
          }
          break;
        case BYTE:
          byte[] byte_array = (byte[]) obj;
          if (byte_array == null) {
            // easy just allocate
            byte_array = new byte[newCount];
            for (i = 0; i < newCount; i++) {
              byte_array[i] = 0;
            }
................................................................................
                  byte_array[k] = 0;
                }
                obj = (Object)byte_array;
              }
            }
          }
          break;
        case SHORT:
          short[] short_array = (short[]) obj;
          if (short_array == null) {
            // easy just allocate
            short_array = new short[newCount];
            for (i = 0; i < newCount; i++) {
              short_array[i] = 0;
            }
................................................................................
                short_array = new short[newCount];
                for (k = 0; k < curCount; k++) {
                  short_array[k] = tmp3[k];
                }
                for (k = curCount; k < newCount; k++) {
                  short_array[k] = 0;
                }
                obj = short_array;
              }
            }
          }
          break;
        case INT:
          int[] int_array = (int[]) obj;
          if (int_array == null) {
            // easy just allocate
            int_array = new int[newCount];
            for (i = 0; i < newCount; i++) {
              int_array[i] = 0;
            }
            obj = int_array;
          } else {
            if (int_array.length >= newCount) {
              // nothing to do
            } else {
              if (curCount == 0) {
                int_array = new int[newCount];
                for (j = 0; j < newCount; j++) {
                  int_array[j] = 0;
                }
                obj = int_array;
              } else {
                int[] tmp3 = new int[curCount];
                tmp3 = java.util.Arrays.copyOf(int_array, curCount);
                int_array = new int[newCount];
                for (k = 0; k < curCount; k++) {
                  int_array[k] = tmp3[k];
                }
                for (k = curCount; k < newCount; k++) {
                  int_array[k] = 0;
                }
                obj = int_array;
              }
            }
          }
          break;
        case LONG:
          obj = null;
          Log.e(TAG, "bad type: "+type+" in FT_RENEW_ARRAY (not yet implemented)");
          break;
        case CHARMAPS:
          FTCharMapRec[] charmaps_array = (FTCharMapRec[]) obj;
          if (charmaps_array == null) {
            // easy just allocate
            charmaps_array = new FTCharMapRec[newCount];
            for (i = 0; i < newCount; i++) {
              charmaps_array[i] = new FTCharMapRec();
            }

Changes to aftutil/FTUtilFlags.java.

61
62
63
64
65
66
67
68
69













70






















    public static boolean isDriver(int flags) {
      return (flags &  FTUtilFlags.StreamOpen.DRIVER.getVal()) != 0;
    }
    public static boolean isParams(int flags) {
      return (flags &  FTUtilFlags.StreamOpen.PARAMS.getVal()) != 0;
    }

  }














}































>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    public static boolean isDriver(int flags) {
      return (flags &  FTUtilFlags.StreamOpen.DRIVER.getVal()) != 0;
    }
    public static boolean isParams(int flags) {
      return (flags &  FTUtilFlags.StreamOpen.PARAMS.getVal()) != 0;
    }

  }

  public enum ArrayType {
    FT_VECTOR(0x1, "FT_ARRAY_TYPE_FT_VECTOR"),
    BYTE(0x2, "FT_ARRAY_TYPE_BYTE"),
    SHORT(0x4, "FT_ARRAY_TYPE_SHORT"),
    INT(0x8, "FT_ARRAY_TYPE_INT"),
    LONG(0x10, "FT_ARRAY_TYPE_LONG"),
    CHARMAPS(0x20, "FT_ARRAY_TYPE_CHARMAPS");
    private int val;
    private String str;
    private static SparseArray<ArrayType> tagToArrayTypeMapping;
    public static ArrayType getTableTag(int i) {
      if (tagToArrayTypeMapping == null) {
        initMapping();
      }
      return tagToArrayTypeMapping.get(i);
    }
    private static void initMapping() {
      tagToArrayTypeMapping = new SparseArray<ArrayType>();
      for (ArrayType t : values()) {
        tagToArrayTypeMapping.put(t.val, t);
      }
    }
    private ArrayType(int val, String str) {
      this.val = val;
      this.str = str;
    }
    public int getVal() {
      return val;
    }
    public String getDescription() {
      return str;
    }

  }

}