apwfreetypelib

Check-in [dac67504dc]
Login

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

Overview
Comment:fixes and make a Set for Flags.Face.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:dac67504dca2ff18ac8a66d24df866b5dcefcac9
User & Date: arnulf 2015-02-07 21:23:26
Context
2015-02-08
15:53
move mist of FTGrayOutlineFuncsClass methods to GrayTWorkerRec, some fixes. check-in: b1184a69d5 user: arnulf tags: trunk
2015-02-07
21:23
fixes and make a Set for Flags.Face. check-in: dac67504dc user: arnulf tags: trunk
16:49
fixes. check-in: 0f24cb935e user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to aftbase/FTAutoHinterInterfaceClass.java.

18
19
20
21
22
23
24


25
26
27
28
29
30
31
..
71
72
73
74
75
76
77
78

79
80
81
82
83
84
  /*                                                                       */
  /* ===================================================================== */

import android.nfc.Tag;
import android.util.Log;

import org.apwtcl.apwfreetypelib.aftutil.FTError;



public class FTAutoHinterInterfaceClass  extends FTModuleInterface {
  private static int oid = 0;

  private int id;
  private final static String TAG = "FTAutoHinterInterfaceClass";

................................................................................
  public FTError.ErrorTag doneGlobalHints() {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    Log.e(TAG, "doneGlobalHints not yet implemented");
    return error;
  }

  /* ==================== loadGlyph ================================== */
  public FTError.ErrorTag loadGlyph(FTModuleRec hinter, FTGlyphSlotRec slot, FTSizeRec size, int glyph_index, int load_flags) {

    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    Log.e(TAG, "loadGlyph not yet implemented");
    return error;
  }

}







>
>







 







|
>






18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
  /*                                                                       */
  /* ===================================================================== */

import android.nfc.Tag;
import android.util.Log;

import org.apwtcl.apwfreetypelib.aftutil.FTError;

import java.util.Set;

public class FTAutoHinterInterfaceClass  extends FTModuleInterface {
  private static int oid = 0;

  private int id;
  private final static String TAG = "FTAutoHinterInterfaceClass";

................................................................................
  public FTError.ErrorTag doneGlobalHints() {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    Log.e(TAG, "doneGlobalHints not yet implemented");
    return error;
  }

  /* ==================== loadGlyph ================================== */
  public FTError.ErrorTag loadGlyph(FTModuleRec hinter, FTGlyphSlotRec slot, FTSizeRec size, int glyph_index, Set<Flags.Load>
      load_flags) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    Log.e(TAG, "loadGlyph not yet implemented");
    return error;
  }

}

Changes to aftbase/FTDriverClassRec.java.

17
18
19
20
21
22
23


24
25
26
27
28
29
30
..
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
  /*    FTDriverClassRec                                                          */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftutil.*;



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

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

................................................................................
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Log.e(TAG, "doneSlot not yet implemented");
    return error;
  }

  /* ==================== loadGlyph ===================================== */
  public FTError.ErrorTag loadGlyph(FTGlyphSlotRec slot, FTSizeRec size, int glyph_index, int load_flags) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Log.e(TAG, "loadGlyph not yet implemented");
    return error;
  }

  /* ==================== getKerning ===================================== */







>
>







 







|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  /*    FTDriverClassRec                                                          */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftutil.*;

import java.util.Set;

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

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

................................................................................
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Log.e(TAG, "doneSlot not yet implemented");
    return error;
  }

  /* ==================== loadGlyph ===================================== */
  public FTError.ErrorTag loadGlyph(FTGlyphSlotRec slot, FTSizeRec size, int glyph_index, Set<Flags.Load> load_flags) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Log.e(TAG, "loadGlyph not yet implemented");
    return error;
  }

  /* ==================== getKerning ===================================== */

Changes to aftbase/FTFaceRec.java.

14
15
16
17
18
19
20


21
22
23
24
25
26
27
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
...
202
203
204
205
206
207
208
209


210
211
212
213
214
215
216
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
...
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
...
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
...
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558










559
560
561
562
563
564
565
566
567
568
569
570
571
572
package org.apwtcl.apwfreetypelib.aftbase;

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

import java.io.*;



  /* ===================================================================== */
  /*    FTFaceRec                                                          */
  /*                                                                       */
  /* <Description>                                                         */
  /*    FreeType root face class structure.  A face object models a        */
  /*    typeface in a font file.                                           */
................................................................................
  private static int oid = 0;

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

  private int num_faces = 0;
  private int face_index = 0;
  private int face_flags = Flags.Face.UNKNOWN.getVal();
  private int style_flags = Flags.FontStyle.NONE.getVal();
  private int num_glyphs = 0;
  private String family_name = null;
  private String style_name = null;
  private int num_fixed_sizes = 0;
  private FTBitmapSize[] available_sizes = null;
  private int num_charmaps = 0;
  public FTCharMapRec[] charmaps = null;
................................................................................
  private FTListRec sizes_list = null;
  private FTFaceInternalRec internal = null;

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


    bbox = new FTBBoxRec();
    sizes_list = new FTListRec();
    internal = new FTFaceInternalRec();
Debug(0, DebugTag.DBG_INIT, TAG, "FTFaceRec constructor: "+mySelf()+"!");
  }
    
  /* ==================== mySelf ================================== */
................................................................................
   * FTNewFace
   * =====================================================================
   */
  public static FTError.ErrorTag FTNewFace(FTLibraryRec library, String pathname, int face_index, FTReference<FTFaceRec> face_ref) {
    FTOpenArgsRec args = new FTOpenArgsRec();
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "FTNewFace: pathname: "+pathname+"!");
    /* test for valid `library' and `face_ref' delayed to FT_Open_Face() */
    if (pathname == null) {
      Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "FTNewFace1 inv arg");
      return FTError.ErrorTag.INTERP_INVALID_ARGUMENT;
    }
    args.setFlags(FTUtilFlags.StreamOpen.PATHNAME.getVal());
    args.setPathname(pathname);
................................................................................
        FTTrace.Trace(7, TAG, "FT_Open_Face: Return "+error);
        return error;
      }
    }
    FTTrace.Trace(7, TAG, "FT_Open_Face: New face object, adding to list stream: "+stream+"!");
      /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
    if (is_external_stream) {
      face.face_flags = face.face_flags | Flags.Face.EXTERNAL_STREAM.getVal();
    }
      /* add the face object to its driver's list */
    node = new FTListNodeRec();
    face.stream = stream;
    node.data = face;
      /* don't assume driver is the same as face->driver, so use */
      /* face->driver instead.                                   */
................................................................................
          return error;
        }
        size = size_ref.Get();
        face.size = size;
      }
    }
      /* some checks */
    if ((face.face_flags & Flags.Face.SCALABLE.getVal()) != 0) {
      if (face.height < 0) {
        face.height = -face.height;
      }
      if ((face.face_flags & Flags.Face.VERTICAL.getVal()) != 0) {
        face.max_advance_height = face.height;
      }
    }
    if ((face.face_flags & Flags.Face.FIXED_SIZES.getVal()) != 0) {
      int i;

      for (i = 0; i < face.num_fixed_sizes; i++) {
        FTBitmapSize bsize = face.available_sizes[i];

        if (bsize.height < 0) {
          bsize.height = -bsize.height;
................................................................................

  /* ==================== setFace_index ================================== */
  public void setFace_index(int face_index) {
    this.face_index = face_index;
  }

  /* ==================== getFace_flags ================================== */
  public int getFace_flags() {
    return face_flags;
  }

  /* ==================== setFace_flags ================================== */
  public void setFace_flags(int face_flags) {
    this.face_flags = face_flags;
  }











  /* ==================== getStyle_flags ================================== */
  public int getStyle_flags() {
    return style_flags;
  }

  /* ==================== setStyle_flags ================================== */
  public void setStyle_flags(int style_flags) {
    this.style_flags = style_flags;
  }

  /* ==================== getNum_glyphs ================================== */
  public int getNum_glyphs() {
    return num_glyphs;
  }







>
>







 







|
|







 







|
>
>







 







|







 







|







 







|



|



|







 







|




|



>
>
>
>
>
>
>
>
>
>

|




|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
...
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
...
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
...
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
...
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
...
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
package org.apwtcl.apwfreetypelib.aftbase;

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

import java.io.*;
import java.util.HashSet;
import java.util.Set;

  /* ===================================================================== */
  /*    FTFaceRec                                                          */
  /*                                                                       */
  /* <Description>                                                         */
  /*    FreeType root face class structure.  A face object models a        */
  /*    typeface in a font file.                                           */
................................................................................
  private static int oid = 0;

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

  private int num_faces = 0;
  private int face_index = 0;
  private Set<Flags.Face> face_flags;
  private Set<Flags.Face> style_flags;
  private int num_glyphs = 0;
  private String family_name = null;
  private String style_name = null;
  private int num_fixed_sizes = 0;
  private FTBitmapSize[] available_sizes = null;
  private int num_charmaps = 0;
  public FTCharMapRec[] charmaps = null;
................................................................................
  private FTListRec sizes_list = null;
  private FTFaceInternalRec internal = null;

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

    face_flags = new HashSet<>();
    style_flags = new HashSet<>();
    bbox = new FTBBoxRec();
    sizes_list = new FTListRec();
    internal = new FTFaceInternalRec();
Debug(0, DebugTag.DBG_INIT, TAG, "FTFaceRec constructor: "+mySelf()+"!");
  }
    
  /* ==================== mySelf ================================== */
................................................................................
   * FTNewFace
   * =====================================================================
   */
  public static FTError.ErrorTag FTNewFace(FTLibraryRec library, String pathname, int face_index, FTReference<FTFaceRec> face_ref) {
    FTOpenArgsRec args = new FTOpenArgsRec();
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "FTNewFace: pathname: " + pathname + "!");
    /* test for valid `library' and `face_ref' delayed to FT_Open_Face() */
    if (pathname == null) {
      Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "FTNewFace1 inv arg");
      return FTError.ErrorTag.INTERP_INVALID_ARGUMENT;
    }
    args.setFlags(FTUtilFlags.StreamOpen.PATHNAME.getVal());
    args.setPathname(pathname);
................................................................................
        FTTrace.Trace(7, TAG, "FT_Open_Face: Return "+error);
        return error;
      }
    }
    FTTrace.Trace(7, TAG, "FT_Open_Face: New face object, adding to list stream: "+stream+"!");
      /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
    if (is_external_stream) {
      face.face_flags.add(Flags.Face.EXTERNAL_STREAM);
    }
      /* add the face object to its driver's list */
    node = new FTListNodeRec();
    face.stream = stream;
    node.data = face;
      /* don't assume driver is the same as face->driver, so use */
      /* face->driver instead.                                   */
