apwfreetypelib

Check-in [39e6a60944]
Login

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

Overview
Comment:FTOutlineFuncs deleted, FTGrayOutlineFuncsClass renamed to FTGrayOutlineClass, moved some methods.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:39e6a60944e58837e14f65f9495c4a232ae56b21
User & Date: arnulf 2015-02-08 16:56:38
Context
2015-02-08
20:19
make Flags.Module a Set and fixes. check-in: 199f3dbc0b user: arnulf tags: trunk
16:56
FTOutlineFuncs deleted, FTGrayOutlineFuncsClass renamed to FTGrayOutlineClass, moved some methods. check-in: 39e6a60944 user: arnulf tags: trunk
15:53
move mist of FTGrayOutlineFuncsClass methods to GrayTWorkerRec, some fixes. check-in: b1184a69d5 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to aftbase/FTGlyphSlotRec.java.

374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
      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)) {







|







374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
      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 = outline.FTOutlineCheck();
        if (error != FTError.ErrorTag.ERR_OK) {
          return error;
        }
      }
    }
    /* compute the advance */
    if (load_flags.contains(Flags.Load.VERTICAL_LAYOUT)) {

Deleted aftbase/FTOutlineFuncs.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* =====================================================================
 *  This Java implementation is derived from FreeType code
 *  Portions of this software are copyright (C) 2014 The FreeType
 *  Project (www.freetype.org).  All rights reserved.
 *
 *  Copyright (C) of the Java implementation 2014
 *  Arnulf Wiedemann: arnulf (at) wiedemann-pri (dot) de
 *
 *  See the file "license.terms" for information on usage and
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftbase;

  /* ===================================================================== */
  /*    FTOutlineFuncs                                                          */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

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

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

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

    protected int shift = 0;
    protected int delta = 0;

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

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

  /* ==================== moveTo ===================================== */
  public FTError.ErrorTag moveTo(FTVectorRec point, Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

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

  /* ==================== lineTo ===================================== */
  public FTError.ErrorTag lineTo(FTVectorRec point, Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

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

  /* ==================== conicTo ===================================== */
  public FTError.ErrorTag conicTo(FTVectorRec control, FTVectorRec point, Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

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

  /* ==================== cubicTo ===================================== */
  public FTError.ErrorTag cubicTo(FTVectorRec control1, FTVectorRec control2, FTVectorRec point, Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

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

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

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

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








































































































































































































Changes to aftbase/FTOutlineRec.java.

61
62
63
64
65
66
67

68
69
70
71
72
73
74
..
88
89
90
91
92
93
94



95
96
97
98
99
100
101
...
144
145
146
147
148
149
150
151
152
153
154
155
156
157

158
159
160
161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
...
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
...
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
...
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
...
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
...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
...
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
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
...
715
716
717
718
719
720
721
722



723







  /*    first point of each contour.  The drop-out mode as given with      */
  /*    @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and       */
  /*    @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden.           */
  /*                                                                       */
  /* ===================================================================== */

import android.support.annotation.NonNull;

import android.util.SparseArray;

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;
................................................................................
  protected FTVectorRec[] points = null; /* the outline's points           */
  protected int points_idx = 0;
  protected Set<Flags.Curve>[] tags = null;   /* the points flags               */
  protected int tags_idx = 0;
  protected int[] contours = null;       /* the contour end points         */
  protected int contours_idx = 0;
  protected int flags = 0;               /* outline masks                  */




  /* ==================== FTOutlineRec ================================== */
  public FTOutlineRec() {
    oid++;
    id = oid;
  }
    
................................................................................
   *    outline :: A handle to a source outline.
   *
   * <Return>
   *    FreeType error code.  0~means success.
   *
   * =====================================================================
   */
  public static FTError.ErrorTag FTOutlineCheck(FTOutlineRec outline) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    if (outline != null) {
      int n_points = outline.n_points;
      int n_contours = outline.n_contours;
      int end0, end;

      int n;

      /* empty glyph? */
      if (n_points == 0 && n_contours == 0) {
        return error;
      }
      /* check point and contour counts */
      if (n_points <= 0 || n_contours <= 0) {
        error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
        return error;
      }

      end0 = end = -1;
      for (n = 0; n < n_contours; n++) {
        end = outline.contours[n];
        /* note that we don't accept empty contours */
        if (end <= end0 || end >= n_points) {
          error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
          return error;
        }
        end0 = end;
      }
      if (end != n_points - 1) {
        error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
        return error;
      }
      /* XXX: check the tags array */
      return error;
    }
    return error;
  }

  /* =====================================================================
   * OutlineTranslate
   * =====================================================================
   */
................................................................................
  }
 
  /* =====================================================================
   *    FTOutlineDecompose
   *
   * =====================================================================
   */
  public FTError.ErrorTag FTOutlineDecompose(FTOutlineFuncs func_interface, Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    FTVectorRec v_last;
    FTVectorRec v_control = new FTVectorRec();
    FTVectorRec v_start;
    int pointIdx;
    int limit;
    int tagsIdx;
    int n;        /* index of contour in outline     */
    int first = 0; /* index of first point in contour */
    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++) {
      int last;  /* index of last point in contour */

      isClosed = false;
      FTTrace.Trace(7, TAG, String.format("ftoutline FT_Outline_Decompose: Outline %d of %d", n, n_contours));
      last = contours[n];
................................................................................
        }
        pointIdx--;
        tagsIdx--;
      }
Debug(0, DebugTag.DBG_RENDER, TAG, "Decompose:");
      FTTrace.Trace(7, TAG, String.format("  move to (%.2f, %.2f)",
                  v_start.getX() / 64.0, v_start.getY() / 64.0));
      error = func_interface.moveTo(v_start, user);
      FTTrace.Trace(7, TAG, String.format("  move to after (%.2f, %.2f)",
          v_start.getX() / 64.0, v_start.getY() / 64.0));
      if (error != FTError.ErrorTag.ERR_OK) {
        FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
        return error;
      }
      while (pointIdx < limit) {
................................................................................
          FTVectorRec vec = new FTVectorRec();

Debug(0, DebugTag.DBG_RENDER, TAG, "FT_CURVE_TAG_ON");
          vec.setX((((points[pointIdx].getX())) << shift) - delta);
          vec.setY(((points[pointIdx].getY()) << shift) - delta);
          FTTrace.Trace(7, TAG, String.format("  line to (%.2f, %.2f)\n",
                vec.getX() / 64.0, vec.getY() / 64.0));
          error = func_interface.lineTo(vec, user);
          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 */
................................................................................
              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());
................................................................................
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("doContinue point: %d, limit: %d", pointIdx, limit));
            continue;
          }
          FTTrace.Trace(7, 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));
          error = func_interface.conicTo(v_control, v_start, user);
          if (error != FTError.ErrorTag.ERR_OK) {
            FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
            return error;
          }
          isClosed = true;
