[sword-cvs] icu-sword/source/samples/layout FontMap.GDI,1.3,1.4 GDIFontInstance.cpp,1.3,1.4 GDIFontMap.cpp,1.3,1.4 GnomeFontInstance.cpp,1.3,1.4 GnomeFontMap.cpp,1.3,1.4 LayoutSample.rc,1.1,1.2 Sample.txt,1.3,1.4 ScriptCompositeFontInstance.cpp,1.1,1.2 gnomelayout.cpp,1.3,1.4 layout.cpp,1.3,1.4 paragraph.cpp,1.3,1.4 paragraph.h,1.3,1.4

sword@www.crosswire.org sword@www.crosswire.org
Tue, 6 Apr 2004 03:10:51 -0700


Update of /cvs/core/icu-sword/source/samples/layout
In directory www:/tmp/cvs-serv8911/source/samples/layout

Modified Files:
	FontMap.GDI GDIFontInstance.cpp GDIFontMap.cpp 
	GnomeFontInstance.cpp GnomeFontMap.cpp LayoutSample.rc 
	Sample.txt ScriptCompositeFontInstance.cpp gnomelayout.cpp 
	layout.cpp paragraph.cpp paragraph.h 
Log Message:
ICU 2.8 sync

Index: FontMap.GDI
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/FontMap.GDI,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- FontMap.GDI	10 Sep 2003 02:42:29 -0000	1.3
+++ FontMap.GDI	6 Apr 2004 10:09:11 -0000	1.4
@@ -1,28 +1,11 @@
 # Copyright (C) 2001-2003, International Business Machines
 # Corporation and others.  All Rights Reserved.
-
+#
 # This is a sample FontMap file for Windows.
 # Fonts are specified by font name, as shown
 # in the "Fonts" folder.
 
-#     LATIN: Times New Roman
-#DEVANAGARI: Devanagari MT for IBM
-#DEVANAGARI: Devanagari MT
  DEVANAGARI: Raghindi
-#    ARABIC: Times New Roman
-#    ARABIC: Arabic Typesetting
-#    ARABIC: Traditional Arabic
-#    ARABIC: MS Farsi
-#    ARABIC: Noori Nastaliq MT
-#    ARABIC: Nafees Naskh
-     ARABIC: Noori DLCursivePre MT
        THAI: Thonburi
-      TAMIL: Latha
-     TELUGU: Gautami
-   GURMUKHI: Raavi
-   GUJARATI: Shruti
-    KANNADA: Tunga
-  MALAYALAM: MalOtf
     DEFAULT: Code2000
-#   DEFAULT: Arial Unicode MS
 

Index: GDIFontInstance.cpp
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/GDIFontInstance.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- GDIFontInstance.cpp	10 Sep 2003 02:42:29 -0000	1.3
+++ GDIFontInstance.cpp	6 Apr 2004 10:09:11 -0000	1.4
@@ -367,7 +367,7 @@
 
     return result;
 #else
-    return false;
+    return FALSE;
 #endif
 }
 

Index: GDIFontMap.cpp
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/GDIFontMap.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- GDIFontMap.cpp	10 Sep 2003 02:42:29 -0000	1.3
+++ GDIFontMap.cpp	6 Apr 2004 10:09:11 -0000	1.4
@@ -28,5 +28,12 @@
 
 const LEFontInstance *GDIFontMap::openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status)
 {
-    return new GDIFontInstance(fSurface, fontName, pointSize, status);
+	LEFontInstance *result = new GDIFontInstance(fSurface, fontName, pointSize, status);
+
+	if (LE_FAILURE(status)) {
+		delete result;
+		result = NULL;
+	}
+
+    return result;
 }

Index: GnomeFontInstance.cpp
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/GnomeFontInstance.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- GnomeFontInstance.cpp	10 Sep 2003 02:42:29 -0000	1.3
+++ GnomeFontInstance.cpp	6 Apr 2004 10:09:11 -0000	1.4
@@ -46,7 +46,7 @@
 
     for (le_int32 g = 0; g < count; g += 1) {
         dx[g] = (le_int32) (positions[g * 2 + 2] - positions[g * 2]);
-        dy[g] = (le_int32) positions[g * 2 + 1];
+        dy[g] = (le_int32) - positions[g * 2 + 1];
     }
 
     raster = gFont->rasterizeGlyphs(glyphs, count, dx, dy, xOffset, yOffset);