................................................................................
          return error;
        }
        size = size_ref.Get();
        face.size = size;
      }
    }
      /* some checks */
    if (face.face_flags.contains(Flags.Face.SCALABLE)) {
      if (face.height < 0) {
        face.height = -face.height;
      }
      if (face.face_flags.contains(Flags.Face.VERTICAL)) {
        face.max_advance_height = face.height;
      }
    }
    if (face.face_flags.contains(Flags.Face.FIXED_SIZES)) {
      int i;

      for (i = 0; i < face.num_fixed_sizes; i++) {
        FTBitmapSize bsize = face.available_sizes[i];

        if (bsize.height < 0) {
          bsize.height = -bsize.height;
................................................................................

  /* ==================== setFace_index ================================== */
  public void setFace_index(int face_index) {
    this.face_index = face_index;
  }

  /* ==================== getFace_flags ================================== */
  public Set<Flags.Face> getFace_flags() {
    return face_flags;
  }

  /* ==================== setFace_flags ================================== */
  public void setFace_flags(Set<Flags.Face> face_flags) {
    this.face_flags = face_flags;
  }

  /* ==================== addFace_flag ================================== */
  public void addFace_flag(Flags.Face face_flag) {
    this.face_flags.add(face_flag);
  }

  /* ==================== removeFace_flag ================================== */
  public void removeFace_flag(Flags.Face face_flag) {
    this.face_flags.remove(face_flag);
  }

  /* ==================== getStyle_flags ================================== */
  public Set<Flags.Face> getStyle_flags() {
    return style_flags;
  }

  /* ==================== setStyle_flags ================================== */
  public void setStyle_flags(Set<Flags.Face> style_flags) {
    this.style_flags = style_flags;
  }

  /* ==================== getNum_glyphs ================================== */
  public int getNum_glyphs() {
    return num_glyphs;
  }

Changes to aftbase/FTGlyphSlotRec.java.

24
25
26
27
28
29
30


31
32
33
34
35
36
37
...
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
282
283
284
285
286
287
288
289

290
291
292
293

294
295
296
297
298
299
300
301
...
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
...
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
395
396
397
398
399
400
401
402
403
404
405
406
...
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
...
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
...
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
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;



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

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

................................................................................
   *    For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is
   *    returned for invalid CID values (this is, for CID values which
   *    don't have a corresponding glyph in the font).  See the discussion
   *    of the @FT_FACE_FLAG_CID_KEYED flag for more details.
   *
   * =====================================================================
   */
  public FTError.ErrorTag LoadGlyph(int glyph_index, int load_flags) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    FTDriverRec driver = null;
    FTLibraryRec library;
    boolean autohint = false;
    FTModuleRec hinter;
    boolean Load_Ok = false;
    TTFaceRec ttface = (TTFaceRec)face;
................................................................................
    /* The validity test for `glyph_index' is performed by the */
    /* font drivers.                                           */
    ft_glyphslot_clear();
    driver  = face.getDriver();
    library = driver.library;
    hinter  = library.getAuto_hinter();
    /* resolve load flags dependencies */
    if ((load_flags & Flags.Load.NO_RECURSE.getVal()) != 0) {

      load_flags |= Flags.Load.NO_SCALE.getVal() | Flags.Load.IGNORE_TRANSFORM.getVal();
    }
    if ((load_flags & Flags.Load.NO_SCALE.getVal()) != 0) {
      load_flags |= Flags.Load.NO_HINTING.getVal() | Flags.Load.NO_BITMAP.getVal();

      load_flags &= ~Flags.Load.RENDER.getVal();
    }
    /*
     * Determine whether we need to auto-hint or not.
     * The general rules are:
     *
     * - Do only auto-hinting if we have a hinter module, a scalable font
     *   format dealing with outlines, and no transforms except simple
................................................................................
     * - Otherwise, auto-hint for LIGHT hinting mode or if there isn't
     *   any hinting bytecode in the TrueType/OpenType font.
     *
     * - Exception: The font is `tricky' and requires the native hinter to
     *   load properly.
     */
    if (hinter != null &&
        ((load_flags & Flags.Load.NO_HINTING.getVal()) == 0) &&
        ((load_flags & Flags.Load.NO_AUTOHINT.getVal()) == 0) &&
        ((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() & Flags.Face.TRICKY.getVal()) == 0) &&
        (((load_flags & Flags.Load.IGNORE_TRANSFORM.getVal()) != 0) ||
            (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 & Flags.Load.FORCE_AUTOHINT.getVal()) != 0) ||
          ((driver.getDriver_clazz().module_flags & Flags.Module.DRIVER_HAS_HINTER.getVal()) == 0)) {
        autohint = true;
      } else {
        int mode = ((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() ||
            ((face.getFace_flags() & Flags.Face.SFNT.getVal()) != 0 &&
                ttface.getLoca_table().getNum_locations() != 0 &&
                ttface.getMax_profile().getMaxSizeOfInstructions() == 0)) {
          autohint = true;
        }
      }
    }
    if (autohint) {
................................................................................
        FTAutoHinterInterfaceClass hinting;

        /* try to load embedded bitmaps first if available            */
        /*                                                            */
        /* XXX: This is really a temporary hack that should disappear */
        /*      promptly with FreeType 2.1!                           */
        /*                                                            */
        if ((face.getFace_flags() & Flags.Face.FIXED_SIZES.getVal()) != 0 &&
            ((load_flags & Flags.Load.NO_BITMAP.getVal()) == 0)) {


          error = driver.driver_clazz.loadGlyph(this, face.getSize(),
                 glyph_index, load_flags | Flags.Load.SBITS_ONLY.getVal());

          if ((error != FTError.ErrorTag.ERR_OK )&& format == FTTags.GlyphFormat.BITMAP) {
            Load_Ok = true;
          }
        }
        if (! Load_Ok) {
          FTFaceInternalRec internal = face.getInternal();
          int transform_flags = internal.getTransform_flags();
................................................................................
          internal.setTransform_flags(transform_flags);
        }
    } else {
      error = driver.getDriver_clazz().loadGlyph(this, face.getSize(), glyph_index, load_flags);
      if (error != FTError.ErrorTag.ERR_OK) {
        return error;
      }
      Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "FT_Load_Glyph: slot->format is outline: "+(format == FTTags.GlyphFormat.OUTLINE));
      if (format == FTTags.GlyphFormat.OUTLINE) {
        /* check that the loaded outline is correct */
        Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("CHKOUTLINE: %d", outline.n_points));
        error = FTOutlineRec.FTOutlineCheck(outline);
        if (error != FTError.ErrorTag.ERR_OK) {
          return error;
        }
      }
    }
    /* compute the advance */
    if ((load_flags & Flags.Load.VERTICAL_LAYOUT.getVal()) != 0) {
      advance.setX(0);
      advance.setY(metrics.getVertAdvance());
    } else {
      advance.setX(metrics.getHoriAdvance());
      advance.setY(0);
    }
    /* compute the linear advance in 16.16 pixels */
    if (((load_flags & Flags.Load.LINEAR_DESIGN.getVal()) == 0) && ((face.getFace_flags() & Flags.Face.SCALABLE.getVal()) != 0)) {
      FTSizeMetricsRec metrics = face.getSize().metrics;

      /* it's tricky! */
      linearHoriAdvance = FTCalc.FT_MulDiv(linearHoriAdvance, metrics.getX_scale(), 64);
      linearVertAdvance = FTCalc.FT_MulDiv(linearVertAdvance, metrics.getY_scale(), 64);
    }

    Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("FT_LOAD_IGNORE_TRANSFORM: %d", (load_flags & Flags.Load.IGNORE_TRANSFORM.getVal())));
    if ((load_flags & Flags.Load.IGNORE_TRANSFORM.getVal()) == 0) {
      FTFaceInternalRec internal = face.getInternal();
      FTReference<FTMatrixRec> matrix_ref = new FTReference<FTMatrixRec>();
      FTReference<FTVectorRec> delta_ref = new FTReference<FTVectorRec>();

      /* now, transform the glyph image if needed */
      if (internal.getTransform_flags() != 0) {
        /* get renderer */
................................................................................
    FTTrace.Trace(7, TAG, String.format("  y advance: %d", advance.getY()));
    FTTrace.Trace(7, TAG, String.format("  linear x advance: %d", linearHoriAdvance));
    FTTrace.Trace(7, TAG, String.format("  linear y advance: %d", linearVertAdvance));
    /* do we need to render the image now? */
    if (error == FTError.ErrorTag.ERR_OK &&
        (format != FTTags.GlyphFormat.BITMAP) &&
        (format != FTTags.GlyphFormat.COMPOSITE) &&
        (load_flags & Flags.Load.RENDER.getVal()) != 0) {
      int mode = ((load_flags >> 16) & 15);

      if ((mode == FTTags.RenderMode.NORMAL.getVal()) &&
          (load_flags & Flags.Load.MONOCHROME.getVal()) != 0) {
        mode = FTTags.RenderMode.MONO.getVal();
      }
      error = this.FTRenderGlyph(mode);
    }
    return error;
  }

................................................................................
   * =====================================================================
   */
  public FTError.ErrorTag FTRenderGlyphInternal(FTLibraryRec library, int render_mode) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    FTRendererRec renderer;
    FTReference<FTListNodeRec> node_ref = new FTReference<FTListNodeRec>();

    Debug(0, DebugTag.DBG_RENDER, TAG, "FTRenderGlyphInternal");
    /* if it is already a bitmap, no need to do anything */
    if (this.format == FTTags.GlyphFormat.BITMAP) {
      /* already a bitmap, don't do anything */
    } else {
      FTListNodeRec node = null;
      boolean update = false;

................................................................................
      } else {
        node_ref.Set(node);
        renderer = library.getCur_renderer().FTLookupRenderer(library, this.format, node_ref);
        Debug(0, DebugTag.DBG_RENDER, TAG, "renderer name: "+renderer.clazz.module_name);
        node = node_ref.Get();
      }
      error = FTError.ErrorTag.GLYPH_UNIMPLEMENTED_FEATURE;
      Debug(0, DebugTag.DBG_RENDER, TAG, "renderer 0: "+renderer+"!");
      while (renderer != null) {
        Debug(0, DebugTag.DBG_RENDER, TAG, "renderer 1: "+renderer+"!"+this.bitmap+"!");
        error = renderer.render(renderer, this, render_mode, null);
        if (error == FTError.ErrorTag.ERR_OK || error != FTError.ErrorTag.GLYPH_CANNOT_RENDER_GLYPH) {
          break;
        }
        /* FT_Err_Cannot_Render_Glyph is returned if the render mode   */
        /* is unsupported by the current renderer for this glyph image */
        /* format.                                                     */
        /* now, look for another renderer that supports the same */
        /* format.                                               */
        node_ref.Set(node);
        renderer = library.getCur_renderer().FTLookupRenderer(library, this.format, node_ref);
        if (renderer != null && renderer.clazz != null) {
          Debug(0, DebugTag.DBG_RENDER, TAG, "renderer name: "+renderer.clazz.module_name);
        }
        node = node_ref.Get();
        update = true;
      }
      Debug(0, DebugTag.DBG_RENDER, TAG, String.format("before BITMAP convert0d: rows %d width %d pitch %d num_grays %d", this.bitmap.getRows(), this.bitmap.getWidth(), this.bitmap.getPitch(), this.bitmap.getNum_grays()));
      /* if we changed the current renderer for the glyph image format */
      /* we need to select it as the next current one                  */
      if (error == FTError.ErrorTag.ERR_OK && update && renderer != null) {
        FTRendererRec.FTSetRenderer(library, renderer, 0, null);
      }
    }
    /* we convert to a single bitmap format for computing the checksum */







>
>







 







|







 







|
>
|

|
|
>
|







 







|
|


|
|


|



|




|







 







|
|
>
>

<
>







 







|


|







|







|







|
|







 







|
|


|







 







|







 







|

|












|




|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
...
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
...
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
...
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
...
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
...
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
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;

import java.util.Set;

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

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

................................................................................
   *    For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is
   *    returned for invalid CID values (this is, for CID values which
   *    don't have a corresponding glyph in the font).  See the discussion
   *    of the @FT_FACE_FLAG_CID_KEYED flag for more details.
   *
   * =====================================================================
   */
  public FTError.ErrorTag LoadGlyph(int glyph_index, Set<Flags.Load> load_flags) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    FTDriverRec driver = null;
    FTLibraryRec library;
    boolean autohint = false;
    FTModuleRec hinter;
    boolean Load_Ok = false;
    TTFaceRec ttface = (TTFaceRec)face;
................................................................................
    /* The validity test for `glyph_index' is performed by the */
    /* font drivers.                                           */
    ft_glyphslot_clear();
    driver  = face.getDriver();
    library = driver.library;
    hinter  = library.getAuto_hinter();
    /* resolve load flags dependencies */
    if (load_flags.contains(Flags.Load.NO_RECURSE)) {
      load_flags.add(Flags.Load.NO_SCALE);
      load_flags.add(Flags.Load.IGNORE_TRANSFORM);
    }
    if (load_flags.contains(Flags.Load.NO_SCALE)) {
      load_flags.add(Flags.Load.NO_HINTING);
      load_flags.add(Flags.Load.NO_BITMAP);
      load_flags.remove(Flags.Load.RENDER);
    }
    /*
     * Determine whether we need to auto-hint or not.
     * The general rules are:
     *
     * - Do only auto-hinting if we have a hinter module, a scalable font
     *   format dealing with outlines, and no transforms except simple
................................................................................
     * - Otherwise, auto-hint for LIGHT hinting mode or if there isn't
     *   any hinting bytecode in the TrueType/OpenType font.
     *
     * - 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() ||
            (face.getFace_flags().contains(Flags.Face.SFNT) &&
                ttface.getLoca_table().getNum_locations() != 0 &&
                ttface.getMax_profile().getMaxSizeOfInstructions() == 0)) {
          autohint = true;
        }
      }
    }
    if (autohint) {
................................................................................
        FTAutoHinterInterfaceClass hinting;

        /* try to load embedded bitmaps first if available            */
        /*                                                            */
        /* XXX: This is really a temporary hack that should disappear */
        /*      promptly with FreeType 2.1!                           */
        /*                                                            */
        if (face.getFace_flags().contains(Flags.Face.FIXED_SIZES) &&
            (!load_flags.contains(Flags.Load.NO_BITMAP))) {
          Set<Flags.Load> my_load_flags = load_flags;
          my_load_flags.add(Flags.Load.SBITS_ONLY);
          error = driver.driver_clazz.loadGlyph(this, face.getSize(),

                 glyph_index, my_load_flags);
          if ((error != FTError.ErrorTag.ERR_OK )&& format == FTTags.GlyphFormat.BITMAP) {
            Load_Ok = true;
          }
        }
        if (! Load_Ok) {
          FTFaceInternalRec internal = face.getInternal();
          int transform_flags = internal.getTransform_flags();
................................................................................
          internal.setTransform_flags(transform_flags);
        }
    } else {
      error = driver.getDriver_clazz().loadGlyph(this, face.getSize(), glyph_index, load_flags);
      if (error != FTError.ErrorTag.ERR_OK) {
        return error;
      }
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "FT_Load_Glyph: slot->format is outline: "+(format == FTTags.GlyphFormat.OUTLINE));
      if (format == FTTags.GlyphFormat.OUTLINE) {
        /* check that the loaded outline is correct */
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("CHKOUTLINE: %d", outline.n_points));
        error = FTOutlineRec.FTOutlineCheck(outline);
        if (error != FTError.ErrorTag.ERR_OK) {
          return error;
        }
      }
    }
    /* compute the advance */
    if (load_flags.contains(Flags.Load.VERTICAL_LAYOUT)) {
      advance.setX(0);
      advance.setY(metrics.getVertAdvance());
    } else {
      advance.setX(metrics.getHoriAdvance());
      advance.setY(0);
    }
    /* compute the linear advance in 16.16 pixels */
    if ((!load_flags.contains(Flags.Load.LINEAR_DESIGN)) && (face.getFace_flags().contains(Flags.Face.SCALABLE))) {
      FTSizeMetricsRec metrics = face.getSize().metrics;

      /* it's tricky! */
      linearHoriAdvance = FTCalc.FT_MulDiv(linearHoriAdvance, metrics.getX_scale(), 64);
      linearVertAdvance = FTCalc.FT_MulDiv(linearVertAdvance, metrics.getY_scale(), 64);
    }

Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("FT_LOAD_IGNORE_TRANSFORM: %b", load_flags.contains(Flags.Load.IGNORE_TRANSFORM)));
    if (!load_flags.contains(Flags.Load.IGNORE_TRANSFORM)) {
      FTFaceInternalRec internal = face.getInternal();
      FTReference<FTMatrixRec> matrix_ref = new FTReference<FTMatrixRec>();
      FTReference<FTVectorRec> delta_ref = new FTReference<FTVectorRec>();

      /* now, transform the glyph image if needed */
      if (internal.getTransform_flags() != 0) {
        /* get renderer */
................................................................................
    FTTrace.Trace(7, TAG, String.format("  y advance: %d", advance.getY()));
    FTTrace.Trace(7, TAG, String.format("  linear x advance: %d", linearHoriAdvance));
    FTTrace.Trace(7, TAG, String.format("  linear y advance: %d", linearVertAdvance));
    /* do we need to render the image now? */
    if (error == FTError.ErrorTag.ERR_OK &&
        (format != FTTags.GlyphFormat.BITMAP) &&
        (format != FTTags.GlyphFormat.COMPOSITE) &&
        load_flags.contains(Flags.Load.RENDER)) {
      int mode = ((Flags.Load.LoadSetToInt(load_flags) >> 16) & 15);

      if ((mode == FTTags.RenderMode.NORMAL.getVal()) &&
          load_flags.contains(Flags.Load.MONOCHROME)) {
        mode = FTTags.RenderMode.MONO.getVal();
      }
      error = this.FTRenderGlyph(mode);
    }
    return error;
  }

................................................................................
   * =====================================================================
   */
  public FTError.ErrorTag FTRenderGlyphInternal(FTLibraryRec library, int render_mode) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    FTRendererRec renderer;
    FTReference<FTListNodeRec> node_ref = new FTReference<FTListNodeRec>();

Debug(0, DebugTag.DBG_RENDER, TAG, "FTRenderGlyphInternal");
    /* if it is already a bitmap, no need to do anything */
    if (this.format == FTTags.GlyphFormat.BITMAP) {
      /* already a bitmap, don't do anything */
    } else {
      FTListNodeRec node = null;
      boolean update = false;

................................................................................
      } else {
        node_ref.Set(node);
        renderer = library.getCur_renderer().FTLookupRenderer(library, this.format, node_ref);
        Debug(0, DebugTag.DBG_RENDER, TAG, "renderer name: "+renderer.clazz.module_name);
        node = node_ref.Get();
      }
      error = FTError.ErrorTag.GLYPH_UNIMPLEMENTED_FEATURE;
Debug(0, DebugTag.DBG_RENDER, TAG, "renderer 0: "+renderer+"!");
      while (renderer != null) {
Debug(0, DebugTag.DBG_RENDER, TAG, "renderer 1: "+renderer+"!"+this.bitmap+"!");
        error = renderer.render(renderer, this, render_mode, null);
        if (error == FTError.ErrorTag.ERR_OK || error != FTError.ErrorTag.GLYPH_CANNOT_RENDER_GLYPH) {
          break;
        }
        /* FT_Err_Cannot_Render_Glyph is returned if the render mode   */
        /* is unsupported by the current renderer for this glyph image */
        /* format.                                                     */
        /* now, look for another renderer that supports the same */
        /* format.                                               */
        node_ref.Set(node);
        renderer = library.getCur_renderer().FTLookupRenderer(library, this.format, node_ref);
        if (renderer != null && renderer.clazz != null) {
Debug(0, DebugTag.DBG_RENDER, TAG, "renderer name: "+renderer.clazz.module_name);
        }
        node = node_ref.Get();
        update = true;
      }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("before BITMAP convert0d: rows %d width %d pitch %d num_grays %d", this.bitmap.getRows(), this.bitmap.getWidth(), this.bitmap.getPitch(), this.bitmap.getNum_grays()));
      /* if we changed the current renderer for the glyph image format */
      /* we need to select it as the next current one                  */
      if (error == FTError.ErrorTag.ERR_OK && update && renderer != null) {
        FTRendererRec.FTSetRenderer(library, renderer, 0, null);
      }
    }
    /* we convert to a single bitmap format for computing the checksum */