Debug(0, DebugTag.DBG_RENDER, TAG, "goto Close");
          break;
................................................................................
              vec.setX((((points[pointIdx].getX()) << shift) - delta));
              vec.setY((((points[pointIdx].getY()) << shift) - delta));
              FTTrace.Trace(7, TAG, String.format(" 1 cubic to (%.2f, %.2f)"+
                          " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
                          vec.getX() / 64.0, vec.getY() / 64.0,
                          vec1.getX() / 64.0, vec1.getY() / 64.0,
                          vec2.getX() / 64.0, vec2.getY() / 64.0));
              error = func_interface.cubicTo(vec1, vec2, vec, user);
              if (error != FTError.ErrorTag.ERR_OK) {
                FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
                return error;
              }
              continue;
            }
            FTTrace.Trace(7, TAG, String.format(" 2 cubic to (%.2f, %.2f)"+
                        " with controls (%.2f, %.2f) and (%.2f, %.2f)",
                        v_start.getX() / 64.0, v_start.getY() / 64.0,
                        vec1.getX() / 64.0, vec1.getY() / 64.0,
                        vec2.getX() / 64.0, vec2.getY() / 64.0));
            error = func_interface.cubicTo(vec1, vec2, v_start, user);
            if (error != FTError.ErrorTag.ERR_OK) {
              FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
              return error;
            }
            isClosed = true;
            break;
          }
................................................................................
        }
      }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==5 after while(pointIdx < limit) isClosed: %b v_start.x: %d, v_start.y: %d", isClosed, v_start.getX(), v_start.getY()));
      if (! isClosed) {
        /* close the contour with a line segment */
        FTTrace.Trace(7, TAG, String.format(" 2 line to (%.2f, %.2f)",
                  v_start.getX() / 64.0, v_start.getY() / 64.0));
        error = func_interface.lineTo(v_start, user);
      }
      if (error != FTError.ErrorTag.ERR_OK) {
        FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
        return error;
      }
      first = last + 1;
    }

    FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Done %d", n));
    return FTError.ErrorTag.ERR_OK;
  }

































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

  /* ==================== setN_contours ================================== */
