apwfreetypelib

Check-in [4621cff9f7]
Login

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

Overview
Comment:fixes and added new Debug tags.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4621cff9f7c0a4571d37142b3d369edb2f9858af
User & Date: arnulf 2015-02-14 18:22:57
Context
2015-02-14
20:30
splitting up of grayTWorker onto several derirvced classes. check-in: a767fde976 user: arnulf tags: trunk
18:22
fixes and added new Debug tags. check-in: 4621cff9f7 user: arnulf tags: trunk
2015-02-08
20:19
make Flags.Module a Set and fixes. check-in: 199f3dbc0b user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to aftbase/FTBitmapRec.java.

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
...
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
...
467
468
469
470
471
472
473
474



475













































































    str.append("..pitch: "+pitch+'\n');
    str.append("..num_grays: "+num_grays+'\n');
    str.append("..pixel_mode: "+pixel_mode+'\n');
    str.append("..palette_mode: "+palette_mode+'\n');
    return str.toString();
  }

  /* ==================== getRows ================================== */
  public int getRows() {
    return rows;
  }

  /* ==================== setRows ================================== */
  public void setRows(int rows) {
    this.rows = rows;
  }

  /* ==================== getWidth ================================== */
  public int getWidth() {
    return width;
  }

  /* ==================== setWidth ================================== */
  public void setWidth(int width) {
    this.width = width;
  }

  /* ==================== getPitch ================================== */
  public int getPitch() {
    return pitch;
  }

  /* ==================== setPitch ================================== */
  public void setPitch(int pitch) {
    this.pitch = pitch;
  }

  /* ==================== getBuffer ================================== */
  public byte[] getBuffer() {
    return buffer;
  }

  /* ==================== setBuffer ================================== */
  public void setBuffer(byte[] buffer) {
    this.buffer = buffer;
  }

  /* ==================== getNum_grays ================================== */
  public int getNum_grays() {
    return num_grays;
  }

  /* ==================== setNum_grays ================================== */
  public void setNum_grays(int num_grays) {
    this.num_grays = num_grays;
  }

  /* ==================== getPixel_mode ================================== */
  public FTTags.PixelMode getPixel_mode() {
    return pixel_mode;
  }

  /* ==================== setPixel_mode ================================== */
  public void setPixel_mode(FTTags.PixelMode pixel_mode) {
    this.pixel_mode = pixel_mode;
  }

  /* ==================== getPalette_mode ================================== */
  public byte getPalette_mode() {
    return palette_mode;
  }

  /* ==================== setPalette_mode ================================== */
  public void setPalette_mode(byte palette_mode) {
    this.palette_mode = palette_mode;
  }

  /* ==================== getPalette ================================== */
  public Object getPalette() {
    return palette;
  }

  /* ==================== setPalette ================================== */
  public void setPalette(Object palette) {
    this.palette = palette;
  }

  /* =====================================================================
   * Convert
   * =====================================================================
   */
  public FTError.ErrorTag Convert(FTLibraryRec library, FTBitmapRec target, int alignment) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
................................................................................
    int col = 0;
    int idx;
    StringBuffer str = new StringBuffer();

    if (library == null) {
      return FTError.ErrorTag.GLYPH_INVALID_LIBRARY_HANDLE;
    }
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "Bitmap slot buffer:");
idx = 0;
for (row = 0; row < rows; row++) {
  str.delete(0, str.length());
  str.append(String.format("row: %02d ", row));
  for (col = 0; col < width; col++) {
    str.append(String.format(" 0x%02x", buffer[idx]));
    idx++;
  }
  Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, str.toString());
}
    switch (pixel_mode) {
      case MONO:
      case GRAY:
      case GRAY2:
      case GRAY4:
      case LCD:
................................................................................
  }

  /* =====================================================================
   * Done
   * =====================================================================
   */
  public FTError.ErrorTag Done(FTLibraryRec library) {
    Log.w(TAG, "FTBitmapDone: not yet implemented\n");
    if (library == null) {
      return FTError.ErrorTag.RENDER_INVALID_LIBRARY_HANDLE;
    }
    rows = 0;
    width = 0;
    pitch = 0;
    buffer = null;
................................................................................
   * =====================================================================
   */
  public Byte ft_gray_for_premultiplied_srgb_bgra(FTReference<byte[]> ss_ref, int ss_idx) {
    Log.w(TAG, "ft_gray_for_premultiplied_srgb_bgra: not yet implemented!!\n");
    byte[] ss = ss_ref.Get();
    return ss[ss_idx];
  }




}




















































































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







 