Changes to aftbase/FTOutlineRec.java.

332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
...
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
...
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
    Set<Flags.Curve> tag;       /* current point's state           */
    int shift;
    int delta;
    boolean doConic = true;
    boolean doContinue = false;
    boolean isClosed = false;

Debug(0, DebugTag.DBG_RENDER, TAG, "ftoutline FTOutlineDecompose");
    if (func_interface == null) {
      return FTError.ErrorTag.RENDER_INVALID_ARGUMENT;
    }
    shift = func_interface.getShift();
    delta = func_interface.getDelta();
    first = 0;
    for (n = 0; n < n_contours; n++) {
................................................................................
          if (error != FTError.ErrorTag.ERR_OK) {
            FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
            return error;
          }
          continue;
        }
        if (tag.contains(Flags.Curve.CONIC)) {  /* consume conic arcs */
          Debug(0, DebugTag.DBG_RENDER, TAG, "FT_CURVE_TAG_CONIC");
          Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==3a v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
          v_control.setX(((points[pointIdx].getX()) << shift) - delta);
          v_control.setY(((points[pointIdx].getY()) << shift) - delta);
          doConic = true;
          while (doConic) {
            Debug(0, DebugTag.DBG_RENDER, TAG, String.format("decompose doConic: pointIdx: %d,  limit: %d", pointIdx, limit));
            doConic = false;
            Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==3b v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
            doContinue = false;
            if (pointIdx < limit) {
              FTVectorRec vec = new FTVectorRec();
              FTVectorRec v_middle = new FTVectorRec();

              pointIdx++;
              tagsIdx++;
              tag = tags[tagsIdx];
              vec.setX(((points[pointIdx].getX()) << shift) - delta);
              vec.setY(((points[pointIdx].getY()) << shift) - delta);
              Debug(0, DebugTag.DBG_RENDER, TAG, String.format("tag: %d, tagIdx: %d, pointIdx: %d, limit: %d, vec.x: %d, vec.y: %d", tag, tagsIdx, pointIdx, limit, vec.getX(), vec.getY()));
              if (tag.contains(Flags.Curve.ON)) {
                FTTrace.Trace(0, TAG, String.format("  1 conic to (%.2f, %.2f)" +
                        " with control (%.2f, %.2f)",
                    vec.getX() / 64.0, vec.getY() / 64.0,
                    v_control.getX() / 64.0, v_control.getY() / 64.0));
                error = func_interface.conicTo(v_control, vec, user);
                Debug(0, DebugTag.DBG_RENDER, TAG, "Decompose2: after call conic_to");
                if (error != FTError.ErrorTag.ERR_OK) {
                  FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
                  return error;
                }
                doContinue = true;
                break;
              }
................................................................................
              v_middle.setX((v_control.getX() + vec.getX()) / 2);
              v_middle.setY((v_control.getY() + vec.getY()) / 2);
              FTTrace.Trace(7, TAG, String.format("  2 conic to (%.2f, %.2f)" +
                      " with control (%.2f, %.2f)",
                  v_middle.getX() / 64.0, v_middle.getY() / 64.0,
                  v_control.getX() / 64.0, v_control.getY() / 64.0));
              error = func_interface.conicTo(v_control, v_middle, user);
              Debug(0, DebugTag.DBG_RENDER, TAG, "Decompose3: after call conic_to");
              if (error != FTError.ErrorTag.ERR_OK) {
                FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
                return error;
              }
              v_control.setX(vec.getX());
              v_control.setY(vec.getY());
              doConic = true;
              Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==4a v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
            }
          }
          Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==4b v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
          if (doContinue) {
            continue;
          }
          FTTrace.Trace(8, TAG, String.format(" 3 conic to (%.2f, %.2f)" +
                  " with control (%.2f, %.2f)",
              v_start.getX() / 64.0, v_start.getY() / 64.0,
              v_control.getX() / 64.0, v_control.getY() / 64.0));







|







 







|
|




|

|










|






|







 







|







|


|







332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
...
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
...
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
    Set<Flags.Curve> tag;       /* current point's state           */
    int shift;
    int delta;
    boolean doConic = true;
    boolean doContinue = false;
    boolean isClosed = false;

Debug(0, DebugTag.DBG_RENDER, TAG, "FTOutlineRec FTOutlineDecompose");
    if (func_interface == null) {
      return FTError.ErrorTag.RENDER_INVALID_ARGUMENT;
    }
    shift = func_interface.getShift();
    delta = func_interface.getDelta();
    first = 0;
    for (n = 0; n < n_contours; n++) {
................................................................................
          if (error != FTError.ErrorTag.ERR_OK) {
            FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
            return error;
          }
          continue;
        }
        if (tag.contains(Flags.Curve.CONIC)) {  /* consume conic arcs */
Debug(0, DebugTag.DBG_RENDER, TAG, "FT_CURVE_TAG_CONIC");
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==3a v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
          v_control.setX(((points[pointIdx].getX()) << shift) - delta);
          v_control.setY(((points[pointIdx].getY()) << shift) - delta);
          doConic = true;
          while (doConic) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("decompose doConic: pointIdx: %d,  limit: %d", pointIdx, limit));
            doConic = false;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==3b v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
            doContinue = false;
            if (pointIdx < limit) {
              FTVectorRec vec = new FTVectorRec();
              FTVectorRec v_middle = new FTVectorRec();

              pointIdx++;
              tagsIdx++;
              tag = tags[tagsIdx];
              vec.setX(((points[pointIdx].getX()) << shift) - delta);
              vec.setY(((points[pointIdx].getY()) << shift) - delta);
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("tag: %s, tagIdx: %d, pointIdx: %d, limit: %d, vec.x: %d, vec.y: %d", tag, tagsIdx, pointIdx, limit, vec.getX(), vec.getY()));
              if (tag.contains(Flags.Curve.ON)) {
                FTTrace.Trace(0, TAG, String.format("  1 conic to (%.2f, %.2f)" +
                        " with control (%.2f, %.2f)",
                    vec.getX() / 64.0, vec.getY() / 64.0,
                    v_control.getX() / 64.0, v_control.getY() / 64.0));
                error = func_interface.conicTo(v_control, vec, user);
Debug(0, DebugTag.DBG_RENDER, TAG, "Decompose2: after call conic_to");
                if (error != FTError.ErrorTag.ERR_OK) {
                  FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
                  return error;
                }
                doContinue = true;
                break;
              }
................................................................................
              v_middle.setX((v_control.getX() + vec.getX()) / 2);
              v_middle.setY((v_control.getY() + vec.getY()) / 2);
              FTTrace.Trace(7, TAG, String.format("  2 conic to (%.2f, %.2f)" +
                      " with control (%.2f, %.2f)",
                  v_middle.getX() / 64.0, v_middle.getY() / 64.0,
                  v_control.getX() / 64.0, v_control.getY() / 64.0));
              error = func_interface.conicTo(v_control, v_middle, user);
Debug(0, DebugTag.DBG_RENDER, TAG, "Decompose3: after call conic_to");
              if (error != FTError.ErrorTag.ERR_OK) {
                FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
                return error;
              }
              v_control.setX(vec.getX());
              v_control.setY(vec.getY());
              doConic = true;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==4a v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
            }
          }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==4b v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
          if (doContinue) {
            continue;
          }
          FTTrace.Trace(8, TAG, String.format(" 3 conic to (%.2f, %.2f)" +
                  " with control (%.2f, %.2f)",
              v_start.getX() / 64.0, v_start.getY() / 64.0,
              v_control.getX() / 64.0, v_control.getY() / 64.0));

