apwfreetypelib

Check-in [1c81d958fa]
Login

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

Overview
Comment:fixes, code moving and changes.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1c81d958fac1f3753f01d74131589159e1784ac9
User & Date: arnulf 2015-02-01 12:45:34
Context
2015-02-01
19:57
fixes and made Set of enums for Curve flags and Load flags. check-in: 4b013f08ed user: arnulf tags: trunk
12:45
fixes, code moving and changes. check-in: 1c81d958fa user: arnulf tags: trunk
2015-01-31
21:35
fixes. check-in: 41fd1a1418 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to aftbase/FTGlyphLoaderRec.java.

11
12
13
14
15
16
17




18
19
20
21
22
23
24
...
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftbase;

import android.util.Log;





import org.apwtcl.apwfreetypelib.aftutil.*;

  /* ===================================================================== */
  /*    FTGlyphLoaderRec                                                   */
  /*                                                                       */
  /* ===================================================================== */

................................................................................
//          return error;
//        }
      max_subglyphs = new_max;
      GlyphLoaderAdjustSubglyphs();
    }
    return error;
  }

  /* ==================== getMax_points ================================== */
  public int getMax_points() {
    return max_points;
  }

  /* ==================== setMax_points ================================== */
  public void setMax_points(int max_points) {







>
>
>
>







 







<







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
472
473
474
475
476
477
478

479
480
481
482
483
484
485
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftbase;

import android.util.Log;

import org.apwtcl.apwfreetypelib.afttruetype.TTFaceRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTLoaderRec;
import org.apwtcl.apwfreetypelib.afttruetype.TTSizeRec;
import org.apwtcl.apwfreetypelib.aftttinterpreter.TTOpCode;
import org.apwtcl.apwfreetypelib.aftutil.*;

  /* ===================================================================== */
  /*    FTGlyphLoaderRec                                                   */
  /*                                                                       */
  /* ===================================================================== */

................................................................................
//          return error;
//        }
      max_subglyphs = new_max;
      GlyphLoaderAdjustSubglyphs();
    }
    return error;
  }

  /* ==================== getMax_points ================================== */
  public int getMax_points() {
    return max_points;
  }

  /* ==================== setMax_points ================================== */
  public void setMax_points(int max_points) {

Deleted afttruetype/TTGlyphLoaderFuncs.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
/* =====================================================================
 *  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.afttruetype;

  /* ===================================================================== */
  /*    TTGlyphLoaderFuncs                                                 */
  /*                                                                       */
  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftbase.FTGlyphClassRec;
import org.apwtcl.apwfreetypelib.aftbase.FTGlyphLoaderFuncs;
import org.apwtcl.apwfreetypelib.aftbase.FTGlyphLoaderRec;
import org.apwtcl.apwfreetypelib.aftbase.FTGlyphSlotRec;
import org.apwtcl.apwfreetypelib.aftbase.FTOutlineRec;
import org.apwtcl.apwfreetypelib.aftbase.FTSubGlyphRec;
import org.apwtcl.apwfreetypelib.aftbase.FTTags;
import org.apwtcl.apwfreetypelib.aftbase.Flags;
import org.apwtcl.apwfreetypelib.aftttinterpreter.TTExecContextRec;
import org.apwtcl.apwfreetypelib.aftttinterpreter.TTInterpTags;
import org.apwtcl.apwfreetypelib.aftttinterpreter.TTOpCode;
import org.apwtcl.apwfreetypelib.aftutil.FTCalc;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTMatrixRec;
import org.apwtcl.apwfreetypelib.aftutil.FTReference;
import org.apwtcl.apwfreetypelib.aftutil.FTTrace;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;
import org.apwtcl.apwfreetypelib.aftutil.TTUtil;

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

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

    public static TTLoaderRec loader = null;

    /* ==================== TTGlyphLoaderFuncs ================================== */
    public TTGlyphLoaderFuncs() {
      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();
    }
 
    /* =====================================================================
     *    TTProcessSimpleGlyph
     *
     * <Description>
     *    Once a simple glyph has been loaded, it needs to be processed.
     *    Usually, this means scaling and hinting through bytecode
     *    interpretation.
     *
     * =====================================================================
     */
    public static FTError.ErrorTag TTProcessSimpleGlyph(TTLoaderRec loader) {
      FTGlyphLoaderRec gloader = loader.getGloader();
      FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
      int n_points;

      n_points = gloader.getCurrent().getN_points();
      /* set phantom points */
      gloader.getCurrent().setPoint(n_points, loader.getPp1());
      gloader.getCurrent().setPoint(n_points + 1, loader.getPp2());
      gloader.getCurrent().setPoint(n_points + 2, loader.getPp3());
      gloader.getCurrent().setPoint(n_points + 3, loader.getPp4());
      gloader.getCurrent().setTag(n_points, Flags.Curve.CONIC);
      gloader.getCurrent().setTag(n_points + 1, Flags.Curve.CONIC);
      gloader.getCurrent().setTag(n_points + 2, Flags.Curve.CONIC);
      gloader.getCurrent().setTag(n_points + 3, Flags.Curve.CONIC);
      n_points += 4;
      if ((loader.getLoad_flags().getVal() & Flags.Load.NO_HINTING.getVal()) == 0) {
        loader.getZone().tt_prepare_zone(gloader.getCurrent(), 0, 0);
        for (int i = 0; i < (loader.getZone().getN_points() + 4); i++) {
          loader.getZone().setOrusPoint(i, new FTVectorRec());
          loader.getZone().setOrusPoint_x(i, loader.getZone().getCurPoint_x(i));
          loader.getZone().setOrusPoint_y(i, loader.getZone().getCurPoint_y(i));
        }
      }
      {
        int vecIdx = 0;
        int limit = n_points;
        int x_scale = 0; /* pacify compiler */
        int y_scale = 0;
        boolean do_scale = false;
        {
          /* scale the glyph */
          if ((loader.getLoad_flags().getVal() & Flags.Load.NO_SCALE.getVal()) == 0) {
            x_scale = (loader.getSize()).getMetrics().getX_scale();
            y_scale = (loader.getSize()).getMetrics().getY_scale();
            do_scale = true;
          }
        }
        if (do_scale) {
          for (vecIdx = 0; vecIdx < limit; vecIdx++) {
            gloader.getCurrent().setPoint_x(vecIdx, TTUtil.FTMulFix(gloader.getCurrent().getPoint_x(vecIdx), x_scale));
            gloader.getCurrent().setPoint_y(vecIdx, TTUtil.FTMulFix(gloader.getCurrent().getPoint_y(vecIdx), y_scale));
          }
          loader.setPp1(gloader.getCurrent().getPoints()[n_points - 4]);
          loader.setPp2(gloader.getCurrent().getPoints()[n_points - 3]);
          loader.setPp3(gloader.getCurrent().getPoints()[n_points - 2]);
          loader.setPp4(gloader.getCurrent().getPoints()[n_points - 1]);
        }
      }
      if ((loader.getLoad_flags().getVal() & Flags.Load.NO_HINTING.getVal()) == 0) {
        loader.getZone().setN_points(loader.getZone().getN_points() + 4);
        error = loader.HintGlyph(false);
      }
      return error;
    }

    /* =====================================================================
     *    TTProcessCompositeComponent
     *
     * <Description>
     *    Once a composite component has been loaded, it needs to be
     *    processed.  Usually, this means transforming and translating.
     *
     * =====================================================================
     */
    public static FTError.ErrorTag TTProcessCompositeComponent(TTLoaderRec loader,
          FTSubGlyphRec subglyph, int start_point, int num_base_points) {
      FTGlyphLoaderRec gloader = loader.getGloader();
//      FT_Vector* base_vec = gloader.base.outline.points;
      int num_points = gloader.getBase().getN_points();
      boolean have_scale;
      int x;
      int y;

      have_scale = ((subglyph.getFlags().getVal() & (Flags.LoadType.WE_HAVE_A_SCALE.getVal() |
          Flags.LoadType.WE_HAVE_AN_XY_SCALE.getVal() | Flags.LoadType.WE_HAVE_A_2X2.getVal())) != 0);
      /* perform the transform required for this subglyph */
      if (have_scale) {
        int i;
        FTReference<FTMatrixRec> matrix_ref = new FTReference<FTMatrixRec>();
        FTReference<FTVectorRec> vec_ref = new FTReference<FTVectorRec>();

        for (i = num_base_points; i < num_points; i++) {
//FIXME!!!
//          FTOutlineRec.FTVectorTransform(gloader.getBase().getPoints()[i], subglyph.transform);
        }
      }
      /* get offset */
      if ((subglyph.getFlags().getVal() & Flags.LoadType.ARGS_ARE_XY_VALUES.getVal()) == 0) {
        int k = subglyph.getArg1();
        int l = subglyph.getArg2();

        /* match l-th point of the newly loaded component to the k-th point */
        /* of the previously loaded components.                             */
        /* change to the point numbers used by our outline */
        k += start_point;
        l += num_base_points;
        if (k >= num_base_points || l >= num_points) {
          return FTError.ErrorTag.GLYPH_INVALID_COMPOSITE;
        }
        x = gloader.getBase().getPoints()[k].getX() - gloader.getBase().getPoints()[l].getX();
        y = gloader.getBase().getPoints()[k].getY() - gloader.getBase().getPoints()[l].getY();
      } else {
        x = subglyph.getArg1();
        y = subglyph.getArg2();
        if (x == 0 && y == 0) {
          return FTError.ErrorTag.ERR_OK;
        }
        /* Use a default value dependent on                                     */
        /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED.  This is useful for old TT */
        /* fonts which don't set the xxx_COMPONENT_OFFSET bit.                  */
        if (have_scale && (subglyph.getFlags().getVal() & Flags.LoadType.SCALED_COMPONENT_OFFSET.getVal()) != 0) {
          /*************************************************************************/
          /*                                                                       */
          /* This algorithm is a guess and works much better than the above.       */
          /*                                                                       */
          int mac_xscale = FTCalc.FTHypot(subglyph.getTransform().getXx(), subglyph.getTransform().getXy());
          int mac_yscale = FTCalc.FTHypot(subglyph.getTransform().getYy(), subglyph.getTransform().getYx());
          x = TTUtil.FTMulFix(x, mac_xscale);
          y = TTUtil.FTMulFix(y, mac_yscale);
        }
        if ((loader.getLoad_flags().getVal() & Flags.Load.NO_SCALE.getVal()) == 0) {
          int x_scale = ((TTSizeRec)loader.getSize()).getMetrics().getX_scale();
          int y_scale = ((TTSizeRec)loader.getSize()).getMetrics().getY_scale();
          x = TTUtil.FTMulFix(x, x_scale);
          y = TTUtil.FTMulFix(y, y_scale);
          if ((subglyph.getFlags().getVal() & Flags.LoadType.ROUND_XY_TO_GRID.getVal()) != 0) {
            x = FTCalc.FT_PIX_ROUND(x);
            y = FTCalc.FT_PIX_ROUND(y);
          }
        }
      }
      if (x != 0 || y != 0) {
        gloader.translate_array(num_points - num_base_points, gloader.getBase().getPoints(), num_base_points, x, y);
      }
      return FTError.ErrorTag.ERR_OK;
    }

    /* =====================================================================
     *    TTProcessCompositeGlyph
     *
     * <Description>
     *    This is slightly different from TTProcessSimpleGlyph, in that
     *    its sole purpose is to hint the glyph.  Thus this function is
     *    only available when bytecode interpreter is enabled.
     *
     * =====================================================================
     */
    public static FTError.ErrorTag TTProcessCompositeGlyph(TTLoaderRec loader,
            int start_point, int start_contour) {
      FTError.ErrorTag error;
      int i;

      /* make room for phantom points */
      error = loader.getGloader().FT_GLYPHLOADER_CHECK_POINTS(loader.getGloader().getBase().getN_points() + 4, 0);
      if (error != FTError.ErrorTag.ERR_OK) {
        return error;
      }
      loader.getGloader().getBase().getPoints()[loader.getGloader().getBase().getN_points()] = loader.getPp1();
      loader.getGloader().getBase().getPoints()[loader.getGloader().getBase().getN_points() + 1] = loader.getPp2();
      loader.getGloader().getBase().getPoints()[loader.getGloader().getBase().getN_points() + 2] = loader.getPp3();
      loader.getGloader().getBase().getPoints()[loader.getGloader().getBase().getN_points() + 3] = loader.getPp4();
      loader.getGloader().getBase().getTags()[loader.getGloader().getBase().getN_points()] = Flags.Curve.CONIC;
      loader.getGloader().getBase().getTags()[loader.getGloader().getBase().getN_points() + 1] = Flags.Curve.CONIC;
      loader.getGloader().getBase().getTags()[loader.getGloader().getBase().getN_points() + 2] = Flags.Curve.CONIC;
      loader.getGloader().getBase().getTags()[loader.getGloader().getBase().getN_points() + 3] = Flags.Curve.CONIC;
      {
        int n_ins;
        int max_ins;

        /* TT_Load_Composite_Glyph only gives us the offset of instructions */
        /* so we read them here                                             */
        long pos = loader.getStream().seek(loader.getIns_pos());
        n_ins = loader.getStream().readShort();
        if (pos < 0 /* || FT_READ_USHORT(n_ins) */ ) {
          return FTError.ErrorTag.UNEXPECTED_NULL_VALUE;
        }
        FTTrace.Trace(7, TAG, String.format("  Instructions size = %d", n_ins));
        /* check it */
        max_ins = ((TTFaceRec)loader.getFace()).getMax_profile().getMaxSizeOfInstructions();
        if (n_ins > max_ins) {
          /* acroread ignores this field, so we only do a rough safety check */
          if ((int)n_ins > loader.getByte_len()) {
            FTTrace.Trace(7, TAG, String.format("TT_Process_Composite_Glyph: "+
                "too many instructions (%d) for glyph with length %d",
                n_ins, loader.getByte_len()));
            error = FTError.ErrorTag.GLYPH_TOO_MANY_HINTS;
            return error;
          }
          /*
          tmp = loader.exec.glyphSize;
          error = Update_Max(loader.exec.memory, &tmp, sizeof ( FT_Byte ), (void*)&loader.exec.glyphIns, n_ins );
          loader.exec.glyphSize = (short)tmp;
          */
          loader.getExec().glyphSize = n_ins;
          loader.getExec().glyphIns = new TTOpCode.OpCode [n_ins];
          if (error != FTError.ErrorTag.ERR_OK) {
            return error;
          }
        } else {
          if (n_ins == 0) {
            return FTError.ErrorTag.ERR_OK;
          }
        }
// FIXME!!
        byte[] my_array = new byte[n_ins];
        loader.getStream().readByteArray(my_array, n_ins);
        for(i = 0; i < n_ins; i++) {
          loader.getExec().glyphIns[i] = TTOpCode.OpCode.getTableTag(my_array[i]);
        }
//        if (FT_STREAM_READ(loader.exec.glyphIns, n_ins)) {
//          return error;
//        }
        loader.getGlyph().setControl_data(loader.getExec().glyphIns);
        loader.getGlyph().setControl_len(n_ins);
      }
      loader.getZone().tt_prepare_zone(loader.getGloader().getBase(), start_point, start_contour);
      /* Some points are likely touched during execution of  */
      /* instructions on components.  So let's untouch them. */
      for (i = start_point; i < loader.getZone().getN_points(); i++) {
        loader.getZone().getTags()[i] = Flags.Curve.getTableTag(loader.getZone().getTags()[i].getVal() & ~Flags.Curve.TOUCH_BOTH.getVal());
      }
      loader.getZone().setN_points(loader.getZone().getN_points() + 4);
      return loader.HintGlyph(true);
    }

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






































































































































































































































































































































































































































































































































































































































Changes to afttruetype/TTGlyphZoneRec.java.

583
584
585
586
587
588
589





590
591
592
593
594
595
596
    return tags[tags_idx + tag_idx];
  }

  /* ==================== setTags ================================== */
  public void setTags(Flags.Curve[] tags) {
    this.tags = tags;
  }






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

  /* ==================== setTags_idx ================================== */







