apwfreetypelib

Check-in [199f3dbc0b]
Login

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

Overview
Comment:make Flags.Module a Set and fixes.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:199f3dbc0b59bca6f40fe3e4c4329334a9b0af05
User & Date: arnulf 2015-02-08 20:19:34
Context
2015-02-14
18:22
fixes and added new Debug tags. check-in: 4621cff9f7 user: arnulf tags: trunk
2015-02-08
20:19
make Flags.Module a Set and fixes. check-in: 199f3dbc0b user: arnulf tags: trunk
16:56
FTOutlineFuncs deleted, FTGrayOutlineFuncsClass renamed to FTGrayOutlineClass, moved some methods. check-in: 39e6a60944 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to aftbase/FTFaceRec.java.

355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
...
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
      return error;
    }
    /* If the font driver is specified in the `args' structure, use */
    /* it.  Otherwise, we scan the list of registered drivers.      */
    if (FTUtilFlags.StreamOpen.isDriver(args.getFlags()) && args.getDriver() != null) {
      driver = (TTDriverRec)args.getDriver();
      /* not all modules are drivers, so check... */
      if ((driver.getDriver_clazz().module_flags & Flags.Module.FONT_DRIVER.getVal()) != 0) {
        int num_params = 0;
        FTParameterRec[] params =null ;

        if (FTUtilFlags.StreamOpen.isParams(args.getFlags())) {
          num_params = args.getNum_params();
          params = args.getParams();
        }
................................................................................
    } else {
      error = FTError.ErrorTag.LOAD_MISSING_MODULE;
        /* check each font driver for an appropriate format */
      limit = library.getNum_modules();
      for (module_idx = 0; module_idx < limit; module_idx++) {
        cur = library.getModule(module_idx);
          /* not all modules are font drivers, so check... */
        if ((cur.module_clazz.module_flags & Flags.Module.FONT_DRIVER.getVal()) != 0) {
          int num_params = 0;
          FTParameterRec params[] = null;

          TTDriverRec cur_obj = (TTDriverRec)library.getModule(module_idx);
          driver = cur_obj;
          if (FTUtilFlags.StreamOpen.isParams(args.getFlags())) {
            num_params = args.getNum_params();







|







 







|







355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
...
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
      return error;
    }
    /* If the font driver is specified in the `args' structure, use */
    /* it.  Otherwise, we scan the list of registered drivers.      */
    if (FTUtilFlags.StreamOpen.isDriver(args.getFlags()) && args.getDriver() != null) {
      driver = (TTDriverRec)args.getDriver();
      /* not all modules are drivers, so check... */
      if (driver.getDriver_clazz().module_flags.contains(Flags.Module.FONT_DRIVER)) {
        int num_params = 0;
        FTParameterRec[] params =null ;

        if (FTUtilFlags.StreamOpen.isParams(args.getFlags())) {
          num_params = args.getNum_params();
          params = args.getParams();
        }
................................................................................
    } else {
      error = FTError.ErrorTag.LOAD_MISSING_MODULE;
        /* check each font driver for an appropriate format */
      limit = library.getNum_modules();
      for (module_idx = 0; module_idx < limit; module_idx++) {
        cur = library.getModule(module_idx);
          /* not all modules are font drivers, so check... */
        if (cur.module_clazz.module_flags.contains(Flags.Module.FONT_DRIVER)) {
          int num_params = 0;
          FTParameterRec params[] = null;

          TTDriverRec cur_obj = (TTDriverRec)library.getModule(module_idx);
          driver = cur_obj;
          if (FTUtilFlags.StreamOpen.isParams(args.getFlags())) {
            num_params = args.getNum_params();

Changes to aftbase/FTGlyphLoadRec.java.

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
..
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
..
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
...
199
200
201
202
203
204
205
206



207













































































































































































package org.apwtcl.apwfreetypelib.aftbase;

  /* ===================================================================== */
  /*    FTGlyphLoadRec                                                          */
  /*                                                                       */
  /* ===================================================================== */


import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;



public class FTGlyphLoadRec extends FTOutlineRec {

  private static int oid = 0;

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

  private FTVectorRec[] extra_points = null;  /* extra points table        */
  private int extra_points_idx = 0;
  private FTVectorRec[] extra_points2 = null; /* second extra points table */
  private int extra_points2_idx = 0;
  private int num_subglyphs = 0;              /* number of subglyphs       */
  private FTSubGlyphRec[] subglyphs = null;   /* subglyphs                 */
  private int subglyphs_idx;


  /* ==================== FTGlyphLoadRec ================================== */
  public FTGlyphLoadRec() {
    oid++;
    id = oid;
  }
    
................................................................................
    str.append("..num_subglyphs: "+""+'\n');
    str.append("..subglyphs_idx: "+""+'\n');
    return str.toString();
  }
 
  /* ==================== copy ===================================== */
  public int copy( FTGlyphLoadRec from ) {
//FIXME ned to copy the fields here !!!
//    outline.copy(from.outline);
    extra_points = from.extra_points;
    extra_points2 = from.extra_points2;
    num_subglyphs = from.num_subglyphs;
    subglyphs = from.subglyphs;
    subglyphs_idx = from.subglyphs_idx;
    extra_points_idx = from.extra_points_idx;
    extra_points2_idx = from.extra_points2_idx;
................................................................................
  }

  /* ==================== showGLoaderGlyph ================================== */
  public void showGloaderGlyph(String str) {
    int j;

    Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, str);
    if (points != null) {
      Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "loaderLoad.outline.points: "+points+"!"+points_idx);
    }
    if (extra_points != null) {
      Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "loaderLoad.extra_points: "+extra_points+"!"+extra_points_idx);
    }
    if (extra_points2 != null) {
      Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "loaderLoad.extra_points2: "+extra_points2+"!"+extra_points2_idx);
    }
    Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "Show loaderLoad");
    for (j = 0; j < n_points; j++) {
      if (points != null) {
        if (points_idx + j < points.length) {
          if (getPoint(j) != null) {
            Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format(" outl: %d %5d %5d", j, getPoint(j).getX(), getPoint(j).getY()));
          }
        }
      }
      if (extra_points != null) {
        if (j < extra_points.length) {
          if (getExtra_point(j) != null) {
            Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format(" ext1: %d %5d %5d", j, getExtra_point(j).getX(), getExtra_point(j).getY()));
................................................................................
    return subglyphs_idx;
  }

  /* ==================== setSubglyphs_idx ===================================== */
  public void setSubglyphs_idx(int subglyphs_idx) {
    this.subglyphs_idx = subglyphs_idx;
  }




}




















































































































































































>


>
>
|
>












>







 







<
|







 







|
|








|
|
|
|
|







 








>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
..
63
64
65
66
67
68
69

70
71
72
73
74
75
76
77
..
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
...
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
package org.apwtcl.apwfreetypelib.aftbase;

  /* ===================================================================== */
  /*    FTGlyphLoadRec                                                          */
  /*                                                                       */
  /* ===================================================================== */

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

import java.util.Set;

//public class FTGlyphLoadRec extends FTOutlineRec {
public class FTGlyphLoadRec extends FTDebug {
  private static int oid = 0;

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

  private FTVectorRec[] extra_points = null;  /* extra points table        */
  private int extra_points_idx = 0;
  private FTVectorRec[] extra_points2 = null; /* second extra points table */
  private int extra_points2_idx = 0;
  private int num_subglyphs = 0;              /* number of subglyphs       */
  private FTSubGlyphRec[] subglyphs = null;   /* subglyphs                 */
  private int subglyphs_idx;
  private FTOutlineRec outline = null;

  /* ==================== FTGlyphLoadRec ================================== */
  public FTGlyphLoadRec() {
    oid++;
    id = oid;
  }
    
................................................................................
    str.append("..num_subglyphs: "+""+'\n');
    str.append("..subglyphs_idx: "+""+'\n');
    return str.toString();
  }
 
  /* ==================== copy ===================================== */
  public int copy( FTGlyphLoadRec from ) {

    outline.copy(from.outline);
    extra_points = from.extra_points;
    extra_points2 = from.extra_points2;
    num_subglyphs = from.num_subglyphs;
    subglyphs = from.subglyphs;
    subglyphs_idx = from.subglyphs_idx;
    extra_points_idx = from.extra_points_idx;
    extra_points2_idx = from.extra_points2_idx;
................................................................................
  }

  /* ==================== showGLoaderGlyph ================================== */
  public void showGloaderGlyph(String str) {
    int j;

    Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, str);
    if (outline.points != null) {
      Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "loaderLoad.outline.points: "+outline.points+"!"+outline.points_idx);
    }
    if (extra_points != null) {
      Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "loaderLoad.extra_points: "+extra_points+"!"+extra_points_idx);
    }
    if (extra_points2 != null) {
      Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "loaderLoad.extra_points2: "+extra_points2+"!"+extra_points2_idx);
    }
    Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "Show loaderLoad");
    for (j = 0; j < outline.n_points; j++) {
      if (outline.points != null) {
        if (outline.points_idx + j < outline.points.length) {
          if (outline.getPoint(j) != null) {
            Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format(" outl: %d %5d %5d", j, outline.getPoint(j).getX(), outline.getPoint(j).getY()));
          }
        }
      }
      if (extra_points != null) {
        if (j < extra_points.length) {
          if (getExtra_point(j) != null) {
            Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format(" ext1: %d %5d %5d", j, getExtra_point(j).getX(), getExtra_point(j).getY()));
................................................................................
    return subglyphs_idx;
  }

  /* ==================== setSubglyphs_idx ===================================== */
  public void setSubglyphs_idx(int subglyphs_idx) {
    this.subglyphs_idx = subglyphs_idx;
  }

  /* ==================== getN_contours ================================== */
  public int getN_contours() {
    return outline.n_contours;
  }

  /* ==================== setN_contours ================================== */
  public void setN_contours(int n_contours) {
    outline.n_contours = n_contours;
  }

  /* ==================== getN_points ================================== */
  public int getN_points() {
    return outline.n_points;
  }

  /* ==================== setN_points ================================== */
  public void setN_points(int n_points) {
    outline.n_points = n_points;
  }

  /* ==================== getPoint ================================== */
  public FTVectorRec getPoint(int idx) {
    return outline.points[outline.points_idx+idx];
  }

  /* ==================== getPoint_x ================================== */
  public int getPoint_x(int idx) {
    return outline.points[outline.points_idx+idx].getX();
  }

  /* ==================== getPoint_y ================================== */
  public int getPoint_y(int idx) {
    return outline.points[outline.points_idx+idx].getY();
  }

  /* ==================== setPoint_x ================================== */
  public void setPoint_x(int idx, int val) {
    outline.points[outline.points_idx+idx].setX(val);
  }

  /* ==================== setPoint_y ================================== */
  public void setPoint_y(int idx, int val) {
    outline.points[outline.points_idx+idx].setY(val);
  }

  /* ==================== setPoint ================================== */
  public void setPoint(int idx, FTVectorRec point) {
    outline.points[outline.points_idx+idx] = point;
  }

  /* ==================== getPoints ================================== */
  public FTVectorRec[] getPoints() {
    return outline.points;
  }

  /* ==================== setPoints ================================== */
  public void setPoints(FTVectorRec[] points) {
    outline.points = points;
  }

  /* ==================== getTag ================================== */
  public Set<Flags.Curve> getTag(int idx) {
    return outline.tags[outline.tags_idx+idx];
  }

  /* ==================== setTag ================================== */
  public void setTag(int idx, Flags.Curve tag) {
    outline.tags[outline.tags_idx+idx].clear();
    outline.tags[outline.tags_idx+idx].add(tag);
  }

  /* ==================== setTag ================================== */
  public void setTag(int idx, Set<Flags.Curve> tag) {
    outline.tags[outline.tags_idx+idx] = tag;
  }

  /* ==================== addTag ================================== */
  public void addTag(int idx, Flags.Curve tag) {
    outline.tags[outline.tags_idx+idx].add(tag);
  }

  /* ==================== removeTag ================================== */
  public void removeTag(int idx, Flags.Curve tag) {
    outline.tags[outline.tags_idx+idx].remove(tag);
  }

  /* ==================== getTags ================================== */
  public Set<Flags.Curve>[] getTags() {
    return outline.tags;
  }

  /* ==================== setTags ================================== */
  public void setTags(Set<Flags.Curve>[] tags) {
    outline.tags = tags;
  }

  /* ==================== getContour ================================== */
  public int getContour(int idx) {
    return outline.contours[outline.contours_idx+idx];
  }

  /* ==================== setContours ================================== */
  public void setContour(int idx, int contour) {
    outline.contours[outline.contours_idx+idx] = contour;
  }

  /* ==================== getContours ================================== */
  public int[] getContours() {
    return outline.contours;
  }

  /* ==================== setContours ================================== */
  public void setContours(int[] contours) {
    outline.contours = contours;
  }

  /* ==================== getFlags ================================== */
  public int getFlags() {
    return outline.flags;
  }

  /* ==================== setFlags ================================== */
  public void setFlags(int flags) {
    outline.flags = flags;
  }

  /* ==================== getPoints_idx ================================== */
  public int getPoints_idx() {
    return outline.points_idx;
  }

  /* ==================== setPoints_idx ================================== */
  public void setPoints_idx(int points_idx) {
    outline.points_idx = points_idx;
  }

  /* ==================== getTags_idx ================================== */
  public int getTags_idx() {
    return outline.tags_idx;
  }

  /* ==================== setTags_idx ================================== */
  public void setTags_idx(int tags_idx) {
    outline.tags_idx = tags_idx;
  }

  /* ==================== getContours_idx ================================== */
  public int getContours_idx() {
    return outline.contours_idx;
  }

  /* ==================== setContours_idx ================================== */
  public void setContours_idx(int contours_idx) {
    outline.contours_idx = contours_idx;
  }

  /* ==================== getShift ===================================== */
  public int getShift() {
    return outline.shift;
  }

  /* ==================== getDelta ===================================== */
  public int getDelta() {
    return outline.delta;
  }

  /* ==================== getOutline ===================================== */
  public FTOutlineRec getOutline() {
    return outline;
  }

  /* ==================== setOutline ===================================== */
  public void setOutline(FTOutlineRec outline) {
    this.outline = outline;
  }

}

Changes to aftbase/FTGlyphLoaderRec.java.

237
238
239
240
241
242
243
244
245
246
247
248
249
250
251

  /* =====================================================================
   * GlyphLoaderRewind
   * =====================================================================
   */
  public void GlyphLoaderRewind() {
    base.setN_points(0);
    base.n_contours = 0;
    base.setNum_subglyphs(0);
    current.copy(base);
  }

  /* =====================================================================
   * GlyphLoaderPrepare
   *







|







237
238
239
240
241
242
243
244
245
246
247
248
249
250
251

  /* =====================================================================
   * GlyphLoaderRewind
   * =====================================================================
   */
  public void GlyphLoaderRewind() {
    base.setN_points(0);
    base.setN_contours(0);
    base.setNum_subglyphs(0);
    current.copy(base);
  }

  /* =====================================================================
   * GlyphLoaderPrepare
   *

Changes to aftbase/FTGlyphSlotRec.java.

14
15
16
17
18
19
20

21
22
23
24
25
26
27
..
53
54
55
56
57
58
59


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
...
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
package org.apwtcl.apwfreetypelib.aftbase;

  /* ===================================================================== */
  /*    FTGlyphSlotRec                                                          */
  /*                                                                       */
  /* ===================================================================== */


import org.apwtcl.apwfreetypelib.afttruetype.TTFaceRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTGlyphLoaderRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTGlyphSlotRec;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTMatrixRec;
................................................................................
  protected FTSubGlyphRec[] subglyphs = null;
  protected Object control_data;
  protected int control_len = 0;
  protected int lsb_delta = 0;
  protected int rsb_delta = 0;
  protected Object other = null;
  protected FTSlotInternalRec internal = null;



  /* ==================== FTGlyphSlotRec ================================== */
  public FTGlyphSlotRec() {
    oid++;
    id = oid;

    metrics = new FTGlyphMetricsRec();
    advance = new FTVectorRec();
    bitmap = new FTBitmapRec();
    outline = new FTOutlineRec();
    subglyphs = new FTSubGlyphRec[5];
    internal = new FTSlotInternalRec();
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
    return TAG+"!"+id+"!";
................................................................................
  private FTError.ErrorTag ft_glyphslot_init() {
    FTDriverRec driver = face.getDriver();
    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;
      }
................................................................................
  public FTError.ErrorTag ft_glyphslot_done() {
    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;
  }

................................................................................
     *
     * - Exception: The font is `tricky' and requires the native hinter to
     *   load properly.
     */
    if (hinter != null &&
        (!load_flags.contains(Flags.Load.NO_HINTING)) &&
        (!load_flags.contains(Flags.Load.NO_AUTOHINT)) &&
        ((driver.getDriver_clazz().module_flags & Flags.Module.DRIVER_SCALABLE.getVal()) != 0) &&
        ((driver.getDriver_clazz().module_flags & Flags.Module.DRIVER_NO_OUTLINES.getVal()) == 0) &&
        (!face.getFace_flags().contains(Flags.Face.TRICKY)) &&
        ((load_flags.contains(Flags.Load.IGNORE_TRANSFORM)) ||
            (face.getInternal().getTransform_matrix().getYx() == 0 && face.getInternal().getTransform_matrix().getXx() != 0) ||
            (face.getInternal().getTransform_matrix().getXx() == 0 && face.getInternal().getTransform_matrix().getYx() != 0))) {
      if ((load_flags.contains(Flags.Load.FORCE_AUTOHINT)) ||
          ((driver.getDriver_clazz().module_flags & Flags.Module.DRIVER_HAS_HINTER.getVal()) == 0)) {
        autohint = true;
      } else {
        int mode = ((Flags.Load.LoadSetToInt(load_flags) >> 16 ) & 15);
        /* the check for `num_locations' assures that we actually    */
        /* test for instructions in a TTF and not in a CFF-based OTF */
        if ((mode == FTTags.RenderMode.LIGHT.getVal()) ||
            face.getInternal().isIgnore_unpatented_hinter() ||







>







 







>
>









|







 







|




|







 







|







 







|
|





|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
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
...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
...
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
package org.apwtcl.apwfreetypelib.aftbase;

  /* ===================================================================== */
  /*    FTGlyphSlotRec                                                          */
  /*                                                                       */
  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftraster.FTGrayOutlineClass;
import org.apwtcl.apwfreetypelib.afttruetype.TTFaceRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTGlyphLoaderRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTGlyphSlotRec;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTMatrixRec;
................................................................................
  protected FTSubGlyphRec[] subglyphs = null;
  protected Object control_data;
  protected int control_len = 0;
  protected int lsb_delta = 0;
  protected int rsb_delta = 0;
  protected Object other = null;
  protected FTSlotInternalRec internal = null;

  protected FTTags.RasterType raster_type;

  /* ==================== FTGlyphSlotRec ================================== */
  public FTGlyphSlotRec() {
    oid++;
    id = oid;

    metrics = new FTGlyphMetricsRec();
    advance = new FTVectorRec();
    bitmap = new FTBitmapRec();
//    outline = new FTOutlineRec();
    subglyphs = new FTSubGlyphRec[5];
    internal = new FTSlotInternalRec();
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
    return TAG+"!"+id+"!";
................................................................................
  private FTError.ErrorTag ft_glyphslot_init() {
    FTDriverRec driver = face.getDriver();
    FTDriverClassRec clazz = driver.getDriver_clazz();
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    library = driver.library;
    internal = new FTSlotInternalRec();
    if (!driver.module_clazz.module_flags.contains(Flags.Module.DRIVER_NO_OUTLINES)) {
      FTReference<FTGlyphLoaderRec> loader_ref = new FTReference<FTGlyphLoaderRec>();
      loader_ref.Set(internal.getLoader());
      switch(face.getDriver().getDriver_clazz().module_type) {
        case TT_DRIVER:
          internal.setLoader(face.getDriver().getGlyph_loader());
          break;
        default:
          return FTError.ErrorTag.INTERP_INVALID_ARGUMENT;
      }
      if (internal.getLoader() == null) {
        error = FTError.ErrorTag.UNEXPECTED_NULL_VALUE;
      }
................................................................................
  public FTError.ErrorTag ft_glyphslot_done() {
    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.contains(Flags.Module.DRIVER_NO_OUTLINES)) {
        internal.getLoader().FTGlyphLoaderDone();
        internal.setLoader(null);
      }
    }
    return error;
  }

................................................................................
     *
     * - Exception: The font is `tricky' and requires the native hinter to
     *   load properly.
     */
    if (hinter != null &&
        (!load_flags.contains(Flags.Load.NO_HINTING)) &&
        (!load_flags.contains(Flags.Load.NO_AUTOHINT)) &&
        (driver.getDriver_clazz().module_flags.contains(Flags.Module.DRIVER_SCALABLE)) &&
        (!driver.getDriver_clazz().module_flags.contains(Flags.Module.DRIVER_NO_OUTLINES)) &&
        (!face.getFace_flags().contains(Flags.Face.TRICKY)) &&
        ((load_flags.contains(Flags.Load.IGNORE_TRANSFORM)) ||
            (face.getInternal().getTransform_matrix().getYx() == 0 && face.getInternal().getTransform_matrix().getXx() != 0) ||
            (face.getInternal().getTransform_matrix().getXx() == 0 && face.getInternal().getTransform_matrix().getYx() != 0))) {
      if ((load_flags.contains(Flags.Load.FORCE_AUTOHINT)) ||
          (!driver.getDriver_clazz().module_flags.contains(Flags.Module.DRIVER_HAS_HINTER))) {
        autohint = true;
      } else {
        int mode = ((Flags.Load.LoadSetToInt(load_flags) >> 16 ) & 15);
        /* the check for `num_locations' assures that we actually    */
        /* test for instructions in a TTF and not in a CFF-based OTF */
        if ((mode == FTTags.RenderMode.LIGHT.getVal()) ||
            face.getInternal().isIgnore_unpatented_hinter() ||

Changes to aftbase/FTModuleClassRec.java.

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
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
..
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

import android.util.Log;
import android.util.SparseArray;

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.TTUtil;




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

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

  protected int module_flags;
  protected FTTags.ModuleType module_type;
  protected String module_name;
  protected int module_version;
  protected int module_requires;
  protected FTModuleInterface module_interface;

  /* ==================== FTModuleClassRec ================================== */
  public FTModuleClassRec() {
    oid++;
    id = oid;

Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "FTModuleClassRec constructor called!!");
    module_flags = 0;
    module_type = FTTags.ModuleType.UNKNOWN;
    module_name = null;
    module_version = 1;
    module_requires = 0;
    module_interface = null;
  }
    
................................................................................
  public String toString() {
      return mySelf()+"!";
    }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("..module_flags: "+Integer.toHexString(module_flags)+'\n');
    str.append("..module_type: "+module_type.getDescription()+'\n');
    str.append("..module_name: "+module_name+'\n');
    str.append("..module_version: "+module_version+'\n');
    str.append("..module_requires: "+module_requires+'\n');
    str.append("..module_interface: "+module_interface);
    return str.toString();
  }
................................................................................

  /* ==================== moduleDone ================================== */
  public void moduleDone() {
    Log.e(TAG, "moduleDone not yet implemented");
  }

  /* ==================== getModule_flags ================================== */
  public int getModule_flags() {
    return module_flags;
  }

  /* ==================== setModule_flags ================================== */
  public void setModule_flags(int module_flags) {
    this.module_flags = module_flags;
  }

  /* ==================== getModule_type ================================== */
  public FTTags.ModuleType getModule_type() {
    return module_type;
  }







>
>
>







|












|







 







|







 







|




|







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
..
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

import android.util.Log;
import android.util.SparseArray;

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.TTUtil;

import java.util.HashSet;
import java.util.Set;

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

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

  protected Set<Flags.Module> module_flags;
  protected FTTags.ModuleType module_type;
  protected String module_name;
  protected int module_version;
  protected int module_requires;
  protected FTModuleInterface module_interface;

  /* ==================== FTModuleClassRec ================================== */
  public FTModuleClassRec() {
    oid++;
    id = oid;

Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "FTModuleClassRec constructor called!!");
    module_flags = new HashSet<>();
    module_type = FTTags.ModuleType.UNKNOWN;
    module_name = null;
    module_version = 1;
    module_requires = 0;
    module_interface = null;
  }
    
................................................................................
  public String toString() {
      return mySelf()+"!";
    }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("..module_flags: "+module_flags+'\n');
    str.append("..module_type: "+module_type.getDescription()+'\n');
    str.append("..module_name: "+module_name+'\n');
    str.append("..module_version: "+module_version+'\n');
    str.append("..module_requires: "+module_requires+'\n');
    str.append("..module_interface: "+module_interface);
    return str.toString();
  }
................................................................................

  /* ==================== moduleDone ================================== */
  public void moduleDone() {
    Log.e(TAG, "moduleDone not yet implemented");
  }

  /* ==================== getModule_flags ================================== */
  public Set<Flags.Module> getModule_flags() {
    return module_flags;
  }

  /* ==================== setModule_flags ================================== */
  public void setModule_flags(Set<Flags.Module> module_flags) {
    this.module_flags = module_flags;
  }

  /* ==================== getModule_type ================================== */
  public FTTags.ModuleType getModule_type() {
    return module_type;
  }

Changes to aftbase/FTModules.java.

12
13
14
15
16
17
18

19
20
21
22
23

24
25
26
27
28
29
30
...
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
 */

package org.apwtcl.apwfreetypelib.aftbase;

import android.util.Log;
import android.util.SparseArray;


import org.apwtcl.apwfreetypelib.aftraster.FTRaster1RendererClass;
import org.apwtcl.apwfreetypelib.aftraster.FTSmoothRendererClass;
import org.apwtcl.apwfreetypelib.aftsfnt.SfntModuleClass;
import org.apwtcl.apwfreetypelib.afttruetype.TTDriverClass;
import org.apwtcl.apwfreetypelib.afttruetype.TTDriverRec;

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.TTUtil;

import java.util.*;

................................................................................
        return FTError.ErrorTag.INIT_BAD_ARGUMENT;
    }
    // base initialization
    module.library = library;
    module.module_clazz = module_clazz;
    /* check whether the module is a renderer - this must be performed */
    /* before the normal module initialization                         */
    int flags = module.module_clazz.module_flags;
    if (Flags.Module.isRenderer(flags)) {
FTDebug.Debug(0, FTDebug.DebugTag.DBG_INIT,  TAG, "FTAddModule module is renderer: "+module.module_clazz.module_name+" "+Flags.Module.RENDERER);
        // add to the renderers list
FTDebug.Debug(0,  FTDebug.DebugTag.DBG_INIT,  TAG, "REND1: "+module.module_clazz.module_name);
      error = renderer.addRenderer();
      if (error != FTError.ErrorTag.ERR_OK) {
        if (Flags.Module.isFontDriver(flags)) {
          if (Flags.Module.isDriverNoOutlines(flags)) {
            driver.getGlyph_loader().FTGlyphLoaderDone();
          }
        }
        if (Flags.Module.isRenderer(flags)) {
          if (renderer.clazz != null && renderer.glyph_format == FTTags.GlyphFormat.OUTLINE &&
               renderer.raster != null) {
            renderer.clazz.rasterDone(renderer.raster);
          }
        }
//          FT_FREE(module);
        return error;
      }
    }
    // is the module a auto-hinter?
    if (Flags.Module.isHinter(flags)) {
      library.setAuto_hinter(module);
    }
    // if the module is a font driver
    if (Flags.Module.isFontDriver(flags)) {
FTDebug.Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "FT_Add_Module module is font driver: "+module.module_clazz.module_name+" "+Flags.Module.FONT_DRIVER);
      // allocate glyph loader if needed
      driver.setDriver_clazz((FTDriverClassRec)module.module_clazz);
      int driver_flags = driver.module_clazz.module_flags;
      if (! Flags.Module.isDriverNoOutlines(driver_flags)) {
FTDebug.Debug(0,  FTDebug.DebugTag.DBG_INIT,  TAG, "FT_Add_Module module uses outlines: "+module.module_clazz.module_name+" "+Flags.Module.FONT_DRIVER);






        driver.setGlyph_loader(new FTGlyphLoaderRec());





      }
    }
