ApwFreetypeLibrary

Check-in [e9ca502532]
Login

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

Overview
Comment:initial version.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e9ca5025323eeb2f2cefc4bd24432959e7e939c0
User & Date: arnulf 2014-12-29 23:20:57
Context
2014-12-30
13:01
fixes and renaming. check-in: 325bb5cc57 user: arnulf tags: trunk
2014-12-29
23:20
initial version. check-in: e9ca502532 user: arnulf tags: trunk
23:20
initial version. check-in: 477dcc17ba user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added ftbase/FTGlyphLoaderFlags.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
/* =====================================================================
 *  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.de
 *
 *  See the file "license.terms" for information on usage and
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package ftbase;

  /* ===================================================================== */
  /*    FTGlyphLoaderFlags                                                   */
  /*                                                                       */
  /* ===================================================================== */

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

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

    public final static int FT_GLYPH_OWN_BITMAP = 0x1;

    public final static int ARGS_ARE_WORDS            = 0x0001;
    public final static int ARGS_ARE_XY_VALUES        = 0x0002;
    public final static int ROUND_XY_TO_GRID          = 0x0004;
    public final static int WE_HAVE_A_SCALE           = 0x0008;
                    /* reserved                       = 0x0010 */
    public final static int MORE_COMPONENTS           = 0x0020;
    public final static int WE_HAVE_AN_XY_SCALE       = 0x0040;
    public final static int WE_HAVE_A_2X2             = 0x0080;
    public final static int WE_HAVE_INSTR             = 0x0100;
    public final static int USE_MY_METRICS            = 0x0200;
    public final static int OVERLAP_COMPOUND          = 0x0400;
    public final static int SCALED_COMPONENT_OFFSET   = 0x0800;
    public final static int UNSCALED_COMPONENT_OFFSET = 0x1000;
   
    
    /* ==================== FTGlyphLoaderFlags ================================== */
    public FTGlyphLoaderFlags() {
      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();
    }

}