................................................................................
    return contours_idx;
  }

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




}














>







 







>
>
>







 







|

<
<
<
<
|
>
|

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







 







|










<
<





<
<
<
<
<







 







|







 







|







 







|







 







|







 







|







 







|











|







 







|











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







 








>
>
>
|
>
>
>
>
>
>
>
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
148
149
150
151
152
153
154
155
156




157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185


186
187
188
189
190
191
192
...
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
...
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
...
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
...
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
...
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
...
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
541
542
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
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
...
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
  /*    first point of each contour.  The drop-out mode as given with      */
  /*    @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and       */
  /*    @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden.           */
  /*                                                                       */
  /* ===================================================================== */

import android.support.annotation.NonNull;
import android.util.Log;
import android.util.SparseArray;

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;
................................................................................
  protected FTVectorRec[] points = null; /* the outline's points           */
  protected int points_idx = 0;
  protected Set<Flags.Curve>[] tags = null;   /* the points flags               */
  protected int tags_idx = 0;
  protected int[] contours = null;       /* the contour end points         */
  protected int contours_idx = 0;
  protected int flags = 0;               /* outline masks                  */

  protected int shift = 0;
  protected int delta = 0;

  /* ==================== FTOutlineRec ================================== */
  public FTOutlineRec() {
    oid++;
    id = oid;
  }
    
................................................................................
   *    outline :: A handle to a source outline.
   *
   * <Return>
   *    FreeType error code.  0~means success.
   *
   * =====================================================================
   */
  public FTError.ErrorTag FTOutlineCheck() {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;




    int end0;
    int end;
    int n;

    /* empty glyph? */
    if (n_points == 0 && n_contours == 0) {
      return error;
    }
    /* check point and contour counts */
     if (n_points <= 0 || n_contours <= 0) {
      error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
      return error;
    }
    end0 = -1;
    end = -1;
    for (n = 0; n < n_contours; n++) {
      end = contours[n];
      /* note that we don't accept empty contours */
      if (end <= end0 || end >= n_points) {
        error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
        return error;
      }
      end0 = end;
    }
    if (end != n_points - 1) {
      error = FTError.ErrorTag.LOAD_INVALID_ARGUMENT;
      return error;
    }
    /* XXX: check the tags array */


    return error;
  }

  /* =====================================================================
   * OutlineTranslate
   * =====================================================================
   */
................................................................................
  }
 
  /* =====================================================================
   *    FTOutlineDecompose
   *
   * =====================================================================
   */
  public FTError.ErrorTag FTOutlineDecompose(Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    FTVectorRec v_last;
    FTVectorRec v_control = new FTVectorRec();
    FTVectorRec v_start;
    int pointIdx;
    int limit;
    int tagsIdx;
    int n;        /* index of contour in outline     */
    int first = 0; /* index of first point in contour */
    Set<Flags.Curve> tag;       /* current point's state           */


    boolean doConic = true;
    boolean doContinue = false;
    boolean isClosed = false;

Debug(0, DebugTag.DBG_RENDER, TAG, "FTOutlineRec FTOutlineDecompose");





    first = 0;
    for (n = 0; n < n_contours; n++) {
      int last;  /* index of last point in contour */

      isClosed = false;
      FTTrace.Trace(7, TAG, String.format("ftoutline FT_Outline_Decompose: Outline %d of %d", n, n_contours));
      last = contours[n];
................................................................................
        }
        pointIdx--;
        tagsIdx--;
      }
Debug(0, DebugTag.DBG_RENDER, TAG, "Decompose:");
      FTTrace.Trace(7, TAG, String.format("  move to (%.2f, %.2f)",
                  v_start.getX() / 64.0, v_start.getY() / 64.0));
      error = moveTo(v_start, user);
      FTTrace.Trace(7, TAG, String.format("  move to after (%.2f, %.2f)",
          v_start.getX() / 64.0, v_start.getY() / 64.0));
      if (error != FTError.ErrorTag.ERR_OK) {
        FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
        return error;
      }
      while (pointIdx < limit) {
................................................................................
          FTVectorRec vec = new FTVectorRec();

Debug(0, DebugTag.DBG_RENDER, TAG, "FT_CURVE_TAG_ON");
          vec.setX((((points[pointIdx].getX())) << shift) - delta);
          vec.setY(((points[pointIdx].getY()) << shift) - delta);
          FTTrace.Trace(7, TAG, String.format("  line to (%.2f, %.2f)\n",
                vec.getX() / 64.0, vec.getY() / 64.0));
          error = lineTo(vec, user);
          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 */
................................................................................
              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 = 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 = 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());