|








|







 







<







 








>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
122
123
124
125
126
127
128















































































129
130
131
132
133
134
135
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
364
365
366
367
368
369
370

371
372
373
374
375
376
377
...
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
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
    str.append("..pitch: "+pitch+'\n');
    str.append("..num_grays: "+num_grays+'\n');
    str.append("..pixel_mode: "+pixel_mode+'\n');
    str.append("..palette_mode: "+palette_mode+'\n');
    return str.toString();
  }

















































































  /* =====================================================================
   * Convert
   * =====================================================================
   */
  public FTError.ErrorTag Convert(FTLibraryRec library, FTBitmapRec target, int alignment) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
................................................................................
    int col = 0;
    int idx;
    StringBuffer str = new StringBuffer();

    if (library == null) {
      return FTError.ErrorTag.GLYPH_INVALID_LIBRARY_HANDLE;
    }
Debug(0, DebugTag.DBG_RENDER, TAG, "Bitmap slot buffer:");
idx = 0;
for (row = 0; row < rows; row++) {
  str.delete(0, str.length());
  str.append(String.format("row: %02d ", row));
  for (col = 0; col < width; col++) {
    str.append(String.format(" 0x%02x", buffer[idx]));
    idx++;
  }
  Debug(0, DebugTag.DBG_RENDER, TAG, str.toString());
}
    switch (pixel_mode) {
      case MONO:
      case GRAY:
      case GRAY2:
      case GRAY4:
      case LCD:
................................................................................
  }

  /* =====================================================================
   * Done
   * =====================================================================
   */
  public FTError.ErrorTag Done(FTLibraryRec library) {

    if (library == null) {
      return FTError.ErrorTag.RENDER_INVALID_LIBRARY_HANDLE;
    }
    rows = 0;
    width = 0;
    pitch = 0;
    buffer = null;
................................................................................
   * =====================================================================
   */
  public Byte ft_gray_for_premultiplied_srgb_bgra(FTReference<byte[]> ss_ref, int ss_idx) {
    Log.w(TAG, "ft_gray_for_premultiplied_srgb_bgra: not yet implemented!!\n");
    byte[] ss = ss_ref.Get();
    return ss[ss_idx];
  }

  /* ==================== getRows ================================== */
  public int getRows() {
    return rows;
  }

  /* ==================== setRows ================================== */
  public void setRows(int rows) {
    this.rows = rows;
  }

  /* ==================== getWidth ================================== */
  public int getWidth() {
    return width;
  }

  /* ==================== setWidth ================================== */
  public void setWidth(int width) {
    this.width = width;
  }

  /* ==================== getPitch ================================== */
  public int getPitch() {
    return pitch;
  }

  /* ==================== setPitch ================================== */
  public void setPitch(int pitch) {
    this.pitch = pitch;
  }

  /* ==================== getBuffer ================================== */
  public byte[] getBuffer() {
    return buffer;
  }

  /* ==================== setBuffer ================================== */
  public void setBuffer(byte[] buffer) {
    this.buffer = buffer;
  }

  /* ==================== getNum_grays ================================== */
  public int getNum_grays() {
    return num_grays;
  }

  /* ==================== setNum_grays ================================== */
  public void setNum_grays(int num_grays) {
    this.num_grays = num_grays;
  }

  /* ==================== getPixel_mode ================================== */
  public FTTags.PixelMode getPixel_mode() {
    return pixel_mode;
  }

  /* ==================== setPixel_mode ================================== */
  public void setPixel_mode(FTTags.PixelMode pixel_mode) {
    this.pixel_mode = pixel_mode;
  }

  /* ==================== getPalette_mode ================================== */
  public byte getPalette_mode() {
    return palette_mode;
  }

  /* ==================== setPalette_mode ================================== */
  public void setPalette_mode(byte palette_mode) {
    this.palette_mode = palette_mode;
  }

  /* ==================== getPalette ================================== */
  public Object getPalette() {
    return palette;
  }

  /* ==================== setPalette ================================== */
  public void setPalette(Object palette) {
    this.palette = palette;
  }

}

Changes to aftbase/FTGlyphSlotRec.java.