Added ftbase/TTLoaderRec.java.





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
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
476
477
478
479
480
481
482
/* =====================================================================
 *  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.de
 *
 *  See the file "license.terms" for information on usage and
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package ftbase;

import android.util.Log;
  /* ===================================================================== */
  /*    TTLoaderRec                                                          */
  /*                                                                       */
  /* ===================================================================== */

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

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

    public FTFaceRec face = null;
    public FTSizeRec size = null;
    public FTGlyphSlotRec glyph = null;
    public FTGlyphLoaderRec  gloader = null;
    public long load_flags = 0L;
    public int glyph_index = 0;
    public FTStreamRec stream = null;
    public int byte_len = 0;
    public short n_contours = 0;
    public FTBBoxRec bbox = null;
    public int left_bearing = 0;
    public int advance = 0;
    public int linear = 0;
    public boolean linear_def = false;
    public boolean preserve_pps = false;
    public FTVectorRec pp1 = null;
    public FTVectorRec pp2 = null;
    public long glyf_offset = 0L;
    /* the zone where we load our glyphs */
    public TTGlyphZoneRec base = null;
    public TTGlyphZoneRec zone = null;
    public TTExecContextRec exec;
    public byte[] instructions;
    public long ins_pos = 0L;
    /* for possible extensibility in other formats */
    public Object other;
    /* since version 2.1.8 */
    public int top_bearing = 0;
    public int vadvance = 0;
    public FTVectorRec pp3 = null;
    public FTVectorRec pp4 = null;
    /* since version 2.2.1 */
    public long cursor = 0;
    public long limit = 0;

    /* ==================== TTLoaderRec ================================== */
    public TTLoaderRec() {
      oid++;
      id = oid;
      bbox = new FTBBoxRec();
      pp1 = new FTVectorRec();
      pp2 = new FTVectorRec();
      pp3 = new FTVectorRec();
      pp4 = new FTVectorRec();
      base = new TTGlyphZoneRec("TTLoaderRec.base");
      zone = new TTGlyphZoneRec("TTLoaderRec.zone");
    }
    
    /* ==================== 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();
    }
 
    /* =====================================================================
     * tt_loader_init
     * =====================================================================
     */
    public static int tt_loader_init(FTReference<TTLoaderRec> loader_ref,
            FTReference<TTSizeRec> size_ref, FTReference<FTGlyphSlotRec> glyph_ref,
            long load_flags, boolean glyf_table_only) {
      FTGlyphSlotRec glyph = glyph_ref.Get();
      TTSizeRec size = size_ref.Get();
      TTLoaderRec loader = loader_ref.Get();
Debug(0, DBG_LOAD_GLYPH, TAG, "tt_loader_init");
      TTFaceRec face;
      boolean pedantic = (load_flags & FT_LOAD_PEDANTIC) != 0;

      face = (TTFaceRec)glyph.face;
      loader = new TTLoaderRec();
      /* load execution context */
      if ((load_flags & FT_LOAD_NO_HINTING) == 0 && !glyf_table_only) {
        TTExecContextRec exec;
        boolean grayscale;
        boolean reexecute = false;

Debug(0, DBG_LOAD_GLYPH, TAG, "fill TTSizeRec\n");
        if (!size.cvt_ready) {
          size_ref.Set(size);
          int error = TTSizeFuncs.tt_size_ready_bytecode(size_ref, pedantic);
          size = size_ref.Get();
          if (error != 0) {
            return error;
          }
        }
        /* query new execution context */
        exec = size.debug ? size.context
                           : ((TTDriverRec)face.driver).context;
        if (exec == null) {
          return FTError.GLYPH_COULD_NOT_FIND_CONTEXT;
        }
        grayscale = (((load_flags >> 16) & 15) != FTRendererRec.FT_RENDER_MODE_MONO);
        FTReference<TTExecContextRec> exec_ref = new FTReference<TTExecContextRec>();
        exec_ref.Set(exec);
        TTDriverRec.TTLoadContext(exec_ref, face, size);
        exec = exec_ref.Get();
        {
          /* a change from mono to grayscale rendering (and vice versa) */
          /* requires a re-execution of the CVT program                 */
          if (grayscale != exec.grayscale) {
            FTTrace.Trace(7, TAG, "tt_loader_init: grayscale change, re-executing `prep' table");
            exec.grayscale = grayscale;
            reexecute = true;
          }
        }
        if (reexecute) {
          int i;

          for (i = 0; i < size.cvt_size; i++) {
            size.cvt[i] = TTInterpInsFuncs1.FT_MulFix((long)face.cvt[i], size.ttmetrics.scale);
          }
          size_ref.Set(size);
          TTSizeFuncs.tt_size_run_prep(size_ref, pedantic);
          size = size_ref.Get();
        }
        /* see whether the cvt program has disabled hinting */
        if ((exec.GS.instruct_control & 1) != 0) {
          load_flags |= FT_LOAD_NO_HINTING;
        }
        /* load default graphics state -- if needed */
        if ((exec.GS.instruct_control & 2) != 0) {
          exec.GS = new TTDefaultGraphicsStateClass();
        }
        exec.pedantic_hinting = (load_flags & FT_LOAD_PEDANTIC) != 0;
        loader.exec = exec;
        loader.instructions = exec.glyphIns;
      }
      /* seek to the beginning of the glyph table -- for Type 42 fonts     */
      /* the table might be accessed from a Postscript stream or something */
      /* else...                                                           */
      {
        FTReference<Long> length_ref = new FTReference<Long>();
        length_ref.Set(new Long(0));
        int error = (int)face.goto_table.callClassMethod(face, TTSfntLoad.TTAG_glyf, face.stream, length_ref);

        if (error == FTError.GLYPH_TABLE_MISSING) {
          loader.glyf_offset = 0L;
        } else {
          if (error != 0) {
            Log.e(TAG, "tt_loader_init: could not access glyph table");
            return error;
          } else {
            loader.glyf_offset = face.stream.pos();
          }
        }
      }
      /* get face's glyph loader */
      if (!glyf_table_only) {
        FTReference<FTGlyphLoaderRec> gloader_ref = new FTReference<FTGlyphLoaderRec>(); 
        gloader_ref.Set(glyph.internal.loader);
        TTDriverRec.FTGlyphLoaderRewind(gloader_ref);
        glyph.internal.loader = gloader_ref.Get();
        loader.gloader = glyph.internal.loader;
      }
      loader.load_flags = load_flags;
      loader.face = (FTFaceRec)face;
      loader.size = (FTSizeRec)size;
      loader.glyph = (FTGlyphSlotRec)glyph;
      loader.stream = face.stream;
      size_ref.Set(size);
      loader_ref.Set(loader);
      return FTError.INTERP_ERR_OK;
    }

    /* =====================================================================
     * load_truetype_glyph
     *
     * <Description>
     *    Loads a given truetype glyph.  Handles composites and uses a
     *    TT_Loader object.
     *
     * =====================================================================
     */
    public static int load_truetype_glyph(FTReference<TTLoaderRec> loader_ref,
            int glyph_index, int recurse_count, boolean header_only) {
Debug(0, DBG_LOAD_GLYPH, TAG, "load_truetype_glyph index: "+glyph_index+"!");
      int error = 0;
      long x_scale;
      long y_scale;
      long offset;
      TTLoaderRec loader = loader_ref.Get();
      TTFaceRec face = (TTFaceRec)loader.face;
      FTGlyphLoaderRec gloader = loader.gloader;
      boolean opened_frame = false;

      /* some fonts have an incorrect value of `maxComponentDepth', */
      /* thus we allow depth 1 to catch the majority of them        */
      if (recurse_count > 1 && recurse_count > face.max_profile.maxComponentDepth) {
        error = FTError.GLYPH_INVALID_COMPOSITE;
        if (opened_frame) {
          face.forget_glyph_frame.callClassMethod(loader);
        }
        return error;
      }
      /* check glyph index */
      if (glyph_index >= face.num_glyphs) {
        error = FTError.GLYPH_INVALID_GLYPH_INDEX;
        if (opened_frame) {
          face.forget_glyph_frame.callClassMethod(loader);
        }
        return error;
      }
      loader.glyph_index = glyph_index;
      if ((loader.load_flags & FT_LOAD_NO_SCALE) == 0) {
        x_scale = ((TTSizeRec)loader.size).metrics.x_scale;
        y_scale = ((TTSizeRec)loader.size).metrics.y_scale;
      } else {
        x_scale = 0x10000L;
        y_scale = 0x10000L;
      }
      TTSizeFuncs.tt_get_metrics(loader, glyph_index);
      /* Set `offset' to the start of the glyph relative to the start of */
      /* the `glyf' table, and `byte_len' to the length of the glyph in  */
      /* bytes.                                                          */
      FTReference<Integer> byte_len_ref = new FTReference<Integer>();
      byte_len_ref.Set(loader.byte_len);
      offset = TTLoad.tt_face_get_location(face, glyph_index, byte_len_ref);
      loader.byte_len = byte_len_ref.Get();
      if (loader.byte_len > 0) {
        if (loader.glyf_offset == 0) {
          FTTrace.Trace(7, TAG, "no `glyf' table but non-zero `loca' entry");
          error = FTError.GLYPH_INVALID_TABLE;
          if (opened_frame) {
            face.forget_glyph_frame.callClassMethod(loader);
          }
          return error;
        }
        error = (int)face.access_glyph_frame.callClassMethod(loader, glyph_index, loader.glyf_offset + offset,
              loader.byte_len);
        if (error != 0) {
          if (opened_frame) {
            face.forget_glyph_frame.callClassMethod(loader);
          }
          return error;
        }
        opened_frame = true;
        /* read glyph header first */
        error = (int)face.read_glyph_header.callClassMethod(loader);
        if (error != 0 || header_only) {
          if (opened_frame) {
            face.forget_glyph_frame.callClassMethod(loader);
          }
          return error;
        }
      }
Debug(0, DBG_LOAD_GLYPH, TAG, "loader.n_contours: "+loader.n_contours+"!loader.byty_len: "+loader.byte_len+"!header_only: "+header_only);
      if (loader.byte_len == 0 || loader.n_contours == 0) {
        loader.bbox.xMin = 0L;
        loader.bbox.xMax = 0L;
        loader.bbox.yMin = 0L;
        loader.bbox.yMax = 0L;
        if (header_only) {
          if (opened_frame) {
            face.forget_glyph_frame.callClassMethod(loader);
          }
          return error;
        }
        /* must initialize points before (possibly) overriding */
        /* glyph metrics from the incremental interface        */

Debug(0, DBG_LOAD_GLYPH, TAG, String.format("loader_set_pp1: loader.bbox.xMin: %d, loader.bbox.yMax: %d, loader.left_bearing: %d, loader.top_bearing: %d, loader.vadvance: %d\n", loader.bbox.xMin, loader.bbox.yMax, loader.left_bearing, loader.top_bearing, loader.vadvance));
        /* Calculate the four phantom points.                     */
        /* The first two stand for horizontal origin and advance. */
        /* The last two stand for vertical origin and advance.    */
        loader.pp1.x = loader.bbox.xMin - loader.left_bearing;
        loader.pp1.y = 0L;
        loader.pp2.x = loader.pp1.x + loader.advance;
        loader.pp2.y = 0L;
        loader.pp3.x = 0L;
        loader.pp3.y = loader.top_bearing + loader.bbox.yMax;
        loader.pp4.x = 0L;
        loader.pp4.y = loader.pp3.y - loader.vadvance;
Debug(0, DBG_LOAD_GLYPH, TAG, String.format("loader.pp1.x: %d %d %d %d %d", loader.pp1.x, loader.pp2.x, loader.pp3.y, loader.pp4.y, (loader.load_flags & FTGlyphLoaderFlags.FT_LOAD_NO_SCALE)));
        if ((loader.load_flags & FT_LOAD_NO_SCALE) == 0) {
          loader.pp1.x = TTInterpInsFuncs1.FT_MulFix(loader.pp1.x, x_scale);
          loader.pp2.x = TTInterpInsFuncs1.FT_MulFix(loader.pp2.x, x_scale);
          loader.pp3.y = TTInterpInsFuncs1.FT_MulFix(loader.pp3.y, y_scale);
          loader.pp4.y = TTInterpInsFuncs1.FT_MulFix(loader.pp4.y, y_scale);
        }
        error = FTError.INTERP_ERR_OK;
        if (opened_frame) {
          face.forget_glyph_frame.callClassMethod(loader);
        }
        return error;
      }
      /* must initialize points before (possibly) overriding */
      /* glyph metrics from the incremental interface        */

Debug(0, DBG_LOAD_GLYPH, TAG, String.format("loader_set_pp2: loader.bbox.xMin: %d, loader.bbox.yMax: %d, loader.left_bearing: %d, loader.top_bearing: %d, loader.vadvance: %d\n", loader.bbox.xMin, loader.bbox.yMax, loader.left_bearing, loader.top_bearing, loader.vadvance));
      /* Calculate the four phantom points.                     */
      /* The first two stand for horizontal origin and advance. */
      /* The last two stand for vertical origin and advance.    */
      loader.pp1.x = loader.bbox.xMin - loader.left_bearing;
      loader.pp1.y = 0L;
      loader.pp2.x = loader.pp1.x + loader.advance;
      loader.pp2.y = 0L;
      loader.pp3.x = 0L;
      loader.pp3.y = loader.top_bearing + loader.bbox.yMax;
      loader.pp4.x = 0L;
      loader.pp4.y = loader.pp3.y - loader.vadvance;
Debug(0, DBG_LOAD_GLYPH, TAG, String.format("loader_set_pp3: loader.pp1.x: %d, loader.pp1.y: %d, loader.pp2.x: %d, loader.pp2.y: %d, loader.pp3.x: %d, loader.pp3.y: %d, loader.pp4.x: %d, loader.pp4.y: %d\n", loader.pp1.x, loader.pp1.y, loader.pp2.x, loader.pp2.y, loader.pp3.x, loader.pp3.y, loader.pp4.x, loader.pp4.y));
      /***********************************************************************/
      /***********************************************************************/
      /***********************************************************************/
      /* if it is a simple glyph, load it */
      if (loader.n_contours > 0) {
        error = (int)face.read_simple_glyph.callClassMethod(loader);
        if (error != 0) {
          if (opened_frame) {
            face.forget_glyph_frame.callClassMethod(loader);
          }
          return error;
        }
        /* all data have been read */
        face.forget_glyph_frame.callClassMethod(loader);
        opened_frame = false;
        error = TTGlyphLoaderFuncs.TTProcessSimpleGlyph(loader);
        if (error != 0) {
          if (opened_frame) {
            face.forget_glyph_frame.callClassMethod(loader);
          }
          return error;
        }
        FTGlyphLoaderRec.FTGlyphLoaderAdd(gloader);
      } else { 
      /* otherwise, load a composite! */
        if (loader.n_contours == -1) {
          int   start_point;
          int   start_contour;
          long  ins_pos;  /* position of composite instructions, if any */

          start_point = gloader.base.outline.n_points;
          start_contour = gloader.base.outline.n_contours;
          /* for each subglyph, read composite header */
          error = (int)face.read_composite_glyph.callClassMethod(loader);
          if (error != 0) {
            if (opened_frame) {
              face.forget_glyph_frame.callClassMethod(loader);
            }
            return error;
          }
          /* store the offset of instructions */
          ins_pos = loader.ins_pos;
          /* all data we need are read */
          face.forget_glyph_frame.callClassMethod(loader);
          opened_frame = false;
Debug(0, DBG_LOAD_GLYPH, TAG, String.format("loader_set_pp4: loader.pp1.x: %d, loader.pp1.y: %d, loader.pp2.x: %d, loader.pp2.y: %d, loader.pp3.x: %d, loader.pp3.y: %d, loader.pp4.x: %d, loader.pp4.y: %d\n", loader.pp1.x, loader.pp1.y, loader.pp2.x, loader.pp2.y, loader.pp3.x, loader.pp3.y, loader.pp4.x, loader.pp4.y));
Debug(0, DBG_LOAD_GLYPH, TAG, String.format("LOAD_NO_SCALE: %d", (loader.load_flags & FT_LOAD_NO_SCALE)));
          if ((loader.load_flags & FT_LOAD_NO_SCALE) == 0) {
            loader.pp1.x = TTInterpInsFuncs1.FT_MulFix(loader.pp1.x, x_scale);
            loader.pp2.x = TTInterpInsFuncs1.FT_MulFix(loader.pp2.x, x_scale);
            loader.pp3.y = TTInterpInsFuncs1.FT_MulFix(loader.pp3.y, y_scale);
            loader.pp4.y = TTInterpInsFuncs1.FT_MulFix(loader.pp4.y, y_scale);
          }
Debug(0, DBG_LOAD_GLYPH, TAG, String.format("loader_set_pp5: loader.pp1.x: %d, loader.pp1.y: %d, loader.pp2.x: %d, loader.pp2.y: %d, loader.pp3.x: %d, loader.pp3.y: %d, loader.pp4.x: %d, loader.pp4.y: %d\n", loader.pp1.x, loader.pp1.y, loader.pp2.x, loader.pp2.y, loader.pp3.x, loader.pp3.y, loader.pp4.x, loader.pp4.y));
          /* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
          /* `as is' in the glyph slot (the client application will be     */
          /* responsible for interpreting these data)...                   */
          if ((loader.load_flags & FT_LOAD_NO_RECURSE) != 0) {
            FTGlyphLoaderRec.FTGlyphLoaderAdd(gloader);
            loader.glyph.format = FT_GLYPH_FORMAT_COMPOSITE;
            if (opened_frame) {
              face.forget_glyph_frame.callClassMethod(loader);
            }
            return error;
          }
          /*********************************************************************/
          /*********************************************************************/
          /*********************************************************************/
          {
            int n;
            int num_base_points;
            FTSubGlyphRec subglyph = null;
            int num_points = start_point;
            int num_subglyphs = gloader.current.num_subglyphs;
            int num_base_subgs = gloader.base.num_subglyphs;
            FTStreamRec old_stream = loader.stream;
            int old_byte_len = loader.byte_len;
  
            FTGlyphLoaderRec.FTGlyphLoaderAdd(gloader);
            /* read each subglyph independently */
            for (n = 0; n < num_subglyphs; n++) {
              FTVectorRec[] pp = new FTVectorRec[4];
  
              /* Each time we call load_truetype_glyph in this loop, the   */
              /* value of `gloader.base.subglyphs' can change due to table */
              /* reallocations.  We thus need to recompute the subglyph    */
              /* pointer on each iteration.                                */
              subglyph = gloader.base.subglyphs[num_base_subgs + n];
              pp[0] = loader.pp1;
              pp[1] = loader.pp2;
              pp[2] = loader.pp3;
              pp[3] = loader.pp4;
              num_base_points = gloader.base.outline.n_points;
              loader_ref.Set(loader);
              error = load_truetype_glyph(loader_ref, subglyph.index, recurse_count + 1, false);
              loader = loader_ref.Get();
              if (error != 0) {
                if (opened_frame) {
                  face.forget_glyph_frame.callClassMethod(loader);
                }
                return error;
              }
              /* restore subglyph pointer */
              subglyph = gloader.base.subglyphs[num_base_subgs + n];
              if ((subglyph.flags & FTSubGlyphRec.FT_SUBGLYPH_FLAG_USE_MY_METRICS) != 0) {
                loader.pp1 = pp[0];
                loader.pp2 = pp[1];
                loader.pp3 = pp[2];
                loader.pp4 = pp[3];
              }
              num_points = gloader.base.outline.n_points;
              if (num_points == num_base_points) {
                continue;
              } 
              /* gloader.base.outline consists of three parts:               */
              /* 0 -(1). start_point -(2). num_base_points -(3). n_points. */
              /*                                                              */
              /* (1): exists from the beginning                               */
              /* (2): components that have been loaded so far                 */
              /* (3): the newly loaded component                              */
              TTGlyphLoaderFuncs.TTProcessCompositeComponent(loader, subglyph, start_point,
                      num_base_points);
            }
            loader.stream = old_stream;
            loader.byte_len = old_byte_len;
            /* process the glyph */
            loader.ins_pos = ins_pos;
            if (((loader.load_flags & FT_LOAD_NO_HINTING) != 0) &&
                    ((subglyph.flags & FTGlyphLoaderFlags.WE_HAVE_INSTR) != 0) && (num_points > start_point)) {
              TTGlyphLoaderFuncs.TTProcessCompositeGlyph(loader, start_point, start_contour);
            } 
          }
        } else {
        /* invalid composite count (negative but not -1) */
        error = FTError.GLYPH_INVALID_OUTLINE;
        }
      }
      if (opened_frame) {
        face.forget_glyph_frame.callClassMethod(loader);
      }
      return error;
    }

}