................................................................................
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("doContinue point: %d, limit: %d", pointIdx, limit));
            continue;
          }
          FTTrace.Trace(7, 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));
          error = conicTo(v_control, v_start, user);
          if (error != FTError.ErrorTag.ERR_OK) {
            FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
            return error;
          }
          isClosed = true;
Debug(0, DebugTag.DBG_RENDER, TAG, "goto Close");
          break;
................................................................................
              vec.setX((((points[pointIdx].getX()) << shift) - delta));
              vec.setY((((points[pointIdx].getY()) << shift) - delta));
              FTTrace.Trace(7, TAG, String.format(" 1 cubic to (%.2f, %.2f)"+
                          " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
                          vec.getX() / 64.0, vec.getY() / 64.0,
                          vec1.getX() / 64.0, vec1.getY() / 64.0,
                          vec2.getX() / 64.0, vec2.getY() / 64.0));
              error = cubicTo(vec1, vec2, vec, user);
              if (error != FTError.ErrorTag.ERR_OK) {
                FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
                return error;
              }
              continue;
            }
            FTTrace.Trace(7, TAG, String.format(" 2 cubic to (%.2f, %.2f)"+
                        " with controls (%.2f, %.2f) and (%.2f, %.2f)",
                        v_start.getX() / 64.0, v_start.getY() / 64.0,
                        vec1.getX() / 64.0, vec1.getY() / 64.0,
                        vec2.getX() / 64.0, vec2.getY() / 64.0));
            error = cubicTo(vec1, vec2, v_start, user);
            if (error != FTError.ErrorTag.ERR_OK) {
              FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
              return error;
            }
            isClosed = true;
            break;
          }