>
>
>
>
>







583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
    return tags[tags_idx + tag_idx];
  }

  /* ==================== setTags ================================== */
  public void setTags(Flags.Curve[] tags) {
    this.tags = tags;
  }

  /* ==================== setTags ================================== */
  public void setTag(int tag_idx, Flags.Curve tag) {
    this.tags[tags_idx + tag_idx] = tag;
  }

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

  /* ==================== setTags_idx ================================== */

Changes to afttruetype/TTLoaderRec.java.

402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
...
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
...
735
736
737
738
739
740
741







































































































































































































































742
743
744
745
746
747
748
          ttface.forgetGlyphFrame(this);
        }
        return error;
      }
      /* all data have been read */
      ttface.forgetGlyphFrame(this);
      opened_frame = false;
      error = TTGlyphLoaderFuncs.TTProcessSimpleGlyph(this);
      if (error != FTError.ErrorTag.ERR_OK) {
        if (opened_frame) {
          ttface.forgetGlyphFrame(this);
        }
        return error;
      }
      gloader.GlyphLoaderAdd();
................................................................................
            } 
            /* 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(this, subglyph, start_point,
                    num_base_points);
          }
          stream = old_stream;
          byte_len = old_byte_len;
          /* process the glyph */
          this.ins_pos = ins_pos;
          if (((load_flags.getVal() & Flags.Load.NO_HINTING.getVal()) != 0) &&
                  ((subglyph.getFlags().getVal() & Flags.LoadType.WE_HAVE_INSTR.getVal()) != 0) && (num_points > start_point)) {
            TTGlyphLoaderFuncs.TTProcessCompositeGlyph(this, start_point, start_contour);
          } 
        }
      } else {
      /* invalid composite count (negative but not -1) */
      error = FTError.ErrorTag.GLYPH_INVALID_OUTLINE;
      }
    }