@@ -177,7 +177,7 @@
     advance.fX = 0;
     advance.fY = 0;
 
-    if (glyph == 0xFFFF) {
+    if (glyph >= 0xFFFE) {
         return;
     }
 
@@ -204,19 +204,19 @@
     error = TT_Load_Glyph(fInstance, fGlyph, glyph, TTLOAD_SCALE_GLYPH | TTLOAD_HINT_GLYPH);
 
     if (error != 0) {
-        return false;
+        return FALSE;
     }
 
     error = TT_Get_Glyph_Outline(fGlyph, &outline);
 
     if (error != 0 || pointNumber >= outline.n_points) {
-        return false;
+        return FALSE;
     }
 
     point.fX = outline.points[pointNumber].x >> 6;
     point.fY = outline.points[pointNumber].y >> 6;
 
-    return true;
+    return TRUE;
 }
 
 // This table was generated by a little Java program.

Index: GnomeFontMap.cpp
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/GnomeFontMap.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- GnomeFontMap.cpp	10 Sep 2003 02:42:29 -0000	1.3
+++ GnomeFontMap.cpp	6 Apr 2004 10:09:11 -0000	1.4
@@ -29,5 +29,12 @@
 
 const LEFontInstance *GnomeFontMap::openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status)
 {
-    return new GnomeFontInstance(fEngine, fontName, pointSize, status);
+    LEFontInstance *result = new GnomeFontInstance(fEngine, fontName, pointSize, status);
+
+    if (LE_FAILURE(status)) {
+      delete result;
+      result = NULL;
+    }
+
+    return result;
 }

Index: LayoutSample.rc
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/LayoutSample.rc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- LayoutSample.rc	10 Sep 2003 02:42:29 -0000	1.1
+++ LayoutSample.rc	6 Apr 2004 10:09:11 -0000	1.2
@@ -15,7 +15,7 @@
 *
 *******************************************************************************
 */
-#include "afxres.h"
+#include <winresrc.h>
 
 /////////////////////////////////////////////////////////////////////////////
 #undef APSTUDIO_READONLY_SYMBOLS
@@ -86,7 +86,7 @@
     "*\r\n"
     "*******************************************************************************\r\n"
     "*/\r\n"
-    "#include ""afxres.h""\r\n"
+    "#include <winresrc.h>\r\n"
     "\0"
 END
 

Index: Sample.txt
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/Sample.txt,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Sample.txt	10 Sep 2003 02:42:29 -0000	1.3
+++ Sample.txt	6 Apr 2004 10:09:11 -0000	1.4
@@ -1 +1 @@
-The LayoutEngine does all the work necessary to display Unicode text written in languages with complex writing systems such as Hindi (हिन्दी) Thai (ไทย) and Arabic (العربية). Here's a sample of some text written in Sanskrit: श्रीमद् भगवद्गीता अध्याय अर्जुन विषाद योग धृतराष्ट्र उवाचृ धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः मामकाः पाण्डवाश्चैव किमकुर्वत संजव Here's a sample of some text written in Arabic: أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية and here's a sample of some text written in Thai: บทที่๑พายุไซโคลนโดโรธีอาศัยอยู่ท่ามกลางทุ่งใหญ่ในแคนซัสกับลุงเฮนรีชาวไร่และป้าเอ็มภรรยาชาวไร่บ้านของพวกเขาหลังเล็กเพราะไม้สร้างบ้านต้องขนมาด้วยเกวียนเป็นระยะทางหลายไมล์
+The LayoutEngine does all the work necessary to display Unicode text written in languages with complex writing systems such as Hindi (हिन्दी) Thai (ไทย) and Arabic (العربية). Here's a sample of some text written in Sanskrit: श्रीमद् भगवद्गीता अध्याय अर्जुन विषाद योग धृतराष्ट्र उवाच। धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः मामकाः पाण्डवाश्चैव किमकुर्वत संजय Here's a sample of some text written in Arabic: أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية and here's a sample of some text written in Thai: บทที่๑พายุไซโคลนโดโรธีอาศัยอยู่ท่ามกลางทุ่งใหญ่ในแคนซัสกับลุงเฮนรีชาวไร่และป้าเอ็มภรรยาชาวไร่บ้านของพวกเขาหลังเล็กเพราะไม้สร้างบ้านต้องขนมาด้วยเกวียนเป็นระยะทางหลายไมล์