540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
        FTRendererRec.FTSetRenderer(library, renderer, 0, null);
      }
    }
    /* we convert to a single bitmap format for computing the checksum */
    {
      FTBitmapRec bitmap = new FTBitmapRec();
      FTError.ErrorTag err;
      FTReference<FTBitmapRec> bitmap_ref = new FTReference<FTBitmapRec>();

      bitmap_ref.Set(bitmap);
      StringBuffer str = new StringBuffer("");
      Debug(0, DebugTag.DBG_RENDER, TAG, String.format("before BITMAP convert: rows %d width %d pitch %d num_grays %d", bitmap.getRows(), bitmap.getWidth(), bitmap.getPitch(), bitmap.getNum_grays()));
      Debug(0, DebugTag.DBG_RENDER, TAG, String.format("before BITMAP convert slot: rows %d width %d pitch %d num_grays %d", this.bitmap.getRows(), this.bitmap.getWidth(), this.bitmap.getPitch(), this.bitmap.getNum_grays()));
      err = this.bitmap.Convert(library, bitmap, 1);
      Debug(0, DebugTag.DBG_RENDER, TAG, String.format("after BITMAP convert: rows %d width %d pitch %d num_grays %d", bitmap.getRows(), bitmap.getWidth(), bitmap.getPitch(), bitmap.getNum_grays()));
      bitmap = bitmap_ref.Get();
      int r;
      int c;
//Debug(0, DebugTag.DBG_RENDER, TAG, String.format("++ Bitmapconv char: %c %d rows: %d width: %d",
//    FTDemoHandle.currCharacter, FTDemoHandle.currGIndex, bitmap.rows, bitmap.width));
      str = new StringBuffer("");
      for(r = 0; r < bitmap.getRows(); r++) {
        str.delete(0,  str.length());







|

<
<
|
<


<







540
541
542
543
544
545
546
547
548


549

550
551

552
553
554
555
556
557
558
        FTRendererRec.FTSetRenderer(library, renderer, 0, null);
      }
    }
    /* we convert to a single bitmap format for computing the checksum */
    {
      FTBitmapRec bitmap = new FTBitmapRec();
      FTError.ErrorTag err;
      StringBuffer str;



Debug(0, DebugTag.DBG_RENDER, TAG, String.format("before BITMAP convert: rows %d width %d pitch %d num_grays %d", bitmap.getRows(), bitmap.getWidth(), bitmap.getPitch(), bitmap.getNum_grays()));

      err = this.bitmap.Convert(library, bitmap, 1);
      Debug(0, DebugTag.DBG_RENDER, TAG, String.format("after BITMAP convert: rows %d width %d pitch %d num_grays %d", bitmap.getRows(), bitmap.getWidth(), bitmap.getPitch(), bitmap.getNum_grays()));

      int r;
      int c;
//Debug(0, DebugTag.DBG_RENDER, TAG, String.format("++ Bitmapconv char: %c %d rows: %d width: %d",
//    FTDemoHandle.currCharacter, FTDemoHandle.currGIndex, bitmap.rows, bitmap.width));
      str = new StringBuffer("");
      for(r = 0; r < bitmap.getRows(); r++) {
        str.delete(0,  str.length());

Changes to aftbase/FTOutlineRec.java.

330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
...
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
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
...
458
459
460
461
462
463
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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
...
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
    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];
      if (last < 0) {
        return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
      }
      limit = last;
      v_start = points[first];
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("first: %d,  last: %d, v_start.x: %d, v_start.y: %d", first, last, v_start.getX(), v_start.getY()));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("delta: %d, shift: %d", delta, shift));
      v_start.setX(((v_start.getX()) << shift) - delta);
      v_start.setY(((v_start.getY()) << shift) - delta);
      v_last = points[last];
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("v_last.x: %d, v_last.y: %d", v_last.getX(), v_last.getY()));
      v_last.setX(((v_last.getX()) << shift) - delta);
      v_last.setY(((v_last.getY()) << shift) - delta);
      v_control.setX(v_start.getX());
      v_control.setY(v_start.getY());
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("v_start: %d %d v_last: %d %d", v_start.getX(), v_start.getY(), v_last.getX(), v_last.getY()));
      pointIdx = first;
      tagsIdx = first;
      tag = tags[tagsIdx];
      /* A contour cannot start with a cubic control point! */
      if (tag.contains(Flags.Curve.CUBIC)) {
        return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
      }