Changes to aftbase/FTRendererRec.java.

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
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf() + "\n");
    return str.toString();
  }

  /* ==================== rasterRender ===================================== */
  public FTError.ErrorTag rasterRender(FTRasterRec raster, FTRasterParamsRec params) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Log.e(TAG, "rasterRest not yet fully implemented");
    return clazz.rasterRender(raster, params);
  }

  /* ==================== render ===================================== */
  public FTError.ErrorTag render(FTRendererRec render, FTGlyphSlotRec slot, int render_mode, Object obj) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Log.e(TAG, "rasterRest not yet fully implemented");
    return clazz.renderGlyph(render, slot, render_mode, (FTVectorRec)obj);
  }

  /* ==================== initModule ===================================== */
  public FTError.ErrorTag initModule(FTModuleClassRec module) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
FTDebug.Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "initModule\n");







<
<
<





<
<
<







62
63
64
65
66
67
68



69
70
71
72
73



74
75
76
77
78
79
80
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf() + "\n");
    return str.toString();
  }

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



    return clazz.rasterRender(raster, params);
  }

  /* ==================== render ===================================== */
  public FTError.ErrorTag render(FTRendererRec render, FTGlyphSlotRec slot, int render_mode, Object obj) {



    return clazz.renderGlyph(render, slot, render_mode, (FTVectorRec)obj);
  }

  /* ==================== initModule ===================================== */
  public FTError.ErrorTag initModule(FTModuleClassRec module) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
FTDebug.Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "initModule\n");

Changes to aftbase/FTSizeMetricsRec.java.

171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    boolean doall = true;