Index: ScriptCompositeFontInstance.cpp
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/ScriptCompositeFontInstance.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ScriptCompositeFontInstance.cpp	10 Sep 2003 02:42:29 -0000	1.1
+++ ScriptCompositeFontInstance.cpp	6 Apr 2004 10:09:11 -0000	1.2
@@ -57,7 +57,7 @@
         return font->getGlyphPoint(LE_GET_GLYPH(glyph), pointNumber, point);
     }
 
-    return false;
+    return FALSE;
 }
 
 const LEFontInstance *ScriptCompositeFontInstance::getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const

Index: gnomelayout.cpp
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/gnomelayout.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gnomelayout.cpp	10 Sep 2003 02:42:29 -0000	1.3
+++ gnomelayout.cpp	6 Apr 2004 10:09:11 -0000	1.4
@@ -225,57 +225,48 @@
 
 GtkWidget *newSample(const gchar *fileName)
 {
-  gchar     *title   = NULL;
-  GtkWidget *app     = NULL;
-  GtkWidget *area    = NULL;
   Context   *context = new Context();
 
   context->width  = 600;
   context->height = 400;
   context->paragraph = Paragraph::paragraphFactory(fileName, font, guiSupport);
 
-  if (context->paragraph != NULL) {
-    GtkStyle *style;
-    gchar *title = prettyTitle(fileName);
-
-    app = gnome_app_new("gnomeLayout", title);
+  gchar *title = prettyTitle(fileName);
+  GtkWidget *app = gnome_app_new("gnomeLayout", title);
 
-    gtk_object_set_data(GTK_OBJECT(app), "context", context);
+  gtk_object_set_data(GTK_OBJECT(app), "context", context);
 
-    gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400);
+  gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400);
 
-    gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app);
+  gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app);
 
-    gtk_signal_connect(GTK_OBJECT(app), "delete_event",
-		       GTK_SIGNAL_FUNC(eventDelete), NULL);
+  gtk_signal_connect(GTK_OBJECT(app), "delete_event",
+		     GTK_SIGNAL_FUNC(eventDelete), NULL);
 
-    area = gtk_drawing_area_new();
-    gtk_object_set_data(GTK_OBJECT(app), "area", area);
+  GtkWidget *area = gtk_drawing_area_new();
+  gtk_object_set_data(GTK_OBJECT(app), "area", area);
 
-#if 1
-    style = gtk_style_copy(gtk_widget_get_style(area));
+  GtkStyle *style = gtk_style_copy(gtk_widget_get_style(area));
 
-    for (int i = 0; i < 5; i += 1) {
-      style->fg[i] = style->white;
-    }
+  for (int i = 0; i < 5; i += 1) {
+    style->fg[i] = style->white;
+  }
     
-    gtk_widget_set_style(area, style);
-#endif
+  gtk_widget_set_style(area, style);
 
-    gnome_app_set_contents(GNOME_APP(app), area);
+  gnome_app_set_contents(GNOME_APP(app), area);
 
-    gtk_signal_connect(GTK_OBJECT(area),
-                       "expose_event",
-                       GTK_SIGNAL_FUNC(eventExpose),
-                       context);
+  gtk_signal_connect(GTK_OBJECT(area),
+		     "expose_event",
+		     GTK_SIGNAL_FUNC(eventExpose),
+		     context);
 
-    gtk_signal_connect(GTK_OBJECT(area),
-                       "configure_event",
-                       GTK_SIGNAL_FUNC(eventConfigure),
-                       context);
+  gtk_signal_connect(GTK_OBJECT(area),
+		     "configure_event",
+		     GTK_SIGNAL_FUNC(eventConfigure),
+		     context);
 
-    appList = g_slist_prepend(appList, app);
-  }
+  appList = g_slist_prepend(appList, app);
 
   g_free(title);
 
@@ -321,10 +312,12 @@
 
     if (argc <= 1) {
       app = newSample("Sample.txt");
+
       gtk_widget_show_all(app);
     } else {
       for (int i = 1; i < argc; i += 1) {
 	app = newSample(argv[i]);
+
 	gtk_widget_show_all(app);
       }
     }

Index: layout.cpp
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/layout.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- layout.cpp	10 Sep 2003 02:42:29 -0000	1.3
+++ layout.cpp	6 Apr 2004 10:09:11 -0000	1.4
@@ -63,7 +63,7 @@
         si.nMin = 0;
         si.nMax = context->paragraph->getLineCount() - 1;
         si.nPage = context->height / context->paragraph->getLineHeight();