FTDebug.Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "FT_Add_Module call module_init for module: "+module.module_clazz.module_name);
    error = module_clazz.moduleInit(module);
    if (error == FTError.ErrorTag.ERR_OK) {
      /* add module to the library's table */
      library.setModule(library.getNum_modules(),  module);
      library.setNum_modules(library.getNum_modules() + 1);
      return error;
    }
    if (Flags.Module.isFontDriver(flags)) {
      driver.module_clazz = module.module_clazz;
      if (!Flags.Module.isDriverNoOutlines(flags)) {
        driver.getGlyph_loader().FTGlyphLoaderDone();
      }
    }
    if (Flags.Module.isRenderer(flags)) {
      renderer.module_clazz = module.module_clazz;
      if (renderer.clazz != null && renderer.glyph_format == FTTags.GlyphFormat.OUTLINE &&
           renderer.raster != null) {
        renderer.clazz.rasterDone(renderer.raster);
      }
    }
    return error;
  }

}







>





>







 







|
|





|
|



|










|



|



|
|

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










|

|



|










12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
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
 */

package org.apwtcl.apwfreetypelib.aftbase;

import android.util.Log;
import android.util.SparseArray;

import org.apwtcl.apwfreetypelib.aftraster.FTGrayOutlineClass;
import org.apwtcl.apwfreetypelib.aftraster.FTRaster1RendererClass;
import org.apwtcl.apwfreetypelib.aftraster.FTSmoothRendererClass;
import org.apwtcl.apwfreetypelib.aftsfnt.SfntModuleClass;
import org.apwtcl.apwfreetypelib.afttruetype.TTDriverClass;
import org.apwtcl.apwfreetypelib.afttruetype.TTDriverRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTGlyphLoaderRec;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.TTUtil;