Debug(0, DebugTag.DBG_INIT, TAG, "FTRequestMetrics:");
    FTSizeMetricsRec metrics;

    metrics = face.getSize().metrics;
    if ((face.getFace_flags() & Flags.Face.SCALABLE.getVal()) != 0) {
      int w = 0;
      int h = 0;
      int scaled_w = 0;
      int scaled_h = 0;

      switch (req.getType()) {
      case NOMINAL:







|







171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    boolean doall = true;

Debug(0, DebugTag.DBG_INIT, TAG, "FTRequestMetrics:");
    FTSizeMetricsRec metrics;

    metrics = face.getSize().metrics;
    if (face.getFace_flags().contains(Flags.Face.SCALABLE)) {
      int w = 0;
      int h = 0;
      int scaled_w = 0;
      int scaled_h = 0;

      switch (req.getType()) {
      case NOMINAL:

Changes to aftbase/FTSizeRec.java.

146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
...
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
   */
  public FTError.ErrorTag MatchSize(FTFaceRec face, FTSizeRequestRec req, boolean ignore_width, FTReference<Integer> size_index_ref) {
    Debug(0, DebugTag.DBG_INIT, TAG, "FTMatchSize:");
    int i;
    int w;
    int h;

    if ((face.getFace_flags() & Flags.Face.FIXED_SIZES.getVal()) == 0) {
      return FTError.ErrorTag.GLYPH_INVALID_FACE_HANDLE;
    }
    /* FT_Bitmap_Size doesn't provide enough info... */
    if (req.getType() != FTTags.SizeRequestType.NOMINAL) {
      return FTError.ErrorTag.GLYPH_UNIMPLEMENTED_FEATURE;
    }
    w = req.getHoriResolution() != 0
................................................................................

    Debug(0, DebugTag.DBG_INIT, TAG, "FTSelectMetrics:");
    FTBitmapSize  bsize;

    bsize = face.getAvailable_sizes()[strike_index];
    metrics.setX_ppem(((bsize.x_ppem + 32) >> 6));
    metrics.setY_ppem(((bsize.y_ppem + 32) >> 6));
    if ((face.getFace_flags() & Flags.Face.SCALABLE.getVal()) != 0) {
      metrics.setX_scale(FTCalc.FTDivFix(bsize.x_ppem, face.getUnits_per_EM()));
      metrics.setY_scale(FTCalc.FTDivFix(bsize.y_ppem, face.getUnits_per_EM()));
      FTReference<FTSizeMetricsRec> metrics_ref = new FTReference<FTSizeMetricsRec>();
      metrics_ref.Set(metrics);
      metrics.ft_recompute_scaled_metrics(face, metrics_ref);
      metrics = metrics_ref.Get();
    } else {
................................................................................
   */
  public FTError.ErrorTag SelectSize(FTFaceRec face, int strike_index) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Debug(0, DebugTag.DBG_INIT, TAG, "FTSelectSize:");
    FTDriverClassRec clazz;

    if (face == null || (face.getFace_flags() & Flags.Face.FIXED_SIZES.getVal()) == 0) {
      return FTError.ErrorTag.GLYPH_INVALID_FACE_HANDLE;
    }
    if (strike_index < 0 || strike_index >= face.getNum_fixed_sizes()) {
      return FTError.ErrorTag.GLYPH_INVALID_ARGUMENT;
    }
    clazz = face.getDriver().getDriver_clazz();
    error = clazz.selectSize(strike_index);
................................................................................
    /*
     * The reason that a driver doesn't have `request_size' defined is
     * either that the scaling here suffices or that the supported formats
     * are bitmap-only and size matching is not implemented.
     *
     * In the latter case, a simple size matching is done.
     */
    if ((face.getFace_flags() & Flags.Face.SCALABLE.getVal()) != 0 &&
        (face.getFace_flags() & Flags.Face.FIXED_SIZES.getVal()) != 0) {
      FTReference<Integer> strike_index_ref = new FTReference<>();
//    	strike_index_Ref.Set(strike_index);
      error = MatchSize(face, req, false, strike_index_ref);
      strike_index = strike_index_ref.Get();
      if (error != FTError.ErrorTag.ERR_OK) {
        return error;
      }







|







 







|







 







|







 







|
|







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
...
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
   */
  public FTError.ErrorTag MatchSize(FTFaceRec face, FTSizeRequestRec req, boolean ignore_width, FTReference<Integer> size_index_ref) {
    Debug(0, DebugTag.DBG_INIT, TAG, "FTMatchSize:");
    int i;
    int w;
    int h;

    if (!face.getFace_flags().contains(Flags.Face.FIXED_SIZES)) {
      return FTError.ErrorTag.GLYPH_INVALID_FACE_HANDLE;
    }
    /* FT_Bitmap_Size doesn't provide enough info... */
    if (req.getType() != FTTags.SizeRequestType.NOMINAL) {
      return FTError.ErrorTag.GLYPH_UNIMPLEMENTED_FEATURE;
    }
    w = req.getHoriResolution() != 0
................................................................................

    Debug(0, DebugTag.DBG_INIT, TAG, "FTSelectMetrics:");
    FTBitmapSize  bsize;

    bsize = face.getAvailable_sizes()[strike_index];
    metrics.setX_ppem(((bsize.x_ppem + 32) >> 6));
    metrics.setY_ppem(((bsize.y_ppem + 32) >> 6));
    if (face.getFace_flags().contains(Flags.Face.SCALABLE)) {
      metrics.setX_scale(FTCalc.FTDivFix(bsize.x_ppem, face.getUnits_per_EM()));
      metrics.setY_scale(FTCalc.FTDivFix(bsize.y_ppem, face.getUnits_per_EM()));
      FTReference<FTSizeMetricsRec> metrics_ref = new FTReference<FTSizeMetricsRec>();
      metrics_ref.Set(metrics);
      metrics.ft_recompute_scaled_metrics(face, metrics_ref);
      metrics = metrics_ref.Get();
    } else {
................................................................................
   */
  public FTError.ErrorTag SelectSize(FTFaceRec face, int strike_index) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Debug(0, DebugTag.DBG_INIT, TAG, "FTSelectSize:");
    FTDriverClassRec clazz;

    if (face == null || !face.getFace_flags().contains(Flags.Face.FIXED_SIZES)) {
      return FTError.ErrorTag.GLYPH_INVALID_FACE_HANDLE;
    }
    if (strike_index < 0 || strike_index >= face.getNum_fixed_sizes()) {
      return FTError.ErrorTag.GLYPH_INVALID_ARGUMENT;
    }
    clazz = face.getDriver().getDriver_clazz();
    error = clazz.selectSize(strike_index);
................................................................................
    /*
     * The reason that a driver doesn't have `request_size' defined is
     * either that the scaling here suffices or that the supported formats
     * are bitmap-only and size matching is not implemented.
     *
     * In the latter case, a simple size matching is done.
     */
    if (face.getFace_flags().contains(Flags.Face.SCALABLE) &&
        face.getFace_flags().contains(Flags.Face.FIXED_SIZES)) {
      FTReference<Integer> strike_index_ref = new FTReference<>();
//    	strike_index_Ref.Set(strike_index);
      error = MatchSize(face, req, false, strike_index_ref);
      strike_index = strike_index_ref.Get();
      if (error != FTError.ErrorTag.ERR_OK) {
        return error;
      }

Changes to aftbase/Flags.java.

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
...
109
110
111
112
113
114
115






























116
117
118
119
120
121
122
      return (flags &  Flags.Module.DRIVER_HAS_HINTER.getVal()) != 0;
    }

  }

  public enum Face {
    UNKNOWN(0, "Flags Face UNKNOWN"),
    SCALABLE((1 <<  0), "FT_FACE_FLAG_SCALABLE"),
    FIXED_SIZES((1 <<  1), "FT_FACE_FLAG_FIXED_SIZES"),
    FIXED_WIDTH((1 <<  2), "FT_FACE_FLAG_FIXED_WIDTH"),
    SFNT((1 <<  3), "FT_FACE_FLAG_SFNT"),
    HORIZONTAL((1 <<  4), "FT_FACE_FLAG_HORIZONTAL"),
    VERTICAL((1 <<  5), "FT_FACE_FLAG_VERTICAL"),
    KERNING((1 <<  6), "FT_FACE_FLAG_KERNING"),
    FAST_GLYPHS((1 <<  7), "FT_FACE_FLAG_FAST_GLYPHS"),
    MULTIPLE_MASTERS((1 <<  8), "FT_FACE_FLAG_MULTIPLE_MASTERS"),
................................................................................
      for (Face t : values()) {
        tagToFaceMapping.put(t.val, t);
      }
    }
    private Face(int val, String str) {
      this.val = val;
      this.str = str;






























    }
    public int getVal() {
      return val;
    }
  }

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







|
|







 







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







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
...
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
      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"),
    SFNT((1 <<  3), "FT_FACE_FLAG_SFNT"),
    HORIZONTAL((1 <<  4), "FT_FACE_FLAG_HORIZONTAL"),
    VERTICAL((1 <<  5), "FT_FACE_FLAG_VERTICAL"),
    KERNING((1 <<  6), "FT_FACE_FLAG_KERNING"),
    FAST_GLYPHS((1 <<  7), "FT_FACE_FLAG_FAST_GLYPHS"),
    MULTIPLE_MASTERS((1 <<  8), "FT_FACE_FLAG_MULTIPLE_MASTERS"),
................................................................................
      for (Face t : values()) {
        tagToFaceMapping.put(t.val, t);
      }
    }
    private Face(int val, String str) {
      this.val = val;
      this.str = str;
    }
    public static Set<Face> makeTableTagSet(int value) {
      Set<Face> flags = new HashSet<>();
      for (Face t : values()) {
        if ((value & t.getVal()) != 0) {
          flags.add(t);
        }
      }
      return flags;
    }
    public static String FaceSetToString(Set<Load> flags) {
      StringBuffer str = new StringBuffer();
      for (Face t : values()) {
        if (flags.contains(t)) {
          str.append(" "+t.toString());
        }
      }
      if (flags.isEmpty()) {
        str.append(" "+UNKNOWN);
      }
      return str.toString();
    }
    public static int FaceSetToInt(Set<Load> flags) {
      int val = 0;
      for (Face t : values()) {
        if (flags.contains(t)) {
          val += t.getVal();
        }
      }
      return val;
    }
    public int getVal() {
      return val;
    }
  }

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

Changes to aftdemo/demo1.java.

10
11
12
13
14
15
16

17
18
19
20
21
22
23



24
25
26
27
28
29
30
..
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
import org.apwtcl.apwfreetypelib.aftbase.FTApwFreeType;
import org.apwtcl.apwfreetypelib.aftbase.FTBitmapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTFaceRec;
import org.apwtcl.apwfreetypelib.aftbase.FTFaceRequester;
import org.apwtcl.apwfreetypelib.aftbase.FTLibraryRec;
import org.apwtcl.apwfreetypelib.aftbase.FTSizeRec;
import org.apwtcl.apwfreetypelib.aftbase.FTStrokerRec;

import org.apwtcl.apwfreetypelib.aftcache.FTCBasicICacheClass;
import org.apwtcl.apwfreetypelib.aftcache.FTCBasicSCacheClass;
import org.apwtcl.apwfreetypelib.aftcache.FTCCMapCacheClass;
import org.apwtcl.apwfreetypelib.aftcache.FTCGCacheClassRec;
import org.apwtcl.apwfreetypelib.aftcache.FTCManagerRec;
import org.apwtcl.apwfreetypelib.aftcache.FTCScalerRec;
import org.apwtcl.apwfreetypelib.aftutil.*;




public class demo1 extends FTDebug {

  public static String TAG = "cl1";

  public demo1() {
    String path = Environment.getExternalStorageDirectory().getAbsolutePath();
................................................................................
      FTReference<FTFaceRec> face_ref = new FTReference<>();
      error = FTFaceRec.FTNewFace(library, font_file_name, 0, face_ref);
      if (error != FTError.ErrorTag.ERR_OK) {
        Log.e(TAG, "could not open face");
        return;
      }
      FTFaceRec face = face_ref.Get();
      Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "FACE: " + face.toDebugString());
      int width = 12 * 64;
      int height = 12 * 64;
      int h_res = 72;
      int v_res = 72;
      error = face.getSize().SetCharSize(face, width, height, h_res, v_res);
      if (error != FTError.ErrorTag.ERR_OK) {
        Log.e(TAG, "could not open face");
        return;
      }
      Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "SIZE: " + face.getSize().toDebugString());

      int load_flags = 0;

      int glyph_index = 72;
      error = face.getGlyph().LoadGlyph(glyph_index, load_flags);

      if (error != FTError.ErrorTag.ERR_OK) {
        Log.e(TAG, "could not load glyph 72");
        return;
      }







>







>
>
>







 







|









|

|
>







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
..
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
import org.apwtcl.apwfreetypelib.aftbase.FTApwFreeType;
import org.apwtcl.apwfreetypelib.aftbase.FTBitmapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTFaceRec;
import org.apwtcl.apwfreetypelib.aftbase.FTFaceRequester;
import org.apwtcl.apwfreetypelib.aftbase.FTLibraryRec;
import org.apwtcl.apwfreetypelib.aftbase.FTSizeRec;
import org.apwtcl.apwfreetypelib.aftbase.FTStrokerRec;
import org.apwtcl.apwfreetypelib.aftbase.Flags;
import org.apwtcl.apwfreetypelib.aftcache.FTCBasicICacheClass;
import org.apwtcl.apwfreetypelib.aftcache.FTCBasicSCacheClass;
import org.apwtcl.apwfreetypelib.aftcache.FTCCMapCacheClass;
import org.apwtcl.apwfreetypelib.aftcache.FTCGCacheClassRec;
import org.apwtcl.apwfreetypelib.aftcache.FTCManagerRec;
import org.apwtcl.apwfreetypelib.aftcache.FTCScalerRec;
import org.apwtcl.apwfreetypelib.aftutil.*;

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

public class demo1 extends FTDebug {

  public static String TAG = "cl1";

  public demo1() {
    String path = Environment.getExternalStorageDirectory().getAbsolutePath();
................................................................................
      FTReference<FTFaceRec> face_ref = new FTReference<>();
      error = FTFaceRec.FTNewFace(library, font_file_name, 0, face_ref);
      if (error != FTError.ErrorTag.ERR_OK) {
        Log.e(TAG, "could not open face");
        return;
      }
      FTFaceRec face = face_ref.Get();
Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "FACE: " + face.toDebugString());
      int width = 12 * 64;
      int height = 12 * 64;
      int h_res = 72;
      int v_res = 72;
      error = face.getSize().SetCharSize(face, width, height, h_res, v_res);
      if (error != FTError.ErrorTag.ERR_OK) {
        Log.e(TAG, "could not open face");
        return;
      }
Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "SIZE: " + face.getSize().toDebugString());

      Set<Flags.Load> load_flags = new HashSet<>();
      load_flags.add(Flags.Load.RENDER);
      int glyph_index = 72;
      error = face.getGlyph().LoadGlyph(glyph_index, load_flags);

      if (error != FTError.ErrorTag.ERR_OK) {
        Log.e(TAG, "could not load glyph 72");
        return;
      }

Changes to aftraster/FTGrayOutlineFuncsClass.java.

72
73
74
75
76
77
78

79
80
81
82
83
84
85
..
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_move_to: to.x: %d, to.y: %d", to.getX(), to.getY()));

      /* record current cell, if any */
    gray_record_cell(worker);
      /* start to a new position */
    x = RasterUtil.UPSCALE(to.getX());
    y = RasterUtil.UPSCALE(to.getY());

    gray_start_cell(worker, RasterUtil.TRUNC(x), RasterUtil.TRUNC(y));
    worker.setX(x);
    worker.setY(y);
    return error;
  }

  /* =====================================================================
................................................................................
   *
   * =====================================================================
   */
  private FTError.ErrorTag gray_line_to(FTVectorRec to, grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_line_to: to.x: %d, to.y: %d", to.getX(), to.getY()));
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Debug(0, DebugTag.DBG_RENDER, TAG, "gray_line_to call gray_render_line");
    gray_render_line(worker, RasterUtil.UPSCALE(to.getX()), RasterUtil.UPSCALE(to.getY()));
    Debug(0, DebugTag.DBG_RENDER, TAG, "gray_line_to after call gray_render_line");
    return error;
  }

  /* =====================================================================
   *    gray_conic_to
   *
   * =====================================================================
................................................................................
    }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox2: %d %d %d %d", worker.getMin_ex(), worker.getMin_ey(), worker.getMax_ex(), worker.getMax_ey()));
      /* truncate the bounding box to integer pixels */
    worker.setMin_ex(worker.getMin_ex() >> 6);
    worker.setMin_ey(worker.getMin_ey() >> 6);
    worker.setMax_ex((worker.getMax_ex() + 63) >> 6);
    worker.setMax_ey((worker.getMax_ey() + 63) >> 6);
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_comput_cbox end: %d %d %d %d", worker.getMin_ex(), worker.getMin_ey(), worker.getMax_ex(), worker.getMax_ey()));
    worker.setOutline(outline);
  }


  /* ==================== moveTo ===================================== */
  @Override
  public FTError.ErrorTag moveTo(FTVectorRec point, Object user) {







>







 







|

|







 







|







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
..
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_move_to: to.x: %d, to.y: %d", to.getX(), to.getY()));

      /* record current cell, if any */
    gray_record_cell(worker);
      /* start to a new position */
    x = RasterUtil.UPSCALE(to.getX());
    y = RasterUtil.UPSCALE(to.getY());
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_move_to2: x(UPSCALE): %d, y(UPSCALE): %d", x, y));
    gray_start_cell(worker, RasterUtil.TRUNC(x), RasterUtil.TRUNC(y));
    worker.setX(x);
    worker.setY(y);
    return error;
  }

  /* =====================================================================
................................................................................
   *
   * =====================================================================
   */
  private FTError.ErrorTag gray_line_to(FTVectorRec to, grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_line_to: to.x: %d, to.y: %d", to.getX(), to.getY()));
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

Debug(0, DebugTag.DBG_RENDER, TAG, "gray_line_to call gray_render_line");
    gray_render_line(worker, RasterUtil.UPSCALE(to.getX()), RasterUtil.UPSCALE(to.getY()));
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_line_to after call gray_render_line");
    return error;
  }

  /* =====================================================================
   *    gray_conic_to
   *
   * =====================================================================
................................................................................
    }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox2: %d %d %d %d", worker.getMin_ex(), worker.getMin_ey(), worker.getMax_ex(), worker.getMax_ey()));
      /* truncate the bounding box to integer pixels */
    worker.setMin_ex(worker.getMin_ex() >> 6);
    worker.setMin_ey(worker.getMin_ey() >> 6);
    worker.setMax_ex((worker.getMax_ex() + 63) >> 6);
    worker.setMax_ey((worker.getMax_ey() + 63) >> 6);
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_compute_cbox end: min_ex: %d min_ey: %d max_ex: %d max_ey: %d", worker.getMin_ex(), worker.getMin_ey(), worker.getMax_ex(), worker.getMax_ey()));
    worker.setOutline(outline);
  }


  /* ==================== moveTo ===================================== */
  @Override
  public FTError.ErrorTag moveTo(FTVectorRec point, Object user) {

Changes to aftraster/FTSmoothRendererClass.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
...
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518

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";

  FTGrayOutlineFuncsClass func_interface = null;

    /* ==================== 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.Black;

Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "FTMSmoothRendererClass constructor called!!");
    }
    
    /* ==================== 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_smooth_init
   * =====================================================================
   */
  private FTError.ErrorTag ft_smooth_init(FTModuleRec module) {
    FTLibraryRec library = module.library;
................................................................................
      /* 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);
    }
    if (vmul) {
      height *= 3;
    }
................................................................................

  /* =====================================================================
   *    gray_init_cells
   *
   * =====================================================================
   */
  private void gray_init_cells(grayTWorkerRec worker, byte[] buffer, int byte_size) {
    Debug(0, DebugTag.DBG_RENDER, TAG, "+++ gray_init_cells");

    worker.setBuffer(buffer);
    worker.setBuffer_size(byte_size);
    worker.setYcells(new TCellRec[byte_size / 10]);
    worker.setCells(null);
    worker.setMax_cells(0);
    worker.setNum_cells(0);
................................................................................
  /* =====================================================================
   *    gray_convert_glyph_inner
   *
   * =====================================================================
   */
  private FTError.ErrorTag gray_convert_glyph_inner(grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_convert_glyph_inner");
    func_interface = new FTGrayOutlineFuncsClass();
    FTReference<FTOutlineRec> outline_ref = new FTReference<FTOutlineRec>();
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

//      if (ft_setjmp(ras.jump_buffer) == 0) {
    error = worker.getOutline().FTOutlineDecompose((FTOutlineFuncs)func_interface, worker);
    func_interface.gray_record_cell(worker);
//      } else {







|

|
|



|
|
|
|
|

|
|
|
|
|
|
|
|
>

|

|
|



|
|



|
|
|
|
|







 







|







 







|







 







<







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
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
...
505
506
507
508
509
510
511

512
513
514
515
516
517
518

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";

  FTGrayOutlineFuncsClass func_interface = null;

  /* ==================== 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;
    func_interface = new FTGrayOutlineFuncsClass();
Debug(0, FTDebug.DebugTag.DBG_INIT, TAG, "FTMSmoothRendererClass constructor called!!");
  }
    
  /* ==================== 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_smooth_init
   * =====================================================================
   */
  private FTError.ErrorTag ft_smooth_init(FTModuleRec module) {
    FTLibraryRec library = module.library;
................................................................................
      /* 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_RENDER, 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);
    }
    if (vmul) {
      height *= 3;
    }
................................................................................

  /* =====================================================================
   *    gray_init_cells
   *
   * =====================================================================
   */
  private void gray_init_cells(grayTWorkerRec worker, byte[] buffer, int byte_size) {
Debug(0, DebugTag.DBG_RENDER, TAG, "+++ gray_init_cells");

    worker.setBuffer(buffer);
    worker.setBuffer_size(byte_size);
    worker.setYcells(new TCellRec[byte_size / 10]);
    worker.setCells(null);
    worker.setMax_cells(0);
    worker.setNum_cells(0);
................................................................................
  /* =====================================================================
   *    gray_convert_glyph_inner
   *
   * =====================================================================
   */
  private FTError.ErrorTag gray_convert_glyph_inner(grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_convert_glyph_inner");

    FTReference<FTOutlineRec> outline_ref = new FTReference<FTOutlineRec>();
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

//      if (ft_setjmp(ras.jump_buffer) == 0) {
    error = worker.getOutline().FTOutlineDecompose((FTOutlineFuncs)func_interface, worker);
    func_interface.gray_record_cell(worker);
//      } else {

Changes to aftsfnt/FTSfntInterfaceClass.java.

27
28
29
30
31
32
33



34
35
36
37
38
39
40
...
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428

429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
...
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.*;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMapRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTFaceRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTTags;
import org.apwtcl.apwfreetypelib.aftutil.*;




public class FTSfntInterfaceClass extends FTModuleInterface {
  private static int oid = 0;

  private int id;
  private final static String TAG = "FTSfntInterfaceClass";

................................................................................
        ttface.setStyle_name(str_ref.Get());
      }
    }
Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "family_name: "+ttface.getFamily_name()+" style_name: "+ttface.getStyle_name());
      /* now set up root fields */
    {
      FTFaceRec root = ttface;
      int flags = Flags.Face.getTableTag(root.getFace_flags()).getVal();

        /* =================================================================
         * Compute face flags.
         * =================================================================
         */
      if (has_outline == true) {
        flags = flags | Flags.Face.SCALABLE.getVal();   /* scalable outlines */
      }
        /* The sfnt driver only supports bitmap fonts natively, thus we */
        /* don't set FT_FACE_FLAG_HINTER.                               */
      flags = flags | Flags.Face.SFNT.getVal() | /* SFNT file format  */
          Flags.Face.HORIZONTAL.getVal(); /* horizontal data   */
        /* fixed width font? */
      if (ttface.getPostscript().getIsFixedPitch() != 0) {
        flags = flags | Flags.Face.FIXED_WIDTH.getVal();
      }
        /* vertical information? */
      if (ttface.isVertical_info()) {
        flags = flags | Flags.Face.VERTICAL.getVal();
      }
        /* kerning available ? */
      if ((ttface.getFace_flags() & Flags.Face.KERNING.getVal()) != 0) {
        flags = flags | Flags.Face.KERNING.getVal();
      }
      root.setFace_flags(flags);
        /* =================================================================
         * Compute style flags.
         * =================================================================
         */

      int style_flags = Flags.FontStyle.NONE.getVal();
      if (has_outline == true && ttface.getOs2().getVersion() != 0xFFFF) {
          /* We have an OS/2 table; use the `fsSelection' field.  Bit 9 */
          /* indicates an oblique font face.  This flag has been        */
          /* introduced in version 1.5 of the OpenType specification.   */
        if ((ttface.getOs2().getFsSelection() & 512) != 0) {      /* bit 9 */
          style_flags = flags | Flags.FontStyle.ITALIC.getVal();
        } else {
          if ((ttface.getOs2().getFsSelection() & 1) != 0) {   /* bit 0 */
            style_flags = flags | Flags.FontStyle.ITALIC.getVal();
          }
        }
        if ((ttface.getOs2().getFsSelection() & 32) != 0) {    /* bit 5 */
          style_flags = flags | Flags.FontStyle.BOLD.getVal();
        }
      } else {
          /* this is an old Mac font, use the header field */
        if ((ttface.getHeader().getMacStyle() & 1) != 0) {
          style_flags = flags | Flags.FontStyle.BOLD.getVal();
        }
        if ((ttface.getHeader().getMacStyle() & 2) != 0) {
          style_flags = flags | Flags.FontStyle.ITALIC.getVal();
        }
      }
      root.setStyle_flags(style_flags);
        /* =================================================================
         * Polish the charmaps.
         *
         *   Try to set the charmap encoding according to the platform &
................................................................................
          } else {
            charmap.setEncoding(FTEncoding.sfnt_find_encoding(TTTags.Platform.getTableTag(charmap.getPlatformId()), charmap.getEncodingId()));
          }
        }
      }
        /* a font with no bitmaps and no outlines is scalable; */
        /* it has only empty glyphs then                       */
      if ((root.getFace_flags() & Flags.Face.FIXED_SIZES.getVal()) != 0 &&
          (root.getFace_flags() & Flags.Face.SCALABLE.getVal()) == 0) {
        root.setFace_flags(root.getFace_flags() | Flags.Face.SCALABLE.getVal());
      }
        /* =================================================================
         *  Set up metrics.
         * =================================================================
         */
      if ((root.getFace_flags() & Flags.Face.SCALABLE.getVal()) != 0) {
          /* XXX What about if outline header is missing */
          /*     (e.g. sfnt wrapped bitmap)?             */
        root.getBbox().setxMin(ttface.getHeader().getXMin());
        root.getBbox().setyMin(ttface.getHeader().getYMin());
        root.getBbox().setxMax(ttface.getHeader().getXMax());
        root.getBbox().setyMax(ttface.getHeader().getYMax());
        root.setUnits_per_EM(ttface.getHeader().getUnitsPerEM());







>
>
>







 







|






|



|
|


|



|


|
|






>
|





|


|



|




|


|







 







|
|
|





|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
...
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
...
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.*;
import org.apwtcl.apwfreetypelib.afttruetype.TTCMapRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTFaceRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTTags;
import org.apwtcl.apwfreetypelib.aftutil.*;

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

public class FTSfntInterfaceClass extends FTModuleInterface {
  private static int oid = 0;

  private int id;
  private final static String TAG = "FTSfntInterfaceClass";

................................................................................
        ttface.setStyle_name(str_ref.Get());
      }
    }
Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "family_name: "+ttface.getFamily_name()+" style_name: "+ttface.getStyle_name());
      /* now set up root fields */
    {
      FTFaceRec root = ttface;
      Set<Flags.Face> flags = root.getFace_flags();

        /* =================================================================
         * Compute face flags.
         * =================================================================
         */
      if (has_outline == true) {
        flags.add(Flags.Face.SCALABLE);   /* scalable outlines */
      }
        /* The sfnt driver only supports bitmap fonts natively, thus we */
        /* don't set FT_FACE_FLAG_HINTER.                               */
      flags.add(Flags.Face.SFNT);       /* SFNT file format  */
      flags.add(Flags.Face.HORIZONTAL); /* horizontal data   */
        /* fixed width font? */
      if (ttface.getPostscript().getIsFixedPitch() != 0) {
        flags.add(Flags.Face.FIXED_WIDTH);
      }
        /* vertical information? */
      if (ttface.isVertical_info()) {
        flags.add(Flags.Face.VERTICAL);
      }
        /* kerning available ? */
      if (ttface.getFace_flags().contains(Flags.Face.KERNING)) {
        flags.add(Flags.Face.KERNING);
      }
      root.setFace_flags(flags);
        /* =================================================================
         * Compute style flags.
         * =================================================================
         */
      Set<Flags.Face> style_flags = new HashSet<>();
      // Flags.FontStyle.NONE.getVal();
      if (has_outline == true && ttface.getOs2().getVersion() != 0xFFFF) {
          /* We have an OS/2 table; use the `fsSelection' field.  Bit 9 */
          /* indicates an oblique font face.  This flag has been        */
          /* introduced in version 1.5 of the OpenType specification.   */
        if ((ttface.getOs2().getFsSelection() & 512) != 0) {      /* bit 9 */
          style_flags.add(Flags.Face.getTableTag(Flags.FontStyle.ITALIC.getVal()));
        } else {
          if ((ttface.getOs2().getFsSelection() & 1) != 0) {   /* bit 0 */
            style_flags.add(Flags.Face.getTableTag(Flags.FontStyle.ITALIC.getVal()));
          }
        }
        if ((ttface.getOs2().getFsSelection() & 32) != 0) {    /* bit 5 */
          style_flags.add(Flags.Face.getTableTag(Flags.FontStyle.BOLD.getVal()));
        }
      } else {
          /* this is an old Mac font, use the header field */
        if ((ttface.getHeader().getMacStyle() & 1) != 0) {
          style_flags.add(Flags.Face.getTableTag(Flags.FontStyle.BOLD.getVal()));
        }
        if ((ttface.getHeader().getMacStyle() & 2) != 0) {
          style_flags.add(Flags.Face.getTableTag(Flags.FontStyle.ITALIC.getVal()));
        }
      }
      root.setStyle_flags(style_flags);
        /* =================================================================
         * Polish the charmaps.
         *
         *   Try to set the charmap encoding according to the platform &
................................................................................
          } else {
            charmap.setEncoding(FTEncoding.sfnt_find_encoding(TTTags.Platform.getTableTag(charmap.getPlatformId()), charmap.getEncodingId()));
          }
        }
      }
        /* a font with no bitmaps and no outlines is scalable; */
        /* it has only empty glyphs then                       */
      if (root.getFace_flags().contains(Flags.Face.FIXED_SIZES) &&
          !root.getFace_flags().contains(Flags.Face.SCALABLE)) {
        root.addFace_flag(Flags.Face.SCALABLE);
      }
        /* =================================================================
         *  Set up metrics.
         * =================================================================
         */
      if (root.getFace_flags().contains(Flags.Face.SCALABLE)) {
          /* XXX What about if outline header is missing */
          /*     (e.g. sfnt wrapped bitmap)?             */
        root.getBbox().setxMin(ttface.getHeader().getXMin());
        root.getBbox().setyMin(ttface.getHeader().getYMin());
        root.getBbox().setxMax(ttface.getHeader().getXMax());
        root.getBbox().setyMax(ttface.getHeader().getYMax());
        root.setUnits_per_EM(ttface.getHeader().getUnitsPerEM());

Changes to afttruetype/TTDriverClass.java.

20
21
22
23
24
25
26


27
28
29
30
31
32
33
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
...
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
...
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403

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.*;



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

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

................................................................................
    if (ttface.getFormat_tag() != TTTags.Table._00010000 &&  /* MS fonts  */
        ttface.getFormat_tag() != TTTags.Table._00020000 && /* CJK fonts for Win 3.1 */
        ttface.getFormat_tag() != TTTags.Table.truE) {   /* Mac fonts */
      FTTrace.Trace(7, TAG, "  not a TTF font");
      error = FTError.ErrorTag.INTERP_UNKNOWN_FILE_FORMAT;
      return error;
    }
    ttface.setFace_flags((ttface.getFace_flags() | Flags.Face.HINTER.getVal()));
      /* If we are performing a simple font format check, exit immediately. */
    if (face_index < 0) {
      return FTError.ErrorTag.ERR_OK;
    }
      /* Load font directory */
    error = sfnt.loadFace(stream, ttface, face_index, num_params, params);
    if (error != FTError.ErrorTag.ERR_OK) {
................................................................................
//        ttface.face_flags |= FTFaceRec.FT_FACE_FLAG_TRICKY;
//      }
//      error = tt_face_load_hdmx(face, stream);
    if (error != FTError.ErrorTag.ERR_OK) {
      return error;
    }
// FIXME!!
    ttface.setFace_flags((ttface.getFace_flags()) | Flags.Face.SCALABLE.getVal());
    if ((ttface.getFace_flags() & Flags.Face.SCALABLE.getVal()) != 0) {
      if (error == FTError.ErrorTag.ERR_OK) {
        error = ttface.loadLoca(stream);
      }
      if (error == FTError.ErrorTag.ERR_OK) {
        error = ttface.loadCvt(stream);
      }
      if (error == FTError.ErrorTag.ERR_OK) {
................................................................................
   *                   whether to hint the outline, etc).
   *
   * <Return>
   *    FreeType error code.  0 means success.
   *
   * =====================================================================
   */
  public FTError.ErrorTag tt_glyph_load(TTGlyphSlotRec ttslot, TTSizeRec ttsize, int glyph_index, int load_flags) {
Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "tt_glyph_load");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    FTFaceRec face = ttslot.getFace();
    FTReference<TTSizeRec> size_ref = new FTReference<TTSizeRec>();

    if (ttsize == null) {
................................................................................
      error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
      return error;
    }
    if (glyph_index >= face.getNum_glyphs()) {
      error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
      return error;
    }
    if ((load_flags & Flags.Load.NO_HINTING.getVal()) !=0) {
        /* both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT   */
        /* are necessary to disable hinting for tricky fonts */
      if ((face.getFace_flags() & Flags.Face.TRICKY.getVal()) != 0) {
        load_flags &= ~Flags.Load.NO_HINTING.getVal();
      }
      if ((load_flags & Flags.Load.NO_AUTOHINT.getVal()) != 0) {
        load_flags |= Flags.Load.NO_HINTING.getVal();
      }
    }
    if ((load_flags & (Flags.Load.NO_RECURSE.getVal() | Flags.Load.NO_SCALE.getVal())) != 0) {
      load_flags |= (Flags.Load.NO_BITMAP.getVal() | Flags.Load.NO_SCALE.getVal());
      if ((face.getFace_flags() & Flags.Face.TRICKY.getVal()) == 0) {

        load_flags |= Flags.Load.NO_HINTING.getVal();
      }
    }
      /* now load the glyph outline if necessary */
    error = ttslot.TTLoadGlyph(ttsize, glyph_index, load_flags);
      /* force drop-out mode to 2 - irrelevant now */
      /* slot->outline.dropout_mode = 2; */

................................................................................
    Log.e(TAG, "getInterface not yet implemented");
    return FTError.ErrorTag.ERR_OK;
//    return tt_get_interface();
  }

  /* ==================== loadGlyph ===================================== */
  @Override
  public FTError.ErrorTag loadGlyph(FTGlyphSlotRec slot, FTSizeRec size, int glyph_index, int load_flags) {
    return  tt_glyph_load((TTGlyphSlotRec)slot, (TTSizeRec)size, glyph_index, load_flags);
  }

  /* ==================== attachFile ===================================== */
  @Override
  public FTError.ErrorTag attachFile() {
    // nothing to do







>
>







 







|







 







|
|







 







|







 







|


|
|

|
|


|
|
|
>
|







 







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
...
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
...
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406

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";

................................................................................
    if (ttface.getFormat_tag() != TTTags.Table._00010000 &&  /* MS fonts  */
        ttface.getFormat_tag() != TTTags.Table._00020000 && /* CJK fonts for Win 3.1 */
        ttface.getFormat_tag() != TTTags.Table.truE) {   /* Mac fonts */
      FTTrace.Trace(7, TAG, "  not a TTF font");
      error = FTError.ErrorTag.INTERP_UNKNOWN_FILE_FORMAT;
      return error;
    }
    ttface.addFace_flag(Flags.Face.HINTER);
      /* If we are performing a simple font format check, exit immediately. */
    if (face_index < 0) {
      return FTError.ErrorTag.ERR_OK;
    }
      /* Load font directory */
    error = sfnt.loadFace(stream, ttface, face_index, num_params, params);
    if (error != FTError.ErrorTag.ERR_OK) {
................................................................................
//        ttface.face_flags |= FTFaceRec.FT_FACE_FLAG_TRICKY;
//      }
//      error = tt_face_load_hdmx(face, stream);
    if (error != FTError.ErrorTag.ERR_OK) {
      return error;
    }
// FIXME!!
    ttface.addFace_flag(Flags.Face.SCALABLE);
    if (ttface.getFace_flags().contains(Flags.Face.SCALABLE)) {
      if (error == FTError.ErrorTag.ERR_OK) {
        error = ttface.loadLoca(stream);
      }
      if (error == FTError.ErrorTag.ERR_OK) {
        error = ttface.loadCvt(stream);
      }
      if (error == FTError.ErrorTag.ERR_OK) {
................................................................................
   *                   whether to hint the outline, etc).
   *
   * <Return>
   *    FreeType error code.  0 means success.
   *
   * =====================================================================
   */
  public FTError.ErrorTag tt_glyph_load(TTGlyphSlotRec ttslot, TTSizeRec ttsize, int glyph_index, Set<Flags.Load> load_flags) {
Debug(0, DebugTag.DBG_LOAD_FACE, TAG, "tt_glyph_load");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    FTFaceRec face = ttslot.getFace();
    FTReference<TTSizeRec> size_ref = new FTReference<TTSizeRec>();

    if (ttsize == null) {
................................................................................
      error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
      return error;
    }
    if (glyph_index >= face.getNum_glyphs()) {
      error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
      return error;
    }
    if (load_flags.contains(Flags.Load.NO_HINTING)) {
        /* both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT   */
        /* are necessary to disable hinting for tricky fonts */
      if (face.getFace_flags().contains(Flags.Face.TRICKY)) {
        load_flags.remove(Flags.Load.NO_HINTING);
      }
      if (load_flags.contains(Flags.Load.NO_AUTOHINT)) {
        load_flags.add(Flags.Load.NO_HINTING);
      }
    }
    if (load_flags.contains(Flags.Load.NO_RECURSE) || load_flags.contains(Flags.Load.NO_SCALE)) {
      load_flags.add(Flags.Load.NO_BITMAP);
      load_flags.add(Flags.Load.NO_SCALE);
      if (!face.getFace_flags().contains(Flags.Face.TRICKY)) {
        load_flags.add(Flags.Load.NO_HINTING);
      }
    }
      /* now load the glyph outline if necessary */
    error = ttslot.TTLoadGlyph(ttsize, glyph_index, load_flags);
      /* force drop-out mode to 2 - irrelevant now */
      /* slot->outline.dropout_mode = 2; */

................................................................................
    Log.e(TAG, "getInterface not yet implemented");
    return FTError.ErrorTag.ERR_OK;
//    return tt_get_interface();
  }

  /* ==================== loadGlyph ===================================== */
  @Override
  public FTError.ErrorTag loadGlyph(FTGlyphSlotRec slot, FTSizeRec size, int glyph_index, Set<Flags.Load> load_flags) {
    return  tt_glyph_load((TTGlyphSlotRec)slot, (TTSizeRec)size, glyph_index, load_flags);
  }

  /* ==================== attachFile ===================================== */
  @Override
  public FTError.ErrorTag attachFile() {
    // nothing to do

Changes to afttruetype/TTGlyphLoaderRec.java.

135
136
137
138
139
140
141



142

143
144
145
146
147
148
149
//        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.setTag(flag_idx, Flags.Curve.makeTableTagSet(TTTags.GlyphFlags.GlyphFlagsSetToInt(ttglyph.getTag(flag_idx))));

      flag_idx++;
    }
for(int t = 0; t < flag_idx; t++) {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("Tag: t: %d: 0x%02x", t, Flags.Curve.CurveSetToInt(current.getTag(t)))+Flags.Curve.CurveSetToString(current.getTag(t)));
}

      /* loading the x and y coordinates */







>
>
>
|
>







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//        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) {
      if (ttglyph.getTag(flag_idx).isEmpty()) {
        current.setTag(flag_idx, Flags.Curve.CONIC);
      } else {
        current.setTag(flag_idx, Flags.Curve.makeTableTagSet(TTTags.GlyphFlags.GlyphFlagsSetToInt(ttglyph.getTag(flag_idx))));
      }
      flag_idx++;
    }
for(int t = 0; t < flag_idx; t++) {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("Tag: t: %d: 0x%02x", t, Flags.Curve.CurveSetToInt(current.getTag(t)))+Flags.Curve.CurveSetToString(current.getTag(t)));
}

      /* loading the x and y coordinates */

Changes to afttruetype/TTGlyphSlotRec.java.

16
17
18
19
20
21
22


23
24
25
26
27
28
29
..
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
...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
  /* ===================================================================== */
  /*    TTGlyphSlotRec                                                      */
  /*                                                                       */
  /* ===================================================================== */

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



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

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

................................................................................
   *                   whether to hint the outline, etc).
   *
   * <Return>
   *    FreeType error code.  0 means success.
   *
   * =====================================================================
   */
  public FTError.ErrorTag TTLoadGlyph(TTSizeRec ttsize, int glyph_index, int 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 & Flags.Load.NO_SCALE.getVal()) == 0 && ttsize.getTtmetrics().isValid() == false) {
      error = FTError.ErrorTag.LOAD_INVALID_SIZE_HANDLE;
      return error;
    }
    if ((load_flags & Flags.Load.SBITS_ONLY.getVal()) != 0) {
      error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
      return error;
    }
    loader = new TTLoaderRec();
    error = loader.tt_loader_init(ttsize, this, Flags.Load.makeTableTagSet(load_flags), false);
    if (error != FTError.ErrorTag.ERR_OK) {
      return error;
    }
    format = FTTags.GlyphFormat.OUTLINE;
    num_subglyphs = 0;
    outline.setFlags(0);
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "load_truetype_glyph");
................................................................................
              loader.getGloader().getCurrent().getPoint(i).getY()));
        }
        if (loader.getPp1().getX() != 0) {
          outline.OutlineTranslate(-loader.getPp1().getX(), 0);
        }
      }

      Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "IS_HINTED: "+((load_flags & Flags.Load.NO_HINTING.getVal()) == 0));
      if ((load_flags & Flags.Load.NO_HINTING.getVal()) == 0) {
        if (loader.getExec().graphics_state.isScan_control()) {
            /* convert scan conversion mode to FT_OUTLINE_XXX flags */
          Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("IS_HINTED2: %d", loader.getExec().graphics_state.getScan_type()));
          switch (loader.getExec().graphics_state.getScan_type()) {
            case 0: /* simple drop-outs including stubs */
              outline.setFlags(outline.getFlags() | Flags.Outline.INCLUDE_STUBS.getVal());
              break;
................................................................................
      }
      loader.compute_glyph_metrics(glyph_index);
    }
      /* Set the `high precision' bit flag.                           */
      /* This is _critical_ to get correct output for monochrome      */
      /* TrueType glyphs at all sizes using the bytecode interpreter. */
      /*                                                              */
    if ((load_flags & Flags.Load.NO_SCALE.getVal()) == 0 && ttsize.getMetrics().getY_ppem() < 24) {
      outline.setFlags(outline.getFlags() | Flags.Outline.HIGH_PRECISION.getVal());
    }
    return error;
  }

}







