From: <sil...@li...> - 2005-08-05 09:44:02
|
Update of /cvsroot/silgraphite/silgraphite/contrib/pangomod In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18492 Modified Files: pangographite.cpp pangographite.h prop-editor.c silgraphite-fc.c stressengine.cpp Log Message: latest experimentation don't require pango patch cursor hack experiments and stuff with log clusters ifdefd out Index: pangographite.cpp =================================================================== RCS file: /cvsroot/silgraphite/silgraphite/contrib/pangomod/pangographite.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- pangographite.cpp 28 Feb 2005 16:08:30 -0000 1.11 +++ pangographite.cpp 5 Aug 2005 09:43:40 -0000 1.12 @@ -30,73 +30,351 @@ #include "pangographite.h" static GrGraphics *cached_grfx = NULL; + +#if CACHE_SEGMENTS +static GList *segment_cache = NULL; //static GrEngine *xftgreng; + +// How to implement caching? +// What exactly needs cached? + +class GrCache +{ +private: + const char * m_text; + int m_length; + GrSegment *m_grseg; + GrGraphics *m_grfx; + GrEngine *m_greng; + GrTextSrc *m_grtxt; + GrCharProps *m_grchp; + +public: + GrCache(const char *, int, GrSegment*, GrGraphics*, + GrEngine*,GrTextSrc*,GrCharProps*); + ~GrCache(); + + GrSegment* segment() {return m_grseg;}; + GrGraphics* graphics() {return m_grfx;}; + const char* text() {return m_text;}; + int length() {return m_length;} +}; + +GrCache::GrCache(const char *text, int length, GrSegment *pgrseg, + GrGraphics *pgrfx, GrEngine *pgreng, + GrTextSrc *pgrtxt, GrCharProps *pgrchp) : + m_length(length), m_grseg(pgrseg), m_grfx(pgrfx), + m_greng(pgreng), m_grtxt(pgrtxt), m_grchp(pgrchp) +{ + m_text = strdup(text); +} + +GrCache::~GrCache() +{ + delete m_grseg; + delete m_grfx; + delete m_greng; + delete m_grtxt; + delete m_grchp; + delete[] m_text; +} + +gint segment_compare (gconstpointer a, gconstpointer b) +{ + GrCache* acache = (GrCache*) a; + GrCache* bcache = (GrCache*) b; + if (acache->length() != bcache->length()) + { + if (acache->length() > bcache->length()) + return 1; + else + return -1; + } + return strcmp(acache->text(), bcache->text()); +} + +GrSegment *graphite_GetSegment(const char *text, int length, GrGraphics **pgrfx) +{ + GList *found; + GrSegment *pgrseg = NULL; + *pgrfx = NULL; + GrCache *cachecomp = new GrCache(text, length, 0, 0, 0, 0, 0); + found = g_list_find_custom(segment_cache, cachecomp, &segment_compare); + delete cachecomp; + if (found) + { + GrCache *foundcache = (GrCache*) found->data; + + pgrseg = foundcache->segment(); + *pgrfx = foundcache->graphics(); + } + return pgrseg; +} + +void graphite_CacheSegment(const char *text, int length, GrSegment *pgrseg, + GrGraphics *pgrfx, GrEngine *pgreng, + GrTextSrc *pgrtext, GrCharProps *pgrchp) +{ + GrCache *cache = new GrCache(text, length, pgrseg, pgrfx, + pgreng, pgrtext, pgrchp); + segment_cache = g_list_append(segment_cache, cache); +} + + +int byte_to_graphite_index(const char *text, int length, int index) +{ + //WARNING Quick and dirty implementation + glong graphite_index, bytesread; + utf16 *subby = g_utf8_to_utf16(text, index, &bytesread, &graphite_index, NULL); + g_free(subby); + return graphite_index; +} + +// How to implement this using grsegment? + +void graphite_glyph_string_x_to_index (PangoGlyphString *glyphs, + const char *text, + int length, + PangoAnalysis *analysis, + int x_pos, + int *index, + gboolean *trailing) +{ +} + +void graphite_glyph_string_index_to_x (PangoGlyphString *glyphs, + const char *text, + int length, + PangoAnalysis *analysis, + int index, + gboolean trailing, + int *x_pos) +{ + Rect rs(0,0,100,100); + Rect rd(0,0,100,100); + GrGraphics *pgrfx; + GrSegment *pgrseg; + RECT rPrimary, rSecondary; + bool bPrimary, bSecondary; + int insertion_point; + pgrseg = graphite_GetSegment(text, length, &pgrfx); + if (!pgrseg) + g_warning("unable to find cached segment for %s:%d", text, length); + + insertion_point = byte_to_graphite_index(text, length, index); + + pgrseg->PositionsOfIP(0, pgrfx, rs, rd, insertion_point, + trailing, kdmNormal, &rPrimary, &rSecondary, + &bPrimary, &bSecondary); + + if (bPrimary) { + *x_pos = PANGO_SCALE * rPrimary.left; + } + else if (bSecondary) { + g_message("using secondary"); + *x_pos = PANGO_SCALE * rSecondary.left; + } + else if (index == 0) { + x_pos = 0; + } + else { + g_warning("failed to find x_pos for index %d", index); + } +} + +#endif + + +/*---------------------------------------------------------------------------------------------- + Fill in bounding rectangles for the (possibly 2-part) IP, in destination device coordinates. + Return flags indicating which of the 2 parts where rendered here. + + @param rs,rd - source/destination coordinates, for scaling + @param ichwIP - insertion point + @param fAssocPrev - is the IP "leaning" backward? + @param dm - draw mode: + kdmNormal = draw complete insertion pt (I-beam or split cursor); + kdmPrimary = only draw primary half of split cursor; + kdmSecondary = only draw secondary half of split cursor + @param prdPrimary - return location of primary selection, in dest coords + @param prdSecondary - return location of secondary selection, in dest coords + @param pfPrimaryHere - true if we filled in prdPrimary + @param pfSecHere - true if we filled in prdSecondary +---------------------------------------------------------------------------------------------- +GrResult GrSegment::PositionsOfIP(int ichwBase, IGrGraphics * pgg, + RECT rs, RECT rd, int ichwIP, bool fAssocPrev, LgIPDrawMode dm, + RECT * prdPrimary, RECT * prdSecondary, + bool * pfPrimaryHere, bool * pfSecHere) +*/ + +#if NEW_LOG_CLUST +static void +set_up_pango_log_clusters (gboolean rtl, + int itemlen, + WORD *usp_log_clusters, + int nglyphs, + gint *pango_log_clusters, + int char_offset) +/* e.g. + itemlen = items[item+1].iCharPos - items[item].iCharPos; + set_up_pango_log_clusters (items[item].a.fRTL, itemlen, log_clusters, + nglyphs, glyphs->log_clusters + ng, + items[item].iCharPos); +*/ + + { + int j, k; + int first_char_in_cluster; + + if (rtl) + { + /* RTL. Walk Uniscribe log_clusters array backwards, build Pango + * log_clusters array forwards. + */ + int glyph0 = 0; + first_char_in_cluster = itemlen - 1; + for (j = itemlen - 1; j >= 0; j--) + { + if (j < itemlen - 1 && usp_log_clusters[j+1] != usp_log_clusters[j]) + { + /* Cluster starts */ + first_char_in_cluster = j; + } + if (j == 0) + { + /* First char, cluster ends */ + for (k = glyph0; k < nglyphs; k++) + pango_log_clusters[k] = first_char_in_cluster + char_offset; + } + else if (usp_log_clusters[j-1] == usp_log_clusters[j]) + { + /* Cluster continues */ + first_char_in_cluster = j-1; + } + else + { + /* Cluster ends */ + for (k = glyph0; k <= usp_log_clusters[j]; k++) + pango_log_clusters[k] = first_char_in_cluster + char_offset; + glyph0 = usp_log_clusters[j] + 1; + } + } + } + else + { + /* LTR. Walk Uniscribe log_clusters array forwards, build Pango + * log_clusters array also forwards. + */ + first_char_in_cluster = 0; + for (j = 0; j < itemlen; j++) + { + if (j > 0 && usp_log_clusters[j-1] != usp_log_clusters[j]) + { + /* Cluster starts */ + first_char_in_cluster = j; + } + if (j == itemlen - 1) + { + /* Last char, cluster ends */ + for (k = usp_log_clusters[j]; k < nglyphs; k++) + pango_log_clusters[k] = first_char_in_cluster + char_offset; + } + else if (usp_log_clusters[j] == usp_log_clusters[j+1]) + { + /* Cluster continues */ + } + else + { + /* Cluster ends */ + for (k = usp_log_clusters[j]; k < usp_log_clusters[j+1]; k++) + pango_log_clusters[k] = first_char_in_cluster + char_offset; + } + } + } +} +#endif + void graphite_PangoGlyphString(const char *text, int length, PangoFont *xftfont, PangoGlyphString *glyphs) { - GrEngine *xftgreng = new GrEngine(); GrGraphics * pgrfx; - if (cached_grfx) + GrSegment * pgrseg; + GrEngine *xftgreng; + GrTextSrc * pgrtext; + GrCharProps * pchrp; + #if CACHE_SEGMENTS + bool using_cache = true; + pgrseg = graphite_GetSegment(text, length, &pgrfx); + if (!pgrseg) { - if (cached_grfx->getFont()==xftfont) + using_cache = false; + #endif + xftgreng = new GrEngine(); + if (cached_grfx) { - pgrfx = cached_grfx; + if (cached_grfx->getFont()==xftfont) + { + pgrfx = cached_grfx; + } + else + { + delete cached_grfx; + pgrfx = new GrGraphics(xftfont); + cached_grfx = pgrfx; + } } else { - delete cached_grfx; pgrfx = new GrGraphics(xftfont); cached_grfx = pgrfx; } + int cchSeg; // how many characters fit in the segment + int dxWidth; // width of resulting segment + LgEndSegmentType est; // why the segment was ended + byte rgbNextSeg[256]; + int ciNextSeg; + OLECHAR errmsg[128]; + int dichContext; + + pchrp = new GrCharProps(); + memset(pchrp, '\0', sizeof(GrCharProps)); + //pchrp->dympHeight = size * 1000; // font size in millipoints + pgrtext = new GrTextSrc(text, length, *pchrp, "", 0); + xftgreng->InitRenderer(pgrfx, NULL, 0); + GrResult res = xftgreng->FindBreakPoint(pgrfx, pgrtext, + 0, // start at the beginning of the string + 10000, 10000, // try to handle entire string if possible + false, // need final break + true, // is this the first segment on the line? + 2560000, // width available + klbWordBreak, // preferred kind of line break + klbClipBreak, // worst-case line break + ktwshAll, // standard handling of trailing white space + false, // paragraph is left-to-right + &pgrseg, + &cchSeg, &dxWidth, &est, + 0, NULL, // no preceding segment to handle + 256, rgbNextSeg, &ciNextSeg, // info for following segment, exception thrown if this missing + &dichContext, // index of first char of interest to following seg + errmsg, 128); // for returning an error message + + if (res != kresOk) + { + g_warning("Could not create Graphite segment."); + delete pchrp; + delete pgrtext; + //delete pgrfx; + delete xftgreng; + return; + } + #if CACHE_SEGMENTS + graphite_CacheSegment(text, length, pgrseg, pgrfx, xftgreng, pgrtext, pchrp); + // WARNING no-one is managing this grseg at the moment - might be ok in cache + // also, there is only a single global grfx at the moment + // of the greng, txtsrc, chrp what else needs held? } - else - { - pgrfx = new GrGraphics(xftfont); - cached_grfx = pgrfx; - } - int cchSeg; // how many characters fit in the segment - int dxWidth; // width of resulting segment - LgEndSegmentType est; // why the segment was ended - byte rgbNextSeg[256]; - int ciNextSeg; - OLECHAR errmsg[128]; - int dichContext; - GrSegment * pgrseg; - - GrCharProps * pchrp = new GrCharProps(); - memset(pchrp, '\0', sizeof(GrCharProps)); - //pchrp->dympHeight = size * 1000; // font size in millipoints - GrTextSrc * pgrtext; - pgrtext = new GrTextSrc(text, length, *pchrp, "", 0); - - xftgreng->InitRenderer(pgrfx, NULL, 0); - GrResult res = xftgreng->FindBreakPoint(pgrfx, pgrtext, - 0, // start at the beginning of the string - 10000, 10000, // try to handle entire string if possible - false, // need final break - true, // is this the first segment on the line? - 2560000, // width available - klbWordBreak, // preferred kind of line break - klbClipBreak, // worst-case line break - ktwshAll, // standard handling of trailing white space - false, // paragraph is left-to-right - &pgrseg, - &cchSeg, &dxWidth, &est, - 0, NULL, // no preceding segment to handle - 256, rgbNextSeg, &ciNextSeg, // info for following segment, exception thrown if this missing - &dichContext, // index of first char of interest to following seg - errmsg, 128); // for returning an error message - - if (res != kresOk) - { - g_warning("Could not create Graphite segment."); - delete pchrp; - delete pgrtext; - //delete pgrfx; - delete xftgreng; - return; - } - + #endif + // now need to get a PangoGlyphString from pgrseg utf16 * prgchGlyphs; int * prgxd; @@ -119,7 +397,6 @@ pgrseg->GetUniscribeGlyphsAndPositions(0, pgrfx, rs, rd, n_glyphs, &n_glyphs, prgchGlyphs, prgxd, prgyd, prgdxdAdv); - int n_chars; int * prg1stOfCluster; bool * pfClusterStart; @@ -127,27 +404,48 @@ int first_char_in_cluster, last_cluster_start = 0; int cluster_width = 0; int cch, cf; - //int * tmp; // find the length (in utf8 chars) of textsource - pgrtext->get_Length(&n_chars); + n_chars = g_utf8_strlen (text, length); + //for each char in the utf8 string the first glyph that is in that cluster prg1stOfCluster = new int[n_chars]; // for each glyph whether or not it is the first in a cluster pfClusterStart = new bool[n_glyphs]; // for each glyph the first char that is in that cluster prg1stCharInClust = new int[n_glyphs]; - //tmp = new int[n_glyphs]; - #ifdef WDGDEBUG - g_message("%d chars, %d glyphs: %s", n_chars, n_glyphs, text); - #endif - - pgrseg->GetUniscribeClusters(0, pgrfx, prg1stOfCluster, n_chars, &cch, pfClusterStart, n_glyphs, &cf); - + + #if NEW_LOG_CLUST + int first_char_in_cluster = 0; + for (int j = 0; j < itemlen; j++) + { + if (j > 0 && usp_log_clusters[j-1] != usp_log_clusters[j]) + { + /* Cluster starts */ + first_char_in_cluster = j; + } + if (j == itemlen - 1) + { + /* Last char, cluster ends */ + for (k = usp_log_clusters[j]; k < nglyphs; k++) + pango_log_clusters[k] = first_char_in_cluster + char_offset; + } + else if (usp_log_clusters[j] == usp_log_clusters[j+1]) + { + /* Cluster continues */ + } + else + { + /* Cluster ends */ + for (k = usp_log_clusters[j]; k < usp_log_clusters[j+1]; k++) + pango_log_clusters[k] = first_char_in_cluster + char_offset; + } + } + #else // BUG? single character strings prg1stOfCluster[0] = -1 // This isn't right though because it isn't guaranteed to be 0 prg1stOfCluster[0] = 0; @@ -155,27 +453,9 @@ { prg1stCharInClust[i] = -1; } - #ifdef WDGDEBUG - for (int i=0; i < n_chars; i++) - { - if ((prg1stOfCluster[i] < 0) || (prg1stOfCluster[i] >= n_glyphs)) - { - g_warning("char %d has a bad 1stof cluster %d", i, prg1stOfCluster[i]); - } - - } - #endif prg1stCharInClust[0] = 0; for (int i=n_chars-1; i>=0; i--) { - #ifdef WDGDEBUG - g_message("prg1stCharInClust[%d] = %d", prg1stOfCluster[i], i); - if (prg1stOfCluster[i]<0) - { - g_warning("prg1stOfCluster[%d]=%d < 0 => not good", i, prg1stOfCluster[i]); - } - else - #endif prg1stCharInClust[prg1stOfCluster[i]] = i; } for (int i=1; i < n_glyphs; i++) @@ -201,16 +481,13 @@ } if (j < 0 || j >= n_glyphs) { - g_message("char %d out of range --%d", j, n_glyphs); + g_warning("char %d out of range --%d", j, n_glyphs); } prg1stCharInClust[i] = prg1stCharInClust[j]; } - #ifdef WDGDEBUG - g_message("1charin of glyph %d is %d(%d)", i, prg1stCharInClust[i], pfClusterStart[i]); - #endif } - - pango_glyph_string_set_size (glyphs, n_glyphs); + #endif + pango_glyph_string_set_size(glyphs, n_glyphs); PangoGlyph index; PangoRectangle logical_rect; @@ -219,8 +496,6 @@ for (int i=0; i<n_glyphs; i++) { - //g_message("char %d", i); - //glyphs->glyphs[i].glyph = pango_fc_font_get_glyph ((PangoFcFont *) xftfont, prgchGlyphs[i]); glyphs->glyphs[i].glyph = prgchGlyphs[i]; // which of these 2??? glyphs->glyphs[i].geometry.y_offset = prgyd[i]*PANGO_SCALE; @@ -228,9 +503,7 @@ pango_font_get_glyph_extents (xftfont, glyphs->glyphs[i].glyph, NULL, &logical_rect); - glyphs->glyphs[i].geometry.width = logical_rect.width; // !!WRONG - glyphs can overlap - // what I think I want to get is the forward width (advance?) for each glyph in a cluster - // then divide it by the number of glyphs in the cluster + glyphs->glyphs[i].geometry.width = logical_rect.width; if (pfClusterStart[i]) { @@ -241,22 +514,23 @@ //tmp[i] = first_char_in_cluster; + #if !NEW_LOG_CLUST glyphs->log_clusters[i] = g_utf8_offset_to_pointer(text, first_char_in_cluster) - text; - - #ifdef WDGDEBUG - g_message("glyph %d has lh%d lw%d lx%d ly%d xoff%d yoff%d wid%d logcl%d", i, - logical_rect.height, logical_rect.width, - logical_rect.x, logical_rect.y, - glyphs->glyphs[i].geometry.x_offset, glyphs->glyphs[i].geometry.y_offset, - glyphs->glyphs[i].geometry.width, - glyphs->log_clusters[i]); #endif - - } glyphs->num_glyphs = n_glyphs; - + // From pango_shape for debug + /* Set glyphs[i].attr.is_cluster_start based on log_clusters[] + */ + int last_cluster = -1; + for (int i = 0; i < glyphs->num_glyphs; i++) + { + if (glyphs->log_clusters[i] != last_cluster) + { + last_cluster = glyphs->log_clusters[i]; + } + } delete[] prgchGlyphs; delete[] prgxd; delete[] prgyd; @@ -265,15 +539,12 @@ delete[] pfClusterStart; delete[] prg1stCharInClust; //delete[] tmp; + #if !CACHE_SEGMENTS delete pgrseg; delete pgrtext; delete pchrp; - //delete pgrseg; //delete pgrfx; //dtor cleans up font delete xftgreng; - #ifdef WDGDEBUG - g_message("%d glyphs:%d:%s", glyphs->num_glyphs, length, text ); #endif - } Index: pangographite.h =================================================================== RCS file: /cvsroot/silgraphite/silgraphite/contrib/pangomod/pangographite.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pangographite.h 20 Aug 2004 23:42:26 -0000 1.2 +++ pangographite.h 5 Aug 2005 09:43:40 -0000 1.3 @@ -21,11 +21,33 @@ */ +#define CURSORHACK 0 +#define NEW_LOG_CLUST 0 +#define CACHE_SEGMENTS 1 + #ifdef __cplusplus extern "C" { #endif void graphite_PangoGlyphString(const char *text, int length, PangoFont *font, PangoGlyphString *glyphs); +#if CURSORHACK +void graphite_glyph_string_x_to_index (PangoGlyphString *glyphs, + const char *text, + int length, + PangoAnalysis *analysis, + int x_pos, + int *index, + gboolean *trailing); + + +void graphite_glyph_string_index_to_x (PangoGlyphString *glyphs, + const char *text, + int length, + PangoAnalysis *analysis, + int index, + gboolean trailing, + int *x_pos); +#endif #ifdef __cplusplus } Index: prop-editor.c =================================================================== RCS file: /cvsroot/silgraphite/silgraphite/contrib/pangomod/prop-editor.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- prop-editor.c 27 Aug 2004 11:23:19 -0000 1.1 +++ prop-editor.c 5 Aug 2005 09:43:40 -0000 1.2 @@ -692,7 +692,7 @@ GtkWidget *vbox; GtkWidget *table; GParamSpec **specs; - gint n_specs; + guint n_specs; int i; if (G_TYPE_IS_INTERFACE (type)) Index: silgraphite-fc.c =================================================================== RCS file: /cvsroot/silgraphite/silgraphite/contrib/pangomod/silgraphite-fc.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- silgraphite-fc.c 16 Sep 2004 14:44:31 -0000 1.4 +++ silgraphite-fc.c 5 Aug 2005 09:43:40 -0000 1.5 @@ -1,7 +1,7 @@ /* Pango * silgraphite-fc.c: SILGraphite based shaper for FreeType-based backends * - * Copyright (C) 2004 SIL International + * Copyright (C) 2004-2005 SIL International * Author: Daniel Glassey <wd...@de...> * * This library is free software; you can redistribute it and/or @@ -40,8 +40,65 @@ #define RENDER_TYPE PANGO_RENDER_TYPE_FC static PangoEngineScriptInfo graphite_scripts[] = { - //{ PANGO_SCRIPT_COMMON, "*" } - { PANGO_SCRIPT_PREFERRED, "*" } + //{ PANGO_SCRIPT_COMMON, "*" }, + { PANGO_SCRIPT_COMMON, "*" }, /* Zyyy */ + { PANGO_SCRIPT_INHERITED, "*" }, /* Qaai */ + { PANGO_SCRIPT_ARABIC, "*" }, /* Arab */ + { PANGO_SCRIPT_ARMENIAN, "*" }, /* Armn */ + { PANGO_SCRIPT_BENGALI, "*" }, /* Beng */ + { PANGO_SCRIPT_BOPOMOFO, "*" }, /* Bopo */ + { PANGO_SCRIPT_CHEROKEE, "*" }, /* Cher */ + { PANGO_SCRIPT_COPTIC, "*" }, /* Qaac */ + { PANGO_SCRIPT_CYRILLIC, "*" }, /* Cyrl (Cyrs) */ + { PANGO_SCRIPT_DESERET, "*" }, /* Dsrt */ + { PANGO_SCRIPT_DEVANAGARI, "*" }, /* Deva */ + { PANGO_SCRIPT_ETHIOPIC, "*" }, /* Ethi */ + { PANGO_SCRIPT_GEORGIAN, "*" }, /* Geor (Geon, Geoa) */ + { PANGO_SCRIPT_GOTHIC, "*" }, /* Goth */ + { PANGO_SCRIPT_GREEK, "*" }, /* Grek */ + { PANGO_SCRIPT_GUJARATI, "*" }, /* Gujr */ + { PANGO_SCRIPT_GURMUKHI, "*" }, /* Guru */ + { PANGO_SCRIPT_HAN, "*" }, /* Hani */ + { PANGO_SCRIPT_HANGUL, "*" }, /* Hang */ + { PANGO_SCRIPT_HEBREW, "*" }, /* Hebr */ + { PANGO_SCRIPT_HIRAGANA, "*" }, /* Hira */ + { PANGO_SCRIPT_KANNADA, "*" }, /* Knda */ + { PANGO_SCRIPT_KATAKANA, "*" }, /* Kana */ + { PANGO_SCRIPT_KHMER, "*" }, /* Khmr */ + { PANGO_SCRIPT_LAO, "*" }, /* Laoo */ + { PANGO_SCRIPT_LATIN, "*" }, /* Latn (Latf, Latg) */ + { PANGO_SCRIPT_MALAYALAM, "*" }, /* Mlym */ + { PANGO_SCRIPT_MONGOLIAN, "*" }, /* Mong */ + { PANGO_SCRIPT_MYANMAR, "*" }, /* Mymr */ + { PANGO_SCRIPT_OGHAM, "*" }, /* Ogam */ + { PANGO_SCRIPT_OLD_ITALIC, "*" }, /* Ital */ + { PANGO_SCRIPT_ORIYA, "*" }, /* Orya */ + { PANGO_SCRIPT_RUNIC, "*" }, /* Runr */ + { PANGO_SCRIPT_SINHALA, "*" }, /* Sinh */ + { PANGO_SCRIPT_SYRIAC, "*" }, /* Syrc (Syrj, Syrn, Syre) */ + { PANGO_SCRIPT_TAMIL, "*" }, /* Taml */ + { PANGO_SCRIPT_TELUGU, "*" }, /* Telu */ + { PANGO_SCRIPT_THAANA, "*" }, /* Thaa */ + { PANGO_SCRIPT_THAI, "*" }, /* Thai */ + { PANGO_SCRIPT_TIBETAN, "*" }, /* Tibt */ + { PANGO_SCRIPT_CANADIAN_ABORIGINAL, "*" }, /* Cans */ + { PANGO_SCRIPT_YI, "*" }, /* Yiii */ + { PANGO_SCRIPT_TAGALOG, "*" }, /* Tglg */ + { PANGO_SCRIPT_HANUNOO, "*" }, /* Hano */ + { PANGO_SCRIPT_BUHID, "*" }, /* Buhd */ + { PANGO_SCRIPT_TAGBANWA, "*" }, /* Tagb */ + + /* Unicode-4.0 additions */ + { PANGO_SCRIPT_BRAILLE, "*" }, /* Brai */ + { PANGO_SCRIPT_CYPRIOT, "*" }, /* Cprt */ + { PANGO_SCRIPT_LIMBU, "*" }, /* Limb */ + { PANGO_SCRIPT_OSMANYA, "*" }, /* Osma */ + { PANGO_SCRIPT_SHAVIAN, "*" }, /* Shaw */ + { PANGO_SCRIPT_LINEAR_B, "*" }, /* Linb */ + { PANGO_SCRIPT_TAI_LE, "*" }, /* Tale */ + { PANGO_SCRIPT_UGARITIC, "*" } /* Ugar */ + + //{ PANGO_SCRIPT_PREFERRED, "*" } }; static PangoEngineInfo script_engines[] = { @@ -129,14 +186,28 @@ { #if GOFORIT g_return_if_fail (PANGO_XFT_IS_FONT (font)); - //g_message("going for a graphite shaping!"); + #ifdef WDGDEBUG + g_message("going for a graphite shaping!"); + #endif static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + #ifdef WDGDEBUG + g_message("lock mutex"); + #endif g_static_mutex_lock (&mutex); // Do Graphite Shaping + #ifdef WDGDEBUG + g_message("locked"); + #endif graphite_PangoGlyphString(text, length, font, glyphs); + #ifdef WDGDEBUG + g_message("got glyph string"); + #endif g_static_mutex_unlock (&mutex); + #ifdef WDGDEBUG + g_message("unlocked mutex"); + #endif #else #ifdef WDGDEBUG g_message("graphite_engine_shape just doing basic shape"); @@ -455,11 +526,56 @@ #endif } +#if CURSORHACK +void +graphite_engine_glyph_string_x_to_index (PangoGlyphString *glyphs, + const char *text, + int length, + PangoAnalysis *analysis, + int x_pos, + int *index, + gboolean *trailing) +{ + //g_message("graphite_glyph_string_x_to_index"); + pango_glyph_string_x_to_index (glyphs, + text, + length, + analysis, + x_pos, + index, + trailing); +} + +void +graphite_engine_glyph_string_index_to_x (PangoGlyphString *glyphs, + const char *text, + int length, + PangoAnalysis *analysis, + int index, + gboolean trailing, + int *x_pos) +{ + //g_message("graphite_glyph_string_index_to_x"); + graphite_glyph_string_index_to_x (glyphs, + text, + length, + analysis, + index, + trailing, + x_pos); +} + +#endif + static void graphite_engine_fc_class_init (PangoEngineShapeClass *class) { class->covers = graphite_engine_covers; class->script_shape = graphite_engine_shape; + #if CURSORHACK + class->glyph_string_index_to_x = graphite_engine_glyph_string_index_to_x; + class->glyph_string_x_to_index = graphite_engine_glyph_string_x_to_index; + #endif } PANGO_ENGINE_SHAPE_DEFINE_TYPE (GraphiteEngineFc, graphite_engine_fc, Index: stressengine.cpp =================================================================== RCS file: /cvsroot/silgraphite/silgraphite/contrib/pangomod/stressengine.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- stressengine.cpp 20 Aug 2004 23:42:26 -0000 1.2 +++ stressengine.cpp 5 Aug 2005 09:43:40 -0000 1.3 @@ -4,14 +4,12 @@ #include "pangographite.h" - -const char text[15] = "Hello World!!!"; Display * display; int screen_num; static PangoCoverageLevel graphite_engine_covers (PangoFont *font) -{ +{ PangoFontDescription *desc; PangoFcFont *fcfont; char * fontcap; @@ -69,8 +67,19 @@ } -int main() +int main(int argc, char *argv[]) +{ +gchar *text; +gsize len; + +//if (!g_file_get_contents("burmese4.txt", &text, &len, NULL)) +if (!g_file_get_contents("ipa_test.txt", &text, &len, NULL)) { +printf("failed to read burmese file\n"); +exit(-1); +} + + PangoGlyphString *glyphs; PangoFont *font; //XftFont *xftfont; @@ -91,7 +100,8 @@ XFT_SIZE, XftTypeInteger, 12, 0); #endif PangoFontMap *fmap = pango_xft_get_font_map(display, screen_num); - PangoFontDescription *fdesc = pango_font_description_from_string("Std SILDoulos"); + PangoFontDescription *fdesc = pango_font_description_from_string("Doulos SIL"); + //PangoFontDescription *fdesc = pango_font_description_from_string("Padauk"); pango_font_description_set_size(fdesc, 12*PANGO_SCALE); //PangoContext *context; font = pango_font_map_load_font (fmap, NULL, fdesc); |