................................................................................
      pp2 = zone.getCurPoint(zone.getN_points() - 3);
      pp3 = zone.getCurPoint(zone.getN_points() - 2);
      pp4 = zone.getCurPoint(zone.getN_points() - 1);
    }
    return FTError.ErrorTag.ERR_OK;
  }








































































































































































































































  /* ==================== getFace ================================== */
  public FTFaceRec getFace() {
    return face;
  }

  /* ==================== setFace ================================== */
  public void setFace(FTFaceRec face) {







|







 







<
|







|







 







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







402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
...
505
506
507
508
509
510
511

512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
...
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
          ttface.forgetGlyphFrame(this);
        }
        return error;
      }
      /* all data have been read */
      ttface.forgetGlyphFrame(this);
      opened_frame = false;
      error = TTProcessSimpleGlyph();
      if (error != FTError.ErrorTag.ERR_OK) {
        if (opened_frame) {
          ttface.forgetGlyphFrame(this);
        }
        return error;
      }
      gloader.GlyphLoaderAdd();
................................................................................
            } 
            /* 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                              */

            TTProcessCompositeComponent(subglyph, start_point, num_base_points);
          }
          stream = old_stream;
          byte_len = old_byte_len;
          /* process the glyph */
          this.ins_pos = ins_pos;
          if (((load_flags.getVal() & Flags.Load.NO_HINTING.getVal()) != 0) &&
                  ((subglyph.getFlags().getVal() & Flags.LoadType.WE_HAVE_INSTR.getVal()) != 0) && (num_points > start_point)) {
            TTProcessCompositeGlyph(start_point, start_contour);
          } 
        }
      } else {
      /* invalid composite count (negative but not -1) */
      error = FTError.ErrorTag.GLYPH_INVALID_OUTLINE;
      }
    }
