]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/samples/layout/GDIFontInstance.cpp
ICU-8.11.tar.gz
[apple/icu.git] / icuSources / samples / layout / GDIFontInstance.cpp
index e66b28f2aaca858fc0cba222871d7d4c8dc635c3..d3451e9a575bede0b3385f413b8113d791dd37b4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 1999-2003, International Business Machines
+ *   Copyright (C) 1999-2006, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
@@ -55,6 +55,8 @@ void GDISurface::drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs,
 {
     TTGlyphID *ttGlyphs = LE_NEW_ARRAY(TTGlyphID, count);
     le_int32  *dx = LE_NEW_ARRAY(le_int32, count);
+    float     *ps = LE_NEW_ARRAY(float, count * 2 + 2);
+    le_int32   out = 0;
     RECT clip;
 
     clip.top    = 0;
@@ -63,13 +65,15 @@ void GDISurface::drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs,
     clip.right  = width;
 
     for (le_int32 g = 0; g < count; g += 1) {
-        ttGlyphs[g] = (TTGlyphID) LE_GET_GLYPH(glyphs[g]);
-
-        if (ttGlyphs[g] == 0xFFFF || ttGlyphs[g] == 0xFFFE) {
-            ttGlyphs[g] = 0x0002;
+        TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyphs[g]);
+
+        if (ttGlyph < 0xFFFE) {
+            ttGlyphs[out] = ttGlyph;
+            dx[out] = (le_int32) (positions[g * 2 + 2] - positions[g * 2]);
+            ps[out * 2] = positions[g * 2];
+            ps[out * 2 + 1] = positions[g * 2 + 1];
+            out += 1;
         }
-
-        dx[g] = (le_int32) (positions[g * 2 + 2] - positions[g * 2]);
     }
 
     le_int32 dyStart, dyEnd;
@@ -78,20 +82,21 @@ void GDISurface::drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs,
 
     dyStart = dyEnd = 0;
 
-    while (dyEnd < count) {
-        float yOffset = positions[dyStart * 2 + 1];
-        float xOffset = positions[dyStart * 2];
+    while (dyEnd < out) {
+        float yOffset = ps[dyStart * 2 + 1];
+        float xOffset = ps[dyStart * 2];
 
-        while (dyEnd < count && yOffset == positions[dyEnd * 2 + 1]) {
+        while (dyEnd < out && yOffset == ps[dyEnd * 2 + 1]) {
             dyEnd += 1;
         }
 
         ExtTextOut(fHdc, x + (le_int32) xOffset, y + (le_int32) yOffset - font->getAscent(), ETO_CLIPPED | ETO_GLYPH_INDEX, &clip,
-            &ttGlyphs[dyStart], dyEnd - dyStart, (INT *) &dx[dyStart]);
+            (LPCWSTR) &ttGlyphs[dyStart], dyEnd - dyStart, (INT *) &dx[dyStart]);
 
         dyStart = dyEnd;
     }
 
+    LE_DELETE_ARRAY(ps);
     LE_DELETE_ARRAY(dx);
     LE_DELETE_ARRAY(ttGlyphs);
 }