>
>







 







|







|



|




|







 







|
|







 







|






16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
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
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
  /* ===================================================================== */
  /*    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 int id;
  private static String TAG = "TTGlyphSlotRec";

................................................................................
   *                   whether to hint the outline, etc).
   *
   * <Return>
   *    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;
      return error;
    }
    loader = new TTLoaderRec();
    error = loader.tt_loader_init(ttsize, this, load_flags, false);
    if (error != FTError.ErrorTag.ERR_OK) {
      return error;
    }
    format = FTTags.GlyphFormat.OUTLINE;
    num_subglyphs = 0;
    outline.setFlags(0);
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "load_truetype_glyph");
................................................................................
              loader.getGloader().getCurrent().getPoint(i).getY()));
        }
        if (loader.getPp1().getX() != 0) {
          outline.OutlineTranslate(-loader.getPp1().getX(), 0);
        }
      }

      Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "IS_HINTED: "+!load_flags.contains(Flags.Load.NO_HINTING));
      if (!load_flags.contains(Flags.Load.NO_HINTING)) {
        if (loader.getExec().graphics_state.isScan_control()) {
            /* convert scan conversion mode to FT_OUTLINE_XXX flags */
          Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("IS_HINTED2: %d", loader.getExec().graphics_state.getScan_type()));
          switch (loader.getExec().graphics_state.getScan_type()) {
            case 0: /* simple drop-outs including stubs */
              outline.setFlags(outline.getFlags() | Flags.Outline.INCLUDE_STUBS.getVal());
              break;
................................................................................
      }
      loader.compute_glyph_metrics(glyph_index);
    }
      /* Set the `high precision' bit flag.                           */
      /* This is _critical_ to get correct output for monochrome      */
      /* TrueType glyphs at all sizes using the bytecode interpreter. */
      /*                                                              */
    if (!load_flags.contains(Flags.Load.NO_SCALE) && ttsize.getMetrics().getY_ppem() < 24) {
      outline.setFlags(outline.getFlags() | Flags.Outline.HIGH_PRECISION.getVal());
    }
    return error;
  }

}

Changes to afttruetype/TTSizeRec.java.

175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
   * =====================================================================
   */
  public FTError.ErrorTag tt_size_request(FTSizeRequestRec req) {
    Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tt_size_request");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    face.getSize().getMetrics().RequestMetrics(face, req);
    if ((face.getFace_flags() & Flags.Face.SCALABLE.getVal()) != 0) {
      error = tt_size_reset();
    }
    return error;
  }

  /* =====================================================================
   * tt_size_reset







|







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
   * =====================================================================
   */
  public FTError.ErrorTag tt_size_request(FTSizeRequestRec req) {
    Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "tt_size_request");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    face.getSize().getMetrics().RequestMetrics(face, req);
    if (face.getFace_flags().contains(Flags.Face.SCALABLE)) {
      error = tt_size_reset();
    }
    return error;
  }

  /* =====================================================================
   * tt_size_reset