................................................................................
      pp2 = zone.getCurPoint(zone.getN_points() - 3);
      pp3 = zone.getCurPoint(zone.getN_points() - 2);
      pp4 = zone.getCurPoint(zone.getN_points() - 1);
    }
    return FTError.ErrorTag.ERR_OK;
  }


  /* =====================================================================
   *    TTProcessSimpleGlyph
   *
   * <Description>
   *    Once a simple glyph has been loaded, it needs to be processed.
   *    Usually, this means scaling and hinting through bytecode
   *    interpretation.
   *
   * =====================================================================
   */
  public FTError.ErrorTag TTProcessSimpleGlyph() {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    int n_points;

    n_points = gloader.getCurrent().getN_points();
      /* set phantom points */
    gloader.getCurrent().setPoint(n_points, pp1);
    gloader.getCurrent().setPoint(n_points + 1, pp2);
    gloader.getCurrent().setPoint(n_points + 2, pp3);
    gloader.getCurrent().setPoint(n_points + 3, pp4);
    gloader.getCurrent().setTag(n_points, Flags.Curve.CONIC);
    gloader.getCurrent().setTag(n_points + 1, Flags.Curve.CONIC);
    gloader.getCurrent().setTag(n_points + 2, Flags.Curve.CONIC);
    gloader.getCurrent().setTag(n_points + 3, Flags.Curve.CONIC);
    n_points += 4;
    if ((load_flags.getVal() & Flags.Load.NO_HINTING.getVal()) == 0) {
      zone.tt_prepare_zone(gloader.getCurrent(), 0, 0);
      for (int i = 0; i < (zone.getN_points() + 4); i++) {
        zone.setOrusPoint(i, new FTVectorRec());
        zone.setOrusPoint_x(i, zone.getCurPoint_x(i));
        zone.setOrusPoint_y(i, zone.getCurPoint_y(i));
      }
    }
    {
      int vecIdx = 0;
      int limit = n_points;
      int x_scale = 0; /* pacify compiler */
      int y_scale = 0;
      boolean do_scale = false;
      {
          /* scale the glyph */
        if ((load_flags.getVal() & Flags.Load.NO_SCALE.getVal()) == 0) {
          x_scale = size.getMetrics().getX_scale();
          y_scale = size.getMetrics().getY_scale();
          do_scale = true;
        }
      }
      if (do_scale) {
        for (vecIdx = 0; vecIdx < limit; vecIdx++) {
          gloader.getCurrent().setPoint_x(vecIdx, TTUtil.FTMulFix(gloader.getCurrent().getPoint_x(vecIdx), x_scale));
          gloader.getCurrent().setPoint_y(vecIdx, TTUtil.FTMulFix(gloader.getCurrent().getPoint_y(vecIdx), y_scale));
        }
        pp1 = gloader.getCurrent().getPoint(n_points - 4);
        pp2 = gloader.getCurrent().getPoint(n_points - 3);
        pp3 = gloader.getCurrent().getPoint(n_points - 2);
        pp4 = gloader.getCurrent().getPoint(n_points - 1);
      }
    }
    if ((load_flags.getVal() & Flags.Load.NO_HINTING.getVal()) == 0) {
      zone.setN_points(zone.getN_points() + 4);
      error = HintGlyph(false);
    }
    return error;
  }

  /* =====================================================================
   *    TTProcessCompositeComponent
   *
   * <Description>
   *    Once a composite component has been loaded, it needs to be
   *    processed.  Usually, this means transforming and translating.
   *
   * =====================================================================
   */
  public FTError.ErrorTag TTProcessCompositeComponent(FTSubGlyphRec subglyph, int start_point, int num_base_points) {
    int num_points = gloader.getBase().getN_points();
    boolean have_scale;
    int x;
    int y;

    have_scale = ((subglyph.getFlags().getVal() & (Flags.LoadType.WE_HAVE_A_SCALE.getVal() |
        Flags.LoadType.WE_HAVE_AN_XY_SCALE.getVal() | Flags.LoadType.WE_HAVE_A_2X2.getVal())) != 0);
      /* perform the transform required for this subglyph */
    if (have_scale) {
      int i;

      for (i = num_base_points; i < num_points; i++) {
//FIXME!!!
        Log.e(TAG, "SubGlyph FTVectorTransform not yet implemented!");
//          FTOutlineRec.FTVectorTransform(gloader.getBase().getPoints()[i], subglyph.transform);
      }
    }
      /* get offset */
    if ((subglyph.getFlags().getVal() & Flags.LoadType.ARGS_ARE_XY_VALUES.getVal()) == 0) {
      int k = subglyph.getArg1();
      int l = subglyph.getArg2();

        /* match l-th point of the newly loaded component to the k-th point */
        /* of the previously loaded components.                             */
        /* change to the point numbers used by our outline */
      k += start_point;
      l += num_base_points;
      if (k >= num_base_points || l >= num_points) {
        return FTError.ErrorTag.GLYPH_INVALID_COMPOSITE;
      }
      x = gloader.getBase().getPoint_x(k) - gloader.getBase().getPoint_x(l);
      y = gloader.getBase().getPoint_y(k) - gloader.getBase().getPoint_y(l);
    } else {
      x = subglyph.getArg1();
      y = subglyph.getArg2();
      if (x == 0 && y == 0) {
        return FTError.ErrorTag.ERR_OK;
      }
        /* Use a default value dependent on                                     */
        /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED.  This is useful for old TT */
        /* fonts which don't set the xxx_COMPONENT_OFFSET bit.                  */
      if (have_scale && (subglyph.getFlags().getVal() & Flags.LoadType.SCALED_COMPONENT_OFFSET.getVal()) != 0) {
        /*************************************************************************/
          /*                                                                       */
          /* This algorithm is a guess and works much better than the above.       */
          /*                                                                       */
        int mac_xscale = FTCalc.FTHypot(subglyph.getTransform().getXx(), subglyph.getTransform().getXy());
        int mac_yscale = FTCalc.FTHypot(subglyph.getTransform().getYy(), subglyph.getTransform().getYx());
        x = TTUtil.FTMulFix(x, mac_xscale);
        y = TTUtil.FTMulFix(y, mac_yscale);
      }
      if ((load_flags.getVal() & Flags.Load.NO_SCALE.getVal()) == 0) {
        int x_scale = size.getMetrics().getX_scale();
        int y_scale = size.getMetrics().getY_scale();
        x = TTUtil.FTMulFix(x, x_scale);
        y = TTUtil.FTMulFix(y, y_scale);
        if ((subglyph.getFlags().getVal() & Flags.LoadType.ROUND_XY_TO_GRID.getVal()) != 0) {
          x = FTCalc.FT_PIX_ROUND(x);
          y = FTCalc.FT_PIX_ROUND(y);
        }
      }
    }
    if (x != 0 || y != 0) {
      gloader.translate_array(num_points - num_base_points, gloader.getBase().getPoints(), num_base_points, x, y);
    }
    return FTError.ErrorTag.ERR_OK;
  }

  /* =====================================================================
   *    TTProcessCompositeGlyph
   *
   * <Description>
   *    This is slightly different from TTProcessSimpleGlyph, in that
   *    its sole purpose is to hint the glyph.  Thus this function is
   *    only available when bytecode interpreter is enabled.
   *
   * =====================================================================
   */
  public FTError.ErrorTag TTProcessCompositeGlyph(int start_point, int start_contour) {
    FTError.ErrorTag error;
    int i;

      /* make room for phantom points */
    error = gloader.FT_GLYPHLOADER_CHECK_POINTS(gloader.getBase().getN_points() + 4, 0);
    if (error != FTError.ErrorTag.ERR_OK) {
      return error;
    }
    gloader.getBase().setPoint(gloader.getBase().getN_points(),  pp1);
    gloader.getBase().setPoint(gloader.getBase().getN_points() + 1, pp2);
    gloader.getBase().setPoint(gloader.getBase().getN_points() + 2, pp3);
    gloader.getBase().setPoint(gloader.getBase().getN_points() + 3, pp4);
    gloader.getBase().setTag(gloader.getBase().getN_points(), Flags.Curve.CONIC);
    gloader.getBase().setTag(gloader.getBase().getN_points() + 1, Flags.Curve.CONIC);
    gloader.getBase().setTag(gloader.getBase().getN_points() + 2, Flags.Curve.CONIC);
    gloader.getBase().setTag(gloader.getBase().getN_points() + 3, Flags.Curve.CONIC);
    {
      int n_ins;
      int max_ins;

        /* TT_Load_Composite_Glyph only gives us the offset of instructions */
        /* so we read them here                                             */
      long pos = stream.seek(getIns_pos());
      n_ins = stream.readShort();
      if (pos < 0 /* || FT_READ_USHORT(n_ins) */ ) {
        return FTError.ErrorTag.UNEXPECTED_NULL_VALUE;
      }
      FTTrace.Trace(7, TAG, String.format("  Instructions size = %d", n_ins));
        /* check it */
      max_ins = ((TTFaceRec)getFace()).getMax_profile().getMaxSizeOfInstructions();
      if (n_ins > max_ins) {
          /* acroread ignores this field, so we only do a rough safety check */
        if (n_ins > byte_len) {
          FTTrace.Trace(7, TAG, String.format("TT_Process_Composite_Glyph: "+
                  "too many instructions (%d) for glyph with length %d",
              n_ins, byte_len));
          error = FTError.ErrorTag.GLYPH_TOO_MANY_HINTS;
          return error;
        }
          /*
          tmp = loader.exec.glyphSize;
          error = Update_Max(loader.exec.memory, &tmp, sizeof ( FT_Byte ), (void*)&loader.exec.glyphIns, n_ins );
          loader.exec.glyphSize = (short)tmp;
          */
        exec.glyphSize = n_ins;
        exec.glyphIns = new TTOpCode.OpCode [n_ins];
        if (error != FTError.ErrorTag.ERR_OK) {
          return error;
        }
      } else {
        if (n_ins == 0) {
          return FTError.ErrorTag.ERR_OK;
        }
      }
// FIXME!!
      byte[] my_array = new byte[n_ins];
      stream.readByteArray(my_array, n_ins);
      for(i = 0; i < n_ins; i++) {
        exec.glyphIns[i] = TTOpCode.OpCode.getTableTag(my_array[i]);
      }
//        if (FT_STREAM_READ(loader.exec.glyphIns, n_ins)) {
//          return error;
//        }
      glyph.setControl_data(exec.glyphIns);
      glyph.setControl_len(n_ins);
    }
    zone.tt_prepare_zone(gloader.getBase(), start_point, start_contour);
      /* Some points are likely touched during execution of  */
      /* instructions on components.  So let's untouch them. */
    for (i = start_point; i < zone.getN_points(); i++) {
      zone.setTag(i, Flags.Curve.getTableTag(zone.getTag(i).getVal() & ~Flags.Curve.TOUCH_BOTH.getVal()));
    }
    zone.setN_points(zone.getN_points() + 4);
    return HintGlyph(true);
  }

  /* ==================== getFace ================================== */
  public FTFaceRec getFace() {
    return face;
  }

  /* ==================== setFace ================================== */
  public void setFace(FTFaceRec face) {

Changes to aftttinterpreter/TTExecContextRec.java.

458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
...
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
507
508
509
510
511

512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
   *
   * <Return>
   *    FreeType error code.  0 means success.
   *
   * =====================================================================
   */
  public FTError.ErrorTag TTGotoCodeRange(TTInterpTags.CodeRange range, int IP) {
Debug(0, DebugTag.DBG_LOAD_GLYPH, TAG, "TTGotoCodeRange: "+range);
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    if (range.getVal() < TTInterpTags.CodeRange.FONT.getVal() || range.getVal() > TTInterpTags.CodeRange.GLYPH.getVal()) {
      error = FTError.ErrorTag.INTERP_INVALID_ARGUMENT;
      return error;
    }
    if (codeRangeTable[range.getVal() - 1].base == null) {
................................................................................
    if (IP > codeRangeTable[range.getVal() - 1].size) {
      error = FTError.ErrorTag.INTERP_INVALID_ARGUMENT;
      return error;
    }
    code = codeRangeTable[range.getVal() - 1].base;
    cvt_code = codeRangeTable[range.getVal() - 1].short_base;
    codeSize = codeRangeTable[range.getVal() - 1].size;
Debug(2, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("TTGotoCodeRange: size: %d", codeSize));
    this.IP = IP;
    curRange = range;
    return error;
  }

  /* ==================== funcRound ===================================== */
  protected int funcRound(int distance, int compensation) {     /* current rounding function */
    Log.e(TAG, "funcRound not yet implemented");
    return render_funcs.curr_round_func.round(distance, compensation);
  }

  /* ==================== funcProject ===================================== */
  protected int funcProject (int dx, int dy) {   /* current projection function */
    Log.e(TAG, "funcProject not yet fully implemented");
    return render_funcs.curr_project_func.project(dx, dy);
  }

  /* ==================== funcDualproj ===================================== */
  protected int funcDualproj(int dx, int dy) {  /* current dual proj. function */
    Log.e(TAG, "funcDualproj not yet fully implemented");
    return render_funcs.curr_project_func.dualproject(dx, dy);
  }

  /* ==================== funcFreeProj ===================================== */

  protected FTError.ErrorTag funcFreeProj() {  /* current freedom proj. func  */
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

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

  /* ==================== funcMove ===================================== */
  protected void funcMove(TTGlyphZoneRec zone, int point, int distance) {      /* current point move function */
    Log.e(TAG, "funcMove not yet implemented");
    render_funcs.curr_move_func.move(zone, point, distance);
  }

  /* ==================== funcMoveOrig ===================================== */
  protected void funcMoveOrig(TTGlyphZoneRec zone, int point, int distance) { /* move original position function */
    Log.e(TAG, "funcMoveOrig not yet fully implemented");
    render_funcs.curr_move_func.moveOrig(zone, point, distance);
  }

  /* ==================== funcReadCvt ===================================== */
  protected int funcReadCvt(int idx) {   /* read a cvt entry              */
    Log.e(TAG, "funcReadCvt not yet fully implemented");
    return render_funcs.curr_cvt_func.readCvt(idx);
  }

  /* ==================== funcWriteCvt ===================================== */
  protected void funcWriteCvt(int idx, int value) { /* write a cvt entry (in pixels) */
    Log.e(TAG, "funcWriteCvt not yet fully implemented");
    render_funcs.curr_cvt_func.writeCvt(idx, value);
  }

  /* ==================== funcMoveCvt ===================================== */
  protected FTError.ErrorTag funcMoveCvt(int val1, int val2) {  /* incr a cvt entry (in pixels)  */
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    Log.e(TAG, "funcMoveCvt not yet implemented");
    return render_funcs.curr_cvt_func.moveCvt(val1, val2);
  }

  public FTError.ErrorTag RunInstructions() {
    Log.e(TAG, "RunInstructions may not be called directly");
    return FTError.ErrorTag.UNEXPECTED_NULL_VALUE;
  }

}







|







 







|






|
|




|
|




|
|




>
|
|






|
|




|
|




|
|




|
|




|
|
<
<









458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
...
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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546


547
548
549
550
551
552
553
554
555
   *
   * <Return>
   *    FreeType error code.  0 means success.
   *
   * =====================================================================
   */
  public FTError.ErrorTag TTGotoCodeRange(TTInterpTags.CodeRange range, int IP) {
Debug(-1, DebugTag.DBG_LOAD_GLYPH, TAG, "TTGotoCodeRange: "+range);
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

    if (range.getVal() < TTInterpTags.CodeRange.FONT.getVal() || range.getVal() > TTInterpTags.CodeRange.GLYPH.getVal()) {
      error = FTError.ErrorTag.INTERP_INVALID_ARGUMENT;
      return error;
    }
    if (codeRangeTable[range.getVal() - 1].base == null) {
................................................................................
    if (IP > codeRangeTable[range.getVal() - 1].size) {
      error = FTError.ErrorTag.INTERP_INVALID_ARGUMENT;
      return error;
    }
    code = codeRangeTable[range.getVal() - 1].base;
    cvt_code = codeRangeTable[range.getVal() - 1].short_base;
    codeSize = codeRangeTable[range.getVal() - 1].size;
Debug(-1, DebugTag.DBG_LOAD_GLYPH, TAG, String.format("TTGotoCodeRange: size: %d", codeSize));
    this.IP = IP;
    curRange = range;
    return error;
  }

  /* ==================== funcRound ===================================== */
  /* current rounding function */
  protected int funcRound(int distance, int compensation) {
    return render_funcs.curr_round_func.round(distance, compensation);
  }

  /* ==================== funcProject ===================================== */
  /* current projection function */
  protected int funcProject (int dx, int dy) {
    return render_funcs.curr_project_func.project(dx, dy);
  }

  /* ==================== funcDualproj ===================================== */
  /* current dual proj. function */
  protected int funcDualproj(int dx, int dy) {
    return render_funcs.curr_project_func.dualproject(dx, dy);
  }

  /* ==================== funcFreeProj ===================================== */
  /* current freedom proj. func  */
  protected FTError.ErrorTag funcFreeProj() {
    FTError.ErrorTag error = FTError.ErrorTag.UNEXPECTED_NULL_VALUE;

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

  /* ==================== funcMove ===================================== */
  /* current point move function */
  protected void funcMove(TTGlyphZoneRec zone, int point, int distance) {
    render_funcs.curr_move_func.move(zone, point, distance);
  }

  /* ==================== funcMoveOrig ===================================== */
  /* move original position function */
  protected void funcMoveOrig(TTGlyphZoneRec zone, int point, int distance) {
    render_funcs.curr_move_func.moveOrig(zone, point, distance);
  }

  /* ==================== funcReadCvt ===================================== */
  /* read a cvt entry              */
  protected int funcReadCvt(int idx) {
    return render_funcs.curr_cvt_func.readCvt(idx);
  }

  /* ==================== funcWriteCvt ===================================== */
  /* write a cvt entry (in pixels) */
  protected void funcWriteCvt(int idx, int value) {
    render_funcs.curr_cvt_func.writeCvt(idx, value);
  }

  /* ==================== funcMoveCvt ===================================== */
  /* incr a cvt entry (in pixels)  */
  protected FTError.ErrorTag funcMoveCvt(int val1, int val2) {


    return render_funcs.curr_cvt_func.moveCvt(val1, val2);
  }

  public FTError.ErrorTag RunInstructions() {
    Log.e(TAG, "RunInstructions may not be called directly");
    return FTError.ErrorTag.UNEXPECTED_NULL_VALUE;
  }

}

Changes to aftttinterpreter/TTInstructionFuncGrp9.java.

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
      /* UNDOCUMENTED!  The MS rasterizer does that with */
      /* twilight points (confirmed by Greg Hitchcock)   */
    if (cur.graphics_state.gep1 == 0) {
      cur.zp1.setOrgPoint_x(point, (cur.zp0.getOrgPoint_x(cur.graphics_state.rp0) + TTUtil.TTMulFix14(cvt_dist, cur.graphics_state.freeVector.getX())));
      cur.zp1.setOrgPoint_y(point, (cur.zp0.getOrgPoint_y(cur.graphics_state.rp0) + TTUtil.TTMulFix14(cvt_dist, cur.graphics_state.freeVector.getY())));
      cur.zp1.setCurPoint(point, cur.zp1.getOrgPoint(point));
    }
    Debug(0, DebugTag.DBG_INTERP, TAG, String.format("dualproj: point: %d, GS.rp0: %d, zp1.org[point].x: %d, zp1.org[point].y: %d, zp0.org[GS.rp0].x: %d, zp0.org[GS.rp0].y: %d", point, cur.graphics_state.rp0, cur.zp1.getOrgPoint_x(point), cur.zp1.getOrgPoint_y(point), cur.zp0.getOrgPoint_x(cur.graphics_state.rp0), cur.zp0.getOrgPoint_y(cur.graphics_state.rp0)));
    org_dist = cur.funcDualproj(cur.zp1.getOrgPoint_x(point) - cur.zp0.getOrgPoint_x(cur.graphics_state.rp0),
        cur.zp1.getOrgPoint_y(point) - cur.zp0.getOrgPoint_y(cur.graphics_state.rp0));
    cur_dist = cur.funcProject(cur.zp1.getCurPoint_x(point) - cur.zp0.getCurPoint_x(cur.graphics_state.rp0),
        cur.zp1.getCurPoint_y(point) - cur.zp0.getCurPoint_y(cur.graphics_state.rp0));
      /* auto-flip test */
    if (cur.graphics_state.auto_flip) {
      if ((org_dist ^ cvt_dist) < 0) {







|







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
      /* UNDOCUMENTED!  The MS rasterizer does that with */
      /* twilight points (confirmed by Greg Hitchcock)   */
    if (cur.graphics_state.gep1 == 0) {
      cur.zp1.setOrgPoint_x(point, (cur.zp0.getOrgPoint_x(cur.graphics_state.rp0) + TTUtil.TTMulFix14(cvt_dist, cur.graphics_state.freeVector.getX())));
      cur.zp1.setOrgPoint_y(point, (cur.zp0.getOrgPoint_y(cur.graphics_state.rp0) + TTUtil.TTMulFix14(cvt_dist, cur.graphics_state.freeVector.getY())));
      cur.zp1.setCurPoint(point, cur.zp1.getOrgPoint(point));
    }
Debug(0, DebugTag.DBG_INTERP, TAG, String.format("dualproj: point: %d, GS.rp0: %d, zp1.org[point].x: %d, zp1.org[point].y: %d, zp0.org[GS.rp0].x: %d, zp0.org[GS.rp0].y: %d", point, cur.graphics_state.rp0, cur.zp1.getOrgPoint_x(point), cur.zp1.getOrgPoint_y(point), cur.zp0.getOrgPoint_x(cur.graphics_state.rp0), cur.zp0.getOrgPoint_y(cur.graphics_state.rp0)));
    org_dist = cur.funcDualproj(cur.zp1.getOrgPoint_x(point) - cur.zp0.getOrgPoint_x(cur.graphics_state.rp0),
        cur.zp1.getOrgPoint_y(point) - cur.zp0.getOrgPoint_y(cur.graphics_state.rp0));
    cur_dist = cur.funcProject(cur.zp1.getCurPoint_x(point) - cur.zp0.getCurPoint_x(cur.graphics_state.rp0),
        cur.zp1.getCurPoint_y(point) - cur.zp0.getCurPoint_y(cur.graphics_state.rp0));
      /* auto-flip test */
    if (cur.graphics_state.auto_flip) {
      if ((org_dist ^ cvt_dist) < 0) {