................................................................................
        }
      }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==5 after while(pointIdx < limit) isClosed: %b v_start.x: %d, v_start.y: %d", isClosed, v_start.getX(), v_start.getY()));
      if (! isClosed) {
        /* close the contour with a line segment */
        FTTrace.Trace(7, TAG, String.format(" 2 line to (%.2f, %.2f)",
                  v_start.getX() / 64.0, v_start.getY() / 64.0));
        error = lineTo(v_start, user);
      }
      if (error != FTError.ErrorTag.ERR_OK) {
        FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Error %d", error));
        return error;
      }
      first = last + 1;
    }

    FTTrace.Trace(7, TAG, String.format("FT_Outline_Decompose: Done %d", n));
    return FTError.ErrorTag.ERR_OK;
  }

  /* ==================== moveTo ===================================== */
  public FTError.ErrorTag moveTo(FTVectorRec point, Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

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

  /* ==================== lineTo ===================================== */
  public FTError.ErrorTag lineTo(FTVectorRec point, Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

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

  /* ==================== conicTo ===================================== */
  public FTError.ErrorTag conicTo(FTVectorRec control, FTVectorRec point, Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

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

  /* ==================== cubicTo ===================================== */
  public FTError.ErrorTag cubicTo(FTVectorRec control1, FTVectorRec control2, FTVectorRec point, Object user) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

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

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

  /* ==================== setN_contours ================================== */
................................................................................
    return contours_idx;
  }

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

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

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

}

Name change from aftraster/FTGrayOutlineFuncsClass.java to aftraster/FTGrayOutlineClass.java.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    RasterUtil.                                                         */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTOutlineFuncs;
import org.apwtcl.apwfreetypelib.aftbase.FTOutlineRec;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;
import org.apwtcl.apwfreetypelib.aftutil.RasterUtil;

public class FTGrayOutlineFuncsClass extends FTOutlineFuncs {
  private static int oid = 0;

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

  public static int PIXEL_BITS = 8;

  /* ==================== FTGrayOutlineFuncsClass ================================== */
  public FTGrayOutlineFuncsClass() {
    oid++;
    id = oid;
    shift = 0;
    delta = 0;
  }
    
  /* ==================== mySelf ================================== */







<
<
<

<

<

<

|



|



|
|







14
15
16
17
18
19
20



21

22

23

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    RasterUtil.                                                         */
  /*                                                                       */
  /* ===================================================================== */




import org.apwtcl.apwfreetypelib.aftbase.FTOutlineRec;

import org.apwtcl.apwfreetypelib.aftutil.FTError;

import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;


public class FTGrayOutlineClass extends FTOutlineRec {
  private static int oid = 0;

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

  public static int PIXEL_BITS = 8;

  /* ==================== FTGrayOutlineClass ================================== */
  public FTGrayOutlineClass() {
    oid++;
    id = oid;
    shift = 0;
    delta = 0;
  }
    
  /* ==================== mySelf ================================== */

Changes to aftraster/grayTWorkerRec.java.

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
...
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
import org.apwtcl.apwfreetypelib.aftbase.FTBBoxRec;
import org.apwtcl.apwfreetypelib.aftbase.FTBitmapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTOutlineRec;
import org.apwtcl.apwfreetypelib.aftbase.Flags;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTTrace;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;
import org.apwtcl.apwfreetypelib.aftutil.RasterUtil;

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

................................................................................
  private int span_y;
  private int band_size;
  private int band_shoot;
  private byte[] buffer;
  private int buffer_size;
  private TCellRec[] ycells;
  private int ycount;
  private FTGrayOutlineFuncsClass outline_funcs = null;

  /* ==================== grayTWorker ================================== */
  public grayTWorkerRec() {
    int i;

    oid++;
    id = oid;
................................................................................
    clip_box = new FTBBoxRec();
    for (i = 0; i < FTSpanRec.FT_MAX_GRAY_SPANS; i++) {
      gray_spans[i] = new FTSpanRec();
    }
    for (i = 0; i < MaxBezier * 3 + 1; i++) {
      bez_stack[i] = new FTVectorRec();
    }
    outline_funcs = new FTGrayOutlineFuncsClass();
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
    return TAG+"!"+id+"!";
  }
        
................................................................................
   * =====================================================================
   */
  public FTError.ErrorTag gray_convert_glyph_inner() {
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_convert_glyph_inner");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

//      if (ft_setjmp(ras.jump_buffer) == 0) {
    error = outline.FTOutlineDecompose(outline_funcs, this);
    gray_record_cell();
//      } else {
//        error = FT_THROW( Memory_Overflow );
//      }
    return error;
  }

................................................................................
    int spanIdx = 0;

      /* compute the coverage line's coverage, depending on the    */
      /* outline fill rule                                         */
      /*                                                           */
      /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
      /*                                                           */
    coverage = (area >> (FTGrayOutlineFuncsClass.PIXEL_BITS * 2 + 1 - 8));
                                                      /* use range 0..256 */
    if (coverage < 0) {
      coverage = -coverage;
    }
    if ((outline.getFlags() & Flags.Outline.EVEN_ODD_FILL.getVal()) != 0) {
      coverage &= 511;
      if (coverage > 256) {







<







 







<







 







<







 







|







 







|







23
24
25
26
27
28
29

30
31
32
33
34
35
36
..
68
69
70
71
72
73
74

75
76
77
78
79
80
81
..
84
85
86
87
88
89
90

91
92
93
94
95
96
97
...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
...
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
import org.apwtcl.apwfreetypelib.aftbase.FTBBoxRec;
import org.apwtcl.apwfreetypelib.aftbase.FTBitmapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTOutlineRec;
import org.apwtcl.apwfreetypelib.aftbase.Flags;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;

import org.apwtcl.apwfreetypelib.aftutil.FTTrace;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;
import org.apwtcl.apwfreetypelib.aftutil.RasterUtil;

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

................................................................................
  private int span_y;
  private int band_size;
  private int band_shoot;
  private byte[] buffer;
  private int buffer_size;
  private TCellRec[] ycells;
  private int ycount;


  /* ==================== grayTWorker ================================== */
  public grayTWorkerRec() {
    int i;

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

  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
    return TAG+"!"+id+"!";
  }
        
................................................................................
   * =====================================================================
   */
  public FTError.ErrorTag gray_convert_glyph_inner() {
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_convert_glyph_inner");
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

//      if (ft_setjmp(ras.jump_buffer) == 0) {
    error = outline.FTOutlineDecompose(this);
    gray_record_cell();
//      } else {
//        error = FT_THROW( Memory_Overflow );
//      }
    return error;
  }

................................................................................
    int spanIdx = 0;

      /* compute the coverage line's coverage, depending on the    */
      /* outline fill rule                                         */
      /*                                                           */
      /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
      /*                                                           */
    coverage = (area >> (FTGrayOutlineClass.PIXEL_BITS * 2 + 1 - 8));
                                                      /* use range 0..256 */
    if (coverage < 0) {
      coverage = -coverage;
    }
    if ((outline.getFlags() & Flags.Outline.EVEN_ODD_FILL.getVal()) != 0) {
      coverage &= 511;
      if (coverage > 256) {