................................................................................
          v_start.setY((v_start.getY() + v_last.getY()) / 2);
          v_last.setX(v_start.getX());
          v_last.setY(v_start.getY());
        }
        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) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("decompose1: pointIdx: %d, limit: %d, n: %d, outline.n_contours: %d", pointIdx, limit, n, n_contours));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("==2 v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
        pointIdx++;
        tagsIdx++;
        tag = tags[tagsIdx];
        if (tag.contains(Flags.Curve.ON)) {
          /* emit a single line_to */
          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 */
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 = 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());
              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) {
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;
        } else {
          /* FT_CURVE_TAG_CUBIC */
          {
            FTVectorRec vec1 = new FTVectorRec();
            FTVectorRec vec2 = new FTVectorRec();

Debug(0, DebugTag.DBG_RENDER, TAG, "FT_CURVE_TAG_CUBIC");
            if (pointIdx + 1 > limit ||
                 (!tags[tagsIdx + 1].contains(Flags.Curve.CUBIC))) {
              return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
            }
            pointIdx += 2;
            tagsIdx += 2;
            vec1.setX((((points[pointIdx - 2].getX()) << shift) - delta));
................................................................................
              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) {







|












|
|



|




|







 







|










|
|







|












|
|




|

|










|






|







 







|







|


|

|












|







|







 







|







330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
...
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
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
...
458
459
460
461
462
463
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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
...
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
    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_DECOMPOSE, 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];
      if (last < 0) {
        return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
      }
      limit = last;
      v_start = points[first];
Debug(0, DebugTag.DBG_DECOMPOSE, TAG, String.format("first: %d,  last: %d, v_start.x: %d, v_start.y: %d", first, last, v_start.getX(), v_start.getY()));
Debug(0, DebugTag.DBG_DECOMPOSE, TAG, String.format("delta: %d, shift: %d", delta, shift));
      v_start.setX(((v_start.getX()) << shift) - delta);
      v_start.setY(((v_start.getY()) << shift) - delta);
      v_last = points[last];
Debug(0, DebugTag.DBG_DECOMPOSE, TAG, String.format("v_last.x: %d, v_last.y: %d", v_last.getX(), v_last.getY()));
      v_last.setX(((v_last.getX()) << shift) - delta);
      v_last.setY(((v_last.getY()) << shift) - delta);
      v_control.setX(v_start.getX());
      v_control.setY(v_start.getY());
Debug(0, DebugTag.DBG_DECOMPOSE, TAG, String.format("v_start: %d %d v_last: %d %d", v_start.getX(), v_start.getY(), v_last.getX(), v_last.getY()));
      pointIdx = first;
      tagsIdx = first;
      tag = tags[tagsIdx];
      /* A contour cannot start with a cubic control point! */
      if (tag.contains(Flags.Curve.CUBIC)) {
        return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
      }
................................................................................
          v_start.setY((v_start.getY() + v_last.getY()) / 2);
          v_last.setX(v_start.getX());
          v_last.setY(v_start.getY());
        }
        pointIdx--;
        tagsIdx--;
      }