-        SetScrollInfo(hwnd, SB_VERT, &si, true);
+        SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
     }
 }
 
@@ -211,7 +211,7 @@
         }
 
         si.fMask = SIF_POS;
-        SetScrollInfo(hwnd, SB_VERT, &si, true);
+        SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
         GetScrollInfo(hwnd, SB_VERT, &si);
 
         context = (Context *) GetWindowLong(hwnd, 0);
@@ -304,7 +304,7 @@
                     context->paragraph = newParagraph;
                     InitParagraph(hwnd, context);
                     PrettyTitle(hwnd, szTitleName);
-                    InvalidateRect(hwnd, NULL, true);
+                    InvalidateRect(hwnd, NULL, TRUE);
 
                 }
             }

Index: paragraph.cpp
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/paragraph.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- paragraph.cpp	10 Sep 2003 02:42:29 -0000	1.3
+++ paragraph.cpp	6 Apr 2004 10:09:11 -0000	1.4
@@ -27,14 +27,24 @@
 #define MARGIN 10
 #define LINE_GROW 32
 
-Paragraph::Paragraph(const LEUnicode chars[], int32_t charCount, const FontRuns *fontRuns)
+Paragraph::Paragraph(const LEUnicode chars[], int32_t charCount, const FontRuns *fontRuns, LEErrorCode &status)
   : fParagraphLayout(NULL), fLineCount(0), fLinesMax(0), fLinesGrow(LINE_GROW), fLines(NULL), fChars(NULL),
     fLineHeight(-1), fAscent(-1), fWidth(-1), fHeight(-1)
 {
+	if (LE_FAILURE(status)) {
+		return;
+	}
+
+	LocaleRuns *locales = NULL;
+
     fChars = LE_NEW_ARRAY(LEUnicode, charCount);
     LE_ARRAY_COPY(fChars, chars, charCount);
 
-    fParagraphLayout = new ParagraphLayout(fChars, charCount, fontRuns, NULL, NULL, NULL, UBIDI_LTR, false);
+    fParagraphLayout = new ParagraphLayout(fChars, charCount, fontRuns, NULL, NULL, locales, UBIDI_DEFAULT_LTR, FALSE, status);
+
+	if (LE_FAILURE(status)) {
+		return;
+	}
 
     le_int32 ascent  = fParagraphLayout->getAscent();
     le_int32 descent = fParagraphLayout->getDescent();
@@ -102,6 +112,13 @@
         le_int32 runCount = line->countRuns();
         le_int32 run;
 
+		if (fParagraphLayout->getParagraphLevel() == UBIDI_RTL) {
+			le_int32 lastX = line->getWidth();
+
+			x = (fWidth - lastX - MARGIN);
+		}
+
+
         for (run = 0; run < runCount; run += 1) {
             const ParagraphLayout::VisualRun *visualRun = line->getVisualRun(run);
             le_int32 glyphCount = visualRun->getGlyphCount();
@@ -118,8 +135,7 @@
 
 Paragraph *Paragraph::paragraphFactory(const char *fileName, const LEFontInstance *font, GUISupport *guiSupport)
 {
-    LEErrorCode fontStatus  = LE_NO_ERROR;
-    UErrorCode scriptStatus = U_ZERO_ERROR;
+    LEErrorCode status  = LE_NO_ERROR;
     le_int32 charCount;
     const UChar *text = UnicodeReader::readFile(fileName, guiSupport, charCount);
     Paragraph *result = NULL;
@@ -132,7 +148,12 @@
 
     fontRuns.add(font, charCount);
 
-    result = new Paragraph(text, charCount, &fontRuns);
+    result = new Paragraph(text, charCount, &fontRuns, status);
+
+	if (LE_FAILURE(status)) {
+		delete result;
+		result = NULL;
+	}
 
     LE_DELETE_ARRAY(text);
 

Index: paragraph.h
===================================================================
RCS file: /cvs/core/icu-sword/source/samples/layout/paragraph.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- paragraph.h	10 Sep 2003 02:42:29 -0000	1.3
+++ paragraph.h	6 Apr 2004 10:09:11 -0000	1.4
@@ -33,7 +33,7 @@
 class Paragraph
 {
 public:
-    Paragraph(const LEUnicode chars[], le_int32 charCount, const FontRuns *fontRuns);
+    Paragraph(const LEUnicode chars[], le_int32 charCount, const FontRuns *fontRuns, LEErrorCode &status);
 
     ~Paragraph();