import java.util.*;

................................................................................
        return FTError.ErrorTag.INIT_BAD_ARGUMENT;
    }
    // base initialization
    module.library = library;
    module.module_clazz = module_clazz;
    /* check whether the module is a renderer - this must be performed */
    /* before the normal module initialization                         */
    Set<Flags.Module> flags = module.module_clazz.module_flags;
    if (flags.contains(Flags.Module.RENDERER)) {
FTDebug.Debug(0, FTDebug.DebugTag.DBG_INIT,  TAG, "FTAddModule module is renderer: "+module.module_clazz.module_name+" "+Flags.Module.RENDERER);
        // add to the renderers list
FTDebug.Debug(0,  FTDebug.DebugTag.DBG_INIT,  TAG, "REND1: "+module.module_clazz.module_name);
      error = renderer.addRenderer();
      if (error != FTError.ErrorTag.ERR_OK) {
        if (flags.contains(Flags.Module.FONT_DRIVER)) {
          if (flags.contains(Flags.Module.DRIVER_NO_OUTLINES)) {
            driver.getGlyph_loader().FTGlyphLoaderDone();
          }
        }
        if (flags.contains(Flags.Module.RENDERER)) {
          if (renderer.clazz != null && renderer.glyph_format == FTTags.GlyphFormat.OUTLINE &&
               renderer.raster != null) {
            renderer.clazz.rasterDone(renderer.raster);
          }
        }
//          FT_FREE(module);
        return error;
      }
    }
    // is the module a auto-hinter?
    if (flags.contains(Flags.Module.HINTER)) {
      library.setAuto_hinter(module);
    }
    // if the module is a font driver
    if (flags.contains(Flags.Module.FONT_DRIVER)) {
FTDebug.Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "FT_Add_Module module is font driver: "+module.module_clazz.module_name+" "+Flags.Module.FONT_DRIVER);
      // allocate glyph loader if needed
      driver.setDriver_clazz((FTDriverClassRec)module.module_clazz);
      Set<Flags.Module> driver_flags = driver.module_clazz.module_flags;
      if (! driver_flags.contains(Flags.Module.DRIVER_NO_OUTLINES)) {
FTDebug.Debug(0,  FTDebug.DebugTag.DBG_INIT,  TAG, "FT_Add_Module module uses outlines: "+module.module_clazz.module_name+" "+Flags.Module.FONT_DRIVER);
        switch (driver.getDriver_clazz().module_type) {
          case TT_DRIVER:
            FTGlyphLoaderRec loader = new TTGlyphLoaderRec();
            loader.getBase().setOutline(new FTGrayOutlineClass());
            loader.getCurrent().setOutline(new FTGrayOutlineClass());
            // FIXME!!!
            driver.setGlyph_loader(loader);
            break;
          default:
            error = FTError.ErrorTag.GLYPH_INVALID_ARGUMENT;
            return error;
        }
      }
    }