Debug(0, DebugTag.DBG_DECOMPOSE, 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) {
Debug(0, DebugTag.DBG_DECOMPOSE, TAG, String.format("decompose1: pointIdx: %d, limit: %d, n: %d, outline.n_contours: %d", pointIdx, limit, n, n_contours));
Debug(0, DebugTag.DBG_DECOMPOSE, TAG, String.format("==2 v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
        pointIdx++;
        tagsIdx++;
        tag = tags[tagsIdx];
        if (tag.contains(Flags.Curve.ON)) {
          /* emit a single line_to */
          FTVectorRec vec = new FTVectorRec();

Debug(0, DebugTag.DBG_DECOMPOSE, 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 */
Debug(0, DebugTag.DBG_DECOMPOSE, TAG, "FT_CURVE_TAG_CONIC");
Debug(0, DebugTag.DBG_DECOMPOSE, 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_DECOMPOSE, TAG, String.format("decompose doConic: pointIdx: %d,  limit: %d", pointIdx, limit));
            doConic = false;
Debug(0, DebugTag.DBG_DECOMPOSE, 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_DECOMPOSE, 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_DECOMPOSE, 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_DECOMPOSE, 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_DECOMPOSE, TAG, String.format("==4a v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
            }
          }
Debug(0, DebugTag.DBG_DECOMPOSE, TAG, String.format("==4b v_start.x: %d, v_start.y: %d", v_start.getX(), v_start.getY()));
          if (doContinue) {
Debug(0, DebugTag.DBG_DECOMPOSE, 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_DECOMPOSE, TAG, "goto Close");
          break;
        } else {
          /* FT_CURVE_TAG_CUBIC */
          {
            FTVectorRec vec1 = new FTVectorRec();
            FTVectorRec vec2 = new FTVectorRec();

Debug(0, DebugTag.DBG_DECOMPOSE, TAG, "FT_CURVE_TAG_CUBIC");
            if (pointIdx + 1 > limit ||
                 (!tags[tagsIdx + 1].contains(Flags.Curve.CUBIC))) {
              return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
            }
            pointIdx += 2;
            tagsIdx += 2;
            vec1.setX((((points[pointIdx - 2].getX()) << shift) - delta));
................................................................................
              return error;
            }
            isClosed = true;
            break;
          }
        }
      }
Debug(0, DebugTag.DBG_DECOMPOSE, 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) {

Changes to aftbase/MD5CTX.java.

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
...
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
...
445
446
447
448
449
450
451
452
453
454
455
456
  }

  /* =====================================================================
   * I
   * =====================================================================
   */
  private long I(long x, long y, long z) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("I fcn: x: 0x%08x, y: 0x%08x, z: 0x%08x, val: 0x%08x", x, y, z, (y ^ (x | ~z))));
    return (y ^ (x | ~z));
  }

  /* =====================================================================
   * SET
   * =====================================================================
   */
................................................................................
    long c;
    long d;
    long saved_a;
    long saved_b;
    long saved_c;
    long saved_d;

Debug(0, DebugTag.DBG_RENDER, TAG, "BODY:");
    ptr = this.buffer;
    this.a = this.a & 0xFFFFFFFFL;
    this.b = this.b & 0xFFFFFFFFL;
    this.c = this.c & 0xFFFFFFFFL;
    this.d = this.d & 0xFFFFFFFFL;
    a = this.a;
    b = this.b;
    c = this.c;
    d = this.d;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("ctx.a: 0x%08x", a));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("ctx.b: 0x%08x", b));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("ctx.c: 0x%08x", c));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("ctx.d: 0x%08x", d));
    do {
      saved_a = a;
      saved_b = b;
      saved_c = c;
      saved_d = d;
/* Round 1 */
//System.out.println("ROUND1");        
................................................................................
//System.out.println(String.format("SIZE: %d", size));              	
    } while ((size -= 64) != 0);

    this.a = a;
    this.b = b;
    this.c = c;
    this.d = d;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("end ctx.a: 0x%08x", a));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("end ctx.b: 0x%08x", b));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("end ctx.c: 0x%08x", c));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("end ctx.d: 0x%08x", d));
    return ptr_idx;
  }


  /* =====================================================================
   * MD5Init
   * =====================================================================
................................................................................
    	ctx_buffer_idx = body(0, 64);
    }
    if (size >= 64) {
    	data_idx = body(data_idx, (size & ~0x3FL));
    	size &= 0x3f;
    }
    for (i = 0; i < size; i++) {
      Debug(0, DebugTag.DBG_RENDER, TAG, String.format("ctx.buffer[i]: %d 0x%02x", i, this.buffer[i]));
    }
    for (i = 0; i < size; i++) {
      this.buffer[i] = data[data_idx++];
    }
    data_ref.Set(data);
  }

................................................................................
    result[10] = (byte)(this.c >> 16);
    result[11] = (byte)(this.c >> 24);
    result[12] = (byte)this.d;
    result[13] = (byte)(this.d >> 8);
    result[14] = (byte)(this.d >> 16);
    result[15] = (byte)(this.d >> 24);
for(int j = 0; j < 16; j++) {
  Debug(0, DebugTag.DBG_RENDER, TAG, String.format("MD5 j: %d 0x%02x", j, result[j] & 0xFF));
}
  }

}







|







 







|









|
|
|
|







 







|
|
|
|







 







|







 







|




86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
...
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
...
445
446
447
448
449
450
451
452
453
454
455
456
  }

  /* =====================================================================
   * I
   * =====================================================================
   */
  private long I(long x, long y, long z) {
Debug(0, DebugTag.DBG_MD5, TAG, String.format("I fcn: x: 0x%08x, y: 0x%08x, z: 0x%08x, val: 0x%08x", x, y, z, (y ^ (x | ~z))));
    return (y ^ (x | ~z));
  }

  /* =====================================================================
   * SET
   * =====================================================================
   */
................................................................................
    long c;
    long d;
    long saved_a;
    long saved_b;
    long saved_c;
    long saved_d;

Debug(0, DebugTag.DBG_MD5, TAG, "BODY:");
    ptr = this.buffer;
    this.a = this.a & 0xFFFFFFFFL;
    this.b = this.b & 0xFFFFFFFFL;
    this.c = this.c & 0xFFFFFFFFL;
    this.d = this.d & 0xFFFFFFFFL;
    a = this.a;
    b = this.b;
    c = this.c;
    d = this.d;
Debug(0, DebugTag.DBG_MD5, TAG, String.format("ctx.a: 0x%08x", a));
Debug(0, DebugTag.DBG_MD5, TAG, String.format("ctx.b: 0x%08x", b));
Debug(0, DebugTag.DBG_MD5, TAG, String.format("ctx.c: 0x%08x", c));
Debug(0, DebugTag.DBG_MD5, TAG, String.format("ctx.d: 0x%08x", d));
    do {
      saved_a = a;
      saved_b = b;
      saved_c = c;
      saved_d = d;
/* Round 1 */
//System.out.println("ROUND1");        
................................................................................
//System.out.println(String.format("SIZE: %d", size));              	
    } while ((size -= 64) != 0);

    this.a = a;
    this.b = b;
    this.c = c;
    this.d = d;