FTDebug.Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "FT_Add_Module call module_init for module: "+module.module_clazz.module_name);
    error = module_clazz.moduleInit(module);
    if (error == FTError.ErrorTag.ERR_OK) {
      /* add module to the library's table */
      library.setModule(library.getNum_modules(),  module);
      library.setNum_modules(library.getNum_modules() + 1);
      return error;
    }
    if (flags.contains(Flags.Module.FONT_DRIVER)) {
      driver.module_clazz = module.module_clazz;
      if (!flags.contains(Flags.Module.DRIVER_NO_OUTLINES)) {
        driver.getGlyph_loader().FTGlyphLoaderDone();
      }
    }
    if (flags.contains(Flags.Module.RENDERER)) {
      renderer.module_clazz = module.module_clazz;
      if (renderer.clazz != null && renderer.glyph_format == FTTags.GlyphFormat.OUTLINE &&
           renderer.raster != null) {
        renderer.clazz.rasterDone(renderer.raster);
      }
    }
    return error;
  }

}

Changes to aftbase/Flags.java.

17
18
19
20
21
22
23

24
25
26
27
28
29
30
..
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

import java.util.HashSet;
import java.util.Set;

public class Flags {

  public enum Module {

    FONT_DRIVER(1, "this module is a font driver"),
    RENDERER(2, "this module is a renderer"),
    HINTER(4, "this module is a glyph hinter"),
    DRIVER_STYLER(8, "this module is a styler"),
    DRIVER_SCALABLE(0x100, " the driver supports scalable fonts"),
    DRIVER_NO_OUTLINES(0x200, "the driver does not support vector outlines"),
    DRIVER_HAS_HINTER(0x400, "the driver provides its own hinter");
................................................................................
      for (Module t : values()) {
        tagToModuleMapping.put(t.val, t);
      }
    }
    private Module(int val, String str) {
      this.val = val;
      this.str = str;






























    }
    public int getVal() {
      return val;
    }
    public String getDescription() {
      return str;
    }