Debug(0, DebugTag.DBG_MD5, TAG, String.format("end ctx.a: 0x%08x", a));
Debug(0, DebugTag.DBG_MD5, TAG, String.format("end ctx.b: 0x%08x", b));
Debug(0, DebugTag.DBG_MD5, TAG, String.format("end ctx.c: 0x%08x", c));
Debug(0, DebugTag.DBG_MD5, TAG, String.format("end ctx.d: 0x%08x", d));
    return ptr_idx;
  }


  /* =====================================================================
   * MD5Init
   * =====================================================================
................................................................................
    	ctx_buffer_idx = body(0, 64);
    }
    if (size >= 64) {
    	data_idx = body(data_idx, (size & ~0x3FL));
    	size &= 0x3f;
    }
    for (i = 0; i < size; i++) {
      Debug(0, DebugTag.DBG_MD5, TAG, String.format("ctx.buffer[i]: %d 0x%02x", i, this.buffer[i]));
    }
    for (i = 0; i < size; i++) {
      this.buffer[i] = data[data_idx++];
    }
    data_ref.Set(data);
  }

................................................................................
    result[10] = (byte)(this.c >> 16);
    result[11] = (byte)(this.c >> 24);
    result[12] = (byte)this.d;
    result[13] = (byte)(this.d >> 8);
    result[14] = (byte)(this.d >> 16);
    result[15] = (byte)(this.d >> 24);
for(int j = 0; j < 16; j++) {
  Debug(2, DebugTag.DBG_MD5, TAG, String.format("MD5 j: %d 0x%02x", j, result[j] & 0xFF));
}
  }

}

Changes to aftraster/grayTWorkerRec.java.

443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
...
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
      TCellRec cell = ycells[yindex];
      int cover = 0;
      int x = 0;

      for ( ; cell != null; cell = cell.getNext()) {
        int area;

//System.out.println(String.format("cell->next: %d", cell.next == null ? -1 : cell.next.self_idx));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_sweep 1: cell.x: %d x: %d,  yindex: %d, cover: %x", cell.getX(), x, yindex, cover));
        if (cell.getX() > x && cover != 0) {
          gray_hline(x, yindex, cover * (RasterUtil.ONE_PIXEL() * 2), cell.getX() - x );
        }
        cover += cell.getCover();
        area = cover * (RasterUtil.ONE_PIXEL() * 2) - cell.getArea();
        if (area != 0 && cell.getX() >= 0) {
................................................................................
    }
    if (max_ey > clip.getyMax()) {
      max_ey = clip.getyMax();
    }
    count_ex = max_ex - min_ex;
    count_ey = max_ey - min_ey;
      /* set up vertical bands */
    num_bands = (max_ey - min_ey / band_size);
    if (num_bands == 0) {
      num_bands = 1;
    }
    if (num_bands >= 39) {
      num_bands = 39;
    }
    band_shoot = 0;
    min = min_ey;
    max_y = max_ey;
    for (n = 0; n < num_bands; n++, min = max) {

      max = min + band_size;
      if (n == num_bands - 1 || max > max_y) {
        max = max_y;
      }
      bands[0].setMin(min);
      bands[0].setMax(max);
      bandIdx = 0;







|







 







|










>







443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
...
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
      TCellRec cell = ycells[yindex];
      int cover = 0;
      int x = 0;

      for ( ; cell != null; cell = cell.getNext()) {
        int area;

Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cell->next: %d", cell.getNext() == null ? -1 : cell.getNext().getSelf_idx()));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_sweep 1: cell.x: %d x: %d,  yindex: %d, cover: %x", cell.getX(), x, yindex, cover));
        if (cell.getX() > x && cover != 0) {
          gray_hline(x, yindex, cover * (RasterUtil.ONE_PIXEL() * 2), cell.getX() - x );
        }
        cover += cell.getCover();
        area = cover * (RasterUtil.ONE_PIXEL() * 2) - cell.getArea();
        if (area != 0 && cell.getX() >= 0) {
................................................................................
    }
    if (max_ey > clip.getyMax()) {
      max_ey = clip.getyMax();
    }
    count_ex = max_ex - min_ex;
    count_ey = max_ey - min_ey;
      /* set up vertical bands */
    num_bands = ((max_ey - min_ey) / band_size);
    if (num_bands == 0) {
      num_bands = 1;
    }
    if (num_bands >= 39) {
      num_bands = 39;
    }
    band_shoot = 0;
    min = min_ey;
    max_y = max_ey;
    for (n = 0; n < num_bands; n++, min = max) {
Debug(0, DebugTag.DBG_RENDER, TAG, "num_bands: n: "+n+" "+num_bands);
      max = min + band_size;
      if (n == num_bands - 1 || max > max_y) {
        max = max_y;
      }
      bands[0].setMin(min);
      bands[0].setMax(max);
      bandIdx = 0;

Changes to aftutil/FTDebug.java.

32
33
34
35
36
37
38
39



40
41
42
43
44
45
46
    DBG_CACHE(2, 0, true, "DBG_CACHE"),
    DBG_CMAP(3, 0, true, "DBG_CMAP"),
    DBG_INIT(4, 2, true, "DBG_INIT"),
    DBG_INTERP(5, 2, true, "DBG_INTERP"),
    DBG_LIBRARY(6, 0, true, "DBG_LIBRARY"),
    DBG_LOAD_FACE(7, 0, true, "DBG_LOAD_FACE"),
    DBG_LOAD_GLYPH(8, 2, true, "DBG_LOAD_GLYPH"),
    DBG_RENDER(9, 0, true, "DBG_RENDER");




    private int val;
    private int level;
    private boolean dbgIsOn;
    private String str;
    private static SparseArray<DebugTag> tagToDebugTagMapping;
    public static DebugTag getTableTag(int i) {







|
>
>
>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
    DBG_CACHE(2, 0, true, "DBG_CACHE"),
    DBG_CMAP(3, 0, true, "DBG_CMAP"),
    DBG_INIT(4, 2, true, "DBG_INIT"),
    DBG_INTERP(5, 2, true, "DBG_INTERP"),
    DBG_LIBRARY(6, 0, true, "DBG_LIBRARY"),
    DBG_LOAD_FACE(7, 0, true, "DBG_LOAD_FACE"),
    DBG_LOAD_GLYPH(8, 2, true, "DBG_LOAD_GLYPH"),
    DBG_RENDER(9, 0, true, "DBG_RENDER"),
    DBG_DECOMPOSE(10, 0, true, "DBG_DECOMPOSE"),
    DBG_SWEEP(11, 0, true, "DBG_SWEEP"),
    DBG_MD5(12, 2, true, "DBG_MD5");

    private int val;
    private int level;
    private boolean dbgIsOn;
    private String str;
    private static SparseArray<DebugTag> tagToDebugTagMapping;
    public static DebugTag getTableTag(int i) {