    public static boolean isFontDriver(int flags) {
      return (flags &  Flags.Module.FONT_DRIVER.getVal()) != 0;
    }
    public static boolean isRenderer(int flags) {
      return (flags &  Flags.Module.RENDERER.getVal()) != 0;
    }
    public static boolean isHinter(int flags) {
      return (flags &  Flags.Module.HINTER.getVal()) != 0;
    }
    public static boolean isDriverStyler(int flags) {
      return (flags &  Flags.Module.DRIVER_STYLER.getVal()) != 0;
    }
    public static boolean isDriverScalable(int flags) {
      return (flags &  Flags.Module.DRIVER_SCALABLE.getVal()) != 0;
    }
    public static boolean isDriverNoOutlines(int flags) {
      return (flags &  Flags.Module.DRIVER_NO_OUTLINES.getVal()) != 0;
    }
    public static boolean driverHasHinter(int flags) {
      return (flags &  Flags.Module.DRIVER_HAS_HINTER.getVal()) != 0;
    }

  }

  public enum Face {
    UNKNOWN(0, "Flags Face UNKNOWN"),
    SCALABLE((1 <<  0), "FT_FACE_FLAG_SCALABLE | FT_STYLE_FLAG_ITALIC"),
    FIXED_SIZES((1 <<  1), "FT_FACE_FLAG_FIXED_SIZES | FT_STYLE_FLAG_BOLD"),
    FIXED_WIDTH((1 <<  2), "FT_FACE_FLAG_FIXED_WIDTH"),







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
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

import java.util.HashSet;
import java.util.Set;

public class Flags {

  public enum Module {
    UNKNOWN(0, "unknown module"),
    FONT_DRIVER(1, "this module is a font driver"),
    RENDERER(2, "this module is a renderer"),
    HINTER(4, "this module is a glyph hinter"),
    DRIVER_STYLER(8, "this module is a styler"),
    DRIVER_SCALABLE(0x100, " the driver supports scalable fonts"),
    DRIVER_NO_OUTLINES(0x200, "the driver does not support vector outlines"),
    DRIVER_HAS_HINTER(0x400, "the driver provides its own hinter");
................................................................................
      for (Module t : values()) {
        tagToModuleMapping.put(t.val, t);
      }
    }
    private Module(int val, String str) {
      this.val = val;
      this.str = str;
    }
    public static Set<Module> makeTableTagSet(int value) {
      Set<Module> flags = new HashSet<>();
      for (Module t : values()) {
        if ((value & t.getVal()) != 0) {
          flags.add(t);
        }
      }
      return flags;
    }
    public static String ModuleSetToString(Set<Load> flags) {
      StringBuffer str = new StringBuffer();
      for (Module t : values()) {
        if (flags.contains(t)) {
          str.append(" "+t.toString());
        }
      }
      if (flags.isEmpty()) {
        str.append(" "+UNKNOWN);
      }
      return str.toString();
    }
    public static int ModuleSetToInt(Set<Load> flags) {
      int val = 0;
      for (Module t : values()) {
        if (flags.contains(t)) {
          val += t.getVal();
        }
      }
      return val;
    }
    public int getVal() {
      return val;
    }
    public String getDescription() {
      return str;
    }























  }

  public enum Face {
    UNKNOWN(0, "Flags Face UNKNOWN"),
    SCALABLE((1 <<  0), "FT_FACE_FLAG_SCALABLE | FT_STYLE_FLAG_ITALIC"),
    FIXED_SIZES((1 <<  1), "FT_FACE_FLAG_FIXED_SIZES | FT_STYLE_FLAG_BOLD"),
    FIXED_WIDTH((1 <<  2), "FT_FACE_FLAG_FIXED_WIDTH"),

Changes to aftraster/FTRaster1RendererClass.java.

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
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

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



public class FTRaster1RendererClass extends FTRendererClassRec {
    private static int oid = 0;

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

    /* ==================== FTRaster1RendererClass ================================== */
    public FTRaster1RendererClass() {
      super();
      oid++;
      id = oid;

      module_flags = Flags.Module.RENDERER.getVal();  /* a renderer */

      module_type = FTTags.ModuleType.FT_RENDERER;
      module_name = "raster1";     /* driver name */
      module_version = 0x10000;   /* driver version 1.0 */
      module_requires = 0x20000;  /* driver requires FreeType 2.0 or higher */
      module_interface = null;     /* module specific interface */
      glyph_format = FTTags.GlyphFormat.OUTLINE;
      raster_type = FTTags.RasterType.Black;







>
>













|
>







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
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

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

import java.util.HashSet;

public class FTRaster1RendererClass extends FTRendererClassRec {
    private static int oid = 0;

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

    /* ==================== FTRaster1RendererClass ================================== */
    public FTRaster1RendererClass() {
      super();
      oid++;
      id = oid;

      module_flags = new HashSet<>();
      module_flags.add(Flags.Module.RENDERER);  /* a renderer */
      module_type = FTTags.ModuleType.FT_RENDERER;
      module_name = "raster1";     /* driver name */
      module_version = 0x10000;   /* driver version 1.0 */
      module_requires = 0x20000;  /* driver requires FreeType 2.0 or higher */
      module_interface = null;     /* module specific interface */
      glyph_format = FTTags.GlyphFormat.OUTLINE;
      raster_type = FTTags.RasterType.Black;

Changes to aftraster/FTSmoothRendererClass.java.

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
...
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361


362
363
364
365
366
367
368
369
370
371
372
373
374
375


376
377
378
379
380
381


382
383
384
385
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

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



public class FTSmoothRendererClass extends FTRendererClassRec {
  private static int oid = 0;

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

  /* ==================== FTSmoothRendererClass ================================== */
  public FTSmoothRendererClass() {
    super();
    oid++;
    id = oid;

    module_flags = Flags.Module.RENDERER.getVal();  /* a renderer */

    module_type = FTTags.ModuleType.FT_RENDERER;
    module_name = "smooth";     /* driver name */
    module_version = 0x10000;   /* driver version 1.0 */
    module_requires = 0x20000;  /* driver requires FreeType 2.0 or higher */
    module_interface = null;    /* module specific interface */
    glyph_format = FTTags.GlyphFormat.OUTLINE;
    raster_type = FTTags.RasterType.GRAY;
................................................................................
//    return ft_smooth_set_mode();
  }

  /* ==================== rasterNew ===================================== */
  @Override
  public FTError.ErrorTag rasterNew(FTReference<FTRasterRec> raster_ref) {
Debug(0, DebugTag.DBG_INIT, TAG, "gray_raster_new");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;;
    grayTRasterRec raster = new grayTRasterRec();
    raster_ref.Set(raster);
    return error;
  }


  /* ==================== rasterReset ===================================== */
  @Override
  public FTError.ErrorTag rasterReset(FTRasterRec raster, byte[] raster_pool, int raster_pool_size) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;;
    ((grayTRasterRec)raster).getWorker().gray_raster_reset((grayTRasterRec)raster, raster_pool, raster_pool_size);


    ((grayTRasterRec)raster).setBand_size(((grayTRasterRec)raster).getWorker().getBand_size());
    return error;
  }

  /* ==================== rasterSetMode ===================================== */
  @Override
  public FTError.ErrorTag rasterSetMode() {
    Log.e(TAG, "rasterSetMode");
    return FTError.ErrorTag.ERR_OK;
  }

  /* ==================== rasterRender ===================================== */
  @Override
  public FTError.ErrorTag rasterRender(FTRasterRec raster, FTRasterParamsRec params) {


    return ((grayTRasterRec)raster).getWorker().gray_raster_render(((grayTRasterRec)raster), params);
  }

  /* ==================== rasterDone ===================================== */
  @Override
  public FTError.ErrorTag rasterDone(FTRasterRec raster) {


    return ((grayTRasterRec)raster).getWorker().gray_raster_done();
  }

}







>
>













|
>







 







|









|
|
>
>
|













>
>
|





>
>
|



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
...
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

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

import java.util.HashSet;

public class FTSmoothRendererClass extends FTRendererClassRec {
  private static int oid = 0;

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

  /* ==================== FTSmoothRendererClass ================================== */
  public FTSmoothRendererClass() {
    super();
    oid++;
    id = oid;

    module_flags = new HashSet<>();
    module_flags.add(Flags.Module.RENDERER);  /* a renderer */
    module_type = FTTags.ModuleType.FT_RENDERER;
    module_name = "smooth";     /* driver name */
    module_version = 0x10000;   /* driver version 1.0 */
    module_requires = 0x20000;  /* driver requires FreeType 2.0 or higher */
    module_interface = null;    /* module specific interface */
    glyph_format = FTTags.GlyphFormat.OUTLINE;
    raster_type = FTTags.RasterType.GRAY;
................................................................................
//    return ft_smooth_set_mode();
  }

  /* ==================== rasterNew ===================================== */
  @Override
  public FTError.ErrorTag rasterNew(FTReference<FTRasterRec> raster_ref) {
Debug(0, DebugTag.DBG_INIT, TAG, "gray_raster_new");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    grayTRasterRec raster = new grayTRasterRec();
    raster_ref.Set(raster);
    return error;
  }


  /* ==================== rasterReset ===================================== */
  @Override
  public FTError.ErrorTag rasterReset(FTRasterRec raster, byte[] raster_pool, int raster_pool_size) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    grayTRasterRec traster = (grayTRasterRec)raster;

    traster.getWorker().gray_raster_reset(traster, raster_pool, raster_pool_size);
    traster.setBand_size(traster.getWorker().getBand_size());
    return error;
  }

  /* ==================== rasterSetMode ===================================== */
  @Override
  public FTError.ErrorTag rasterSetMode() {
    Log.e(TAG, "rasterSetMode");
    return FTError.ErrorTag.ERR_OK;
  }

  /* ==================== rasterRender ===================================== */
  @Override
  public FTError.ErrorTag rasterRender(FTRasterRec raster, FTRasterParamsRec params) {
    grayTRasterRec traster = (grayTRasterRec)raster;

    return traster.getWorker().gray_raster_render(traster, params);
  }

  /* ==================== rasterDone ===================================== */
  @Override
  public FTError.ErrorTag rasterDone(FTRasterRec raster) {
    grayTRasterRec traster = (grayTRasterRec)raster;

    return traster.getWorker().gray_raster_done();
  }

}

Changes to aftraster/grayTWorkerRec.java.

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  /* ==================== grayTWorker ================================== */
  public grayTWorkerRec() {
    int i;

    oid++;
    id = oid;
    target = new FTBitmapRec();
    outline = new FTOutlineRec();
    clip_box = new FTBBoxRec();
    for (i = 0; i < FTSpanRec.FT_MAX_GRAY_SPANS; i++) {
      gray_spans[i] = new FTSpanRec();
    }
    for (i = 0; i < MaxBezier * 3 + 1; i++) {
      bez_stack[i] = new FTVectorRec();
    }







|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  /* ==================== grayTWorker ================================== */
  public grayTWorkerRec() {
    int i;

    oid++;
    id = oid;
    target = new FTBitmapRec();
    outline = new FTGrayOutlineClass();
    clip_box = new FTBBoxRec();
    for (i = 0; i < FTSpanRec.FT_MAX_GRAY_SPANS; i++) {
      gray_spans[i] = new FTSpanRec();
    }
    for (i = 0; i < MaxBezier * 3 + 1; i++) {
      bez_stack[i] = new FTVectorRec();
    }

Changes to aftsfnt/SfntModuleClass.java.

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
import org.apwtcl.apwfreetypelib.aftbase.FTModuleClassRec;
import org.apwtcl.apwfreetypelib.aftbase.FTModuleRec;
import org.apwtcl.apwfreetypelib.aftbase.FTModules;
import org.apwtcl.apwfreetypelib.aftbase.FTRendererRec;
import org.apwtcl.apwfreetypelib.aftbase.FTTags;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;



public class SfntModuleClass extends FTModuleClassRec {
  private static int oid = 0;

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

  /* ==================== SfntModuleClass ================================== */
  public SfntModuleClass() {
    super();
    oid++;
    id = oid;

    module_flags = 0;  /* not a font driver or renderer */
    module_type = FTTags.ModuleType.FT_MODULE;
    module_name = "sfnt";        /* driver name */
    module_version = 0x10000;   /* driver version 1.0 */
    module_requires = 0x20000;  /* driver requires FreeType 2.0 or higher */
    module_interface = new FTSfntInterfaceClass(); /* "Sfnt_Interface"; /* module specific interface */
Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "SfntModuleClass constructor called!!");
  }







>
>













|







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
import org.apwtcl.apwfreetypelib.aftbase.FTModuleClassRec;
import org.apwtcl.apwfreetypelib.aftbase.FTModuleRec;
import org.apwtcl.apwfreetypelib.aftbase.FTModules;
import org.apwtcl.apwfreetypelib.aftbase.FTRendererRec;
import org.apwtcl.apwfreetypelib.aftbase.FTTags;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;

import java.util.HashSet;

public class SfntModuleClass extends FTModuleClassRec {
  private static int oid = 0;

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

  /* ==================== SfntModuleClass ================================== */
  public SfntModuleClass() {
    super();
    oid++;
    id = oid;

    module_flags = new HashSet<>(); /* not a font driver or renderer */
    module_type = FTTags.ModuleType.FT_MODULE;
    module_name = "sfnt";        /* driver name */
    module_version = 0x10000;   /* driver version 1.0 */
    module_requires = 0x20000;  /* driver requires FreeType 2.0 or higher */
    module_interface = new FTSfntInterfaceClass(); /* "Sfnt_Interface"; /* module specific interface */
Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "SfntModuleClass constructor called!!");
  }

Changes to afttruetype/TTDriverClass.java.

21
22
23
24
25
26
27

28
29
30
31
32
33
34
..
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.*;
import org.apwtcl.apwfreetypelib.aftsfnt.FTSfntInterfaceClass;
import org.apwtcl.apwfreetypelib.aftttinterpreter.TTRunInstructions;
import org.apwtcl.apwfreetypelib.aftutil.*;


import java.util.Set;

public class TTDriverClass extends FTDriverClassRec {
  private static int oid = 0;

  private int id;
  private static String TAG = "TTDriverClass";
................................................................................
  /* ==================== TTDriverClass ================================== */
  public TTDriverClass() {
    super();
    oid++;
    id = oid;

Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "TTDriverClass constructor called!!");

    module_flags = (Flags.Module.FONT_DRIVER.getVal() |
         Flags.Module.DRIVER_SCALABLE.getVal() |
         Flags.Module.DRIVER_HAS_HINTER.getVal());  /* a font driver */
    module_type = FTTags.ModuleType.TT_DRIVER;
    module_name = "truetype";   /* driver name */
    module_version = 0x10000;   /* driver version 1.0 */
    module_requires = 0x20000;  /* driver requires FreeType 2.0 or higher */
    module_interface = null;    /* driver specific interface */
  }
    







>







 







>
|
|
|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.*;
import org.apwtcl.apwfreetypelib.aftsfnt.FTSfntInterfaceClass;
import org.apwtcl.apwfreetypelib.aftttinterpreter.TTRunInstructions;
import org.apwtcl.apwfreetypelib.aftutil.*;

import java.util.HashSet;
import java.util.Set;

public class TTDriverClass extends FTDriverClassRec {
  private static int oid = 0;

  private int id;
  private static String TAG = "TTDriverClass";
................................................................................
  /* ==================== TTDriverClass ================================== */
  public TTDriverClass() {
    super();
    oid++;
    id = oid;

Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "TTDriverClass constructor called!!");
    module_flags = new HashSet<>();
    module_flags.add(Flags.Module.FONT_DRIVER);
    module_flags.add(Flags.Module.DRIVER_SCALABLE);
    module_flags.add(Flags.Module.DRIVER_HAS_HINTER);  /* a font driver */
    module_type = FTTags.ModuleType.TT_DRIVER;
    module_name = "truetype";   /* driver name */
    module_version = 0x10000;   /* driver version 1.0 */
    module_requires = 0x20000;  /* driver requires FreeType 2.0 or higher */
    module_interface = null;    /* driver specific interface */
  }
    

Changes to afttruetype/TTGlyphSlotRec.java.

15
16
17
18
19
20
21

22
23
24
25
26
27
28
..
30
31
32
33
34
35
36


37
38
39
40
41
42
43
..
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

  /* ===================================================================== */
  /*    TTGlyphSlotRec                                                      */
  /*                                                                       */
  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftbase.*;

import org.apwtcl.apwfreetypelib.aftutil.*;

import java.util.Set;

public class TTGlyphSlotRec extends FTGlyphSlotRec {
  private static int oid = 0;

................................................................................
  private static String TAG = "TTGlyphSlotRec";

  /* ==================== TTGlyphSLotRec ================================== */
  public TTGlyphSlotRec() {
    super();
    oid++;
    id = oid;


  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
    return TAG+"!"+id+"!";
  }
        
................................................................................
   *    FreeType error code.  0 means success.
   *
   * =====================================================================
   */
  public FTError.ErrorTag TTLoadGlyph(TTSizeRec ttsize, int glyph_index, Set<Flags.Load> load_flags) {
    FTError.ErrorTag error;
    TTLoaderRec loader;
    FTReference<FTOutlineRec> outline_ref = new FTReference<FTOutlineRec>();

    Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("TT_Load_Glyph: glyph_index: %d size: " + ttsize, glyph_index));
    error = FTError.ErrorTag.ERR_OK;
      /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
    if (!load_flags.contains(Flags.Load.NO_SCALE) && ttsize.getTtmetrics().isValid() == false) {
      error = FTError.ErrorTag.LOAD_INVALID_SIZE_HANDLE;
      return error;
    }
    if (load_flags.contains(Flags.Load.SBITS_ONLY)) {
      error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
................................................................................
      /* main loading loop */
    error = loader.load_truetype_glyph(glyph_index, 0, false);
    if (error == FTError.ErrorTag.ERR_OK) {
      if (format == FTTags.GlyphFormat.COMPOSITE) {
        num_subglyphs = loader.getGloader().getBase().getNum_subglyphs();
        subglyphs = loader.getGloader().getBase().getSubglyphs();
      } else {
        outline = loader.getGloader().getBase();
        outline.setFlags(outline.getFlags() & ~Flags.Outline.SINGLE_PASS.getVal());
          /* Translate array so that (0,0) is the glyph's origin.  Note  */
          /* that this behaviour is independent on the value of bit 1 of */
          /* the `flags' field in the `head' table -- at least major     */
          /* applications like Acroread indicate that.                   */
loader.getBase().showLoaderZone("TTLoadGlyph", null);
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("loader.pp1.x: %d", loader.getPp1().getX()));







>







 







>
>







 







<

|
<







 







|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
82
83
84
85
86
87
88

89
90

91
92
93
94
95
96
97
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

  /* ===================================================================== */
  /*    TTGlyphSlotRec                                                      */
  /*                                                                       */
  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftbase.*;
import org.apwtcl.apwfreetypelib.aftraster.FTGrayOutlineClass;
import org.apwtcl.apwfreetypelib.aftutil.*;

import java.util.Set;

public class TTGlyphSlotRec extends FTGlyphSlotRec {
  private static int oid = 0;

................................................................................
  private static String TAG = "TTGlyphSlotRec";

  /* ==================== TTGlyphSLotRec ================================== */
  public TTGlyphSlotRec() {
    super();
    oid++;
    id = oid;
    raster_type = FTTags.RasterType.GRAY;
    outline = new FTGrayOutlineClass();
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
    return TAG+"!"+id+"!";
  }
        
................................................................................
   *    FreeType error code.  0 means success.
   *
   * =====================================================================
   */
  public FTError.ErrorTag TTLoadGlyph(TTSizeRec ttsize, int glyph_index, Set<Flags.Load> load_flags) {
    FTError.ErrorTag error;
    TTLoaderRec loader;


Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("TT_Load_Glyph: glyph_index: %d size: " + ttsize, glyph_index));

      /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
    if (!load_flags.contains(Flags.Load.NO_SCALE) && ttsize.getTtmetrics().isValid() == false) {
      error = FTError.ErrorTag.LOAD_INVALID_SIZE_HANDLE;
      return error;
    }
    if (load_flags.contains(Flags.Load.SBITS_ONLY)) {
      error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
................................................................................
      /* main loading loop */
    error = loader.load_truetype_glyph(glyph_index, 0, false);
    if (error == FTError.ErrorTag.ERR_OK) {
      if (format == FTTags.GlyphFormat.COMPOSITE) {
        num_subglyphs = loader.getGloader().getBase().getNum_subglyphs();
        subglyphs = loader.getGloader().getBase().getSubglyphs();
      } else {
        outline = loader.getGloader().getBase().getOutline();
        outline.setFlags(outline.getFlags() & ~Flags.Outline.SINGLE_PASS.getVal());
          /* Translate array so that (0,0) is the glyph's origin.  Note  */
          /* that this behaviour is independent on the value of bit 1 of */
          /* the `flags' field in the `head' table -- at least major     */
          /* applications like Acroread indicate that.                   */
loader.getBase().showLoaderZone("TTLoadGlyph", null);
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("loader.pp1.x: %d", loader.getPp1().getX()));

Changes to afttruetype/TTLoaderRec.java.

703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
    }
      /* round pp2 and pp4 */
    zone.setCurPoint_x(zone.getN_points() - 3, FTCalc.FT_PIX_ROUND(zone.getCurPoint_x(zone.getN_points() - 3)));
    zone.setCurPoint_y(zone.getN_points() - 1, FTCalc.FT_PIX_ROUND(zone.getCurPoint_y(zone.getN_points() - 1)));
    if (n_ins > 0) {
      boolean debug;
      FTGlyphLoaderRec gloader = this.gloader;
      FTOutlineRec current_outline = gloader.getCurrent();

      error = exec.TTSetCodeRange(TTInterpTags.CodeRange.GLYPH, exec.glyphIns, null, n_ins);
      if (error != FTError.ErrorTag.ERR_OK) {
        return error;
      }
      exec.is_composite = is_composite;
      exec.pts.copy(zone);







|







703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
    }
      /* round pp2 and pp4 */
    zone.setCurPoint_x(zone.getN_points() - 3, FTCalc.FT_PIX_ROUND(zone.getCurPoint_x(zone.getN_points() - 3)));
    zone.setCurPoint_y(zone.getN_points() - 1, FTCalc.FT_PIX_ROUND(zone.getCurPoint_y(zone.getN_points() - 1)));
    if (n_ins > 0) {
      boolean debug;
      FTGlyphLoaderRec gloader = this.gloader;
      FTOutlineRec current_outline = gloader.getCurrent().getOutline();

      error = exec.TTSetCodeRange(TTInterpTags.CodeRange.GLYPH, exec.glyphIns, null, n_ins);
      if (error != FTError.ErrorTag.ERR_OK) {
        return error;
      }
      exec.is_composite = is_composite;
      exec.pts.copy(zone);