From: <sil...@li...> - 2004-10-28 15:50:38
|
Update of /cvsroot/silgraphite/silgraphite/contrib/pangomod In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10098 Modified Files: pangographite.cpp Log Message: new cluster work ifdefd out Index: pangographite.cpp =================================================================== RCS file: /cvsroot/silgraphite/silgraphite/contrib/pangomod/pangographite.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pangographite.cpp 25 Oct 2004 21:23:54 -0000 1.7 +++ pangographite.cpp 28 Oct 2004 15:50:29 -0000 1.8 @@ -103,33 +103,68 @@ int * prgxd; int * prgyd; int * prgdxdAdv; - int n_chars; + int n_glyphs; Rect rs(0,0,100,100); Rect rd(0,0,100,100); // Get the number of chars first pgrseg->GetGlyphsAndPositions(0, pgrfx, - rs, rd, 0, &n_chars, NULL, NULL, NULL, NULL); + rs, rd, 0, &n_glyphs, NULL, NULL, NULL, NULL); #if 0 - g_message("%d chars: %s", n_chars, text); + g_message("%d chars: %s", n_glyphs, text); #endif - prgchGlyphs = new utf16[n_chars]; - prgxd = new int[n_chars]; - prgyd = new int[n_chars]; - prgdxdAdv = new int[n_chars]; + prgchGlyphs = new utf16[n_glyphs]; + prgxd = new int[n_glyphs]; + prgyd = new int[n_glyphs]; + prgdxdAdv = new int[n_glyphs]; pgrseg->GetUniscribeGlyphsAndPositions(0, pgrfx, - rs, rd, n_chars, &n_chars, prgchGlyphs, + rs, rd, n_glyphs, &n_glyphs, prgchGlyphs, prgxd, prgyd, prgdxdAdv); - pango_glyph_string_set_size (glyphs, n_chars); +#ifdef NEW_CLUSTER + int n_chars; + int * prg1stOfCluster; + bool * pfClusterStart; + int * prg1stCharInClust; + + pgrtext->get_Length(&n_chars); + prg1stOfCluster = new int[n_chars]; + pfClusterStart = new bool[n_glyphs]; + prg1stCharInClust = new int[n_glyphs]; + //int cch, cf; + + pgrseg->GetUniscribeClusters(0, pgrfx, + prg1stOfCluster, n_chars, /*&cch*/NULL, + pfClusterStart, n_glyphs, /*&cf*/NULL); + + #if 1 + for (int i=n_glyphs-1; i>0; i--) + { + prg1stCharInClust[i] = -1; + } + #endif + prg1stCharInClust[0] = 0; + for (int i=n_chars-1; i>=0; i--) + { + if (prg1stOfCluster[i]<0) + { + g_warning("prg1stOfCluster[%d]=%d < 0 => not good", i, prg1stOfCluster[i]); + } + else + prg1stCharInClust[prg1stOfCluster[i]] = i; + //g_message("prg1stCharInClust[%d] = %d", prg1stOfCluster[i], i); + } +#endif + + pango_glyph_string_set_size (glyphs, n_glyphs); PangoGlyph index; PangoRectangle logical_rect; int prev_offset = 0; - for (int i=0; i<n_chars; i++) + 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]); @@ -167,7 +202,18 @@ glyphs->glyphs[i].geometry.width = logical_rect.width; //glyphs->log_clusters[i] = prgdxdAdv[i]; + #ifdef NEW_CLUSTER + if (pfClusterStart[i]) + { + if (prg1stCharInClust[i]==-1) + g_warning("oops cluster wrong at %d", i); + first_char_in_cluster = prg1stCharInClust[i]; + } + + glyphs->log_clusters[i] = g_utf8_offset_to_pointer(text, first_char_in_cluster) - text; + #else pgrseg->GlyphToChar(0, pgrfx, i, 1, &(glyphs->log_clusters[i])); + #endif #if 0 g_message("%d complete glyph %d xoff %d yoff %d width %d logclust %d", @@ -178,13 +224,17 @@ //glyphs->glyphs[i].geometry.width = prgdxdAdv[i]; } - glyphs->num_glyphs = n_chars; + glyphs->num_glyphs = n_glyphs; delete[] prgchGlyphs; delete[] prgxd; delete[] prgyd; delete[] prgdxdAdv; - +#ifdef NEW_CLUSTER + delete[] prg1stOfCluster; + delete[] pfClusterStart; + delete[] prg1stCharInClust; +#endif delete pgrseg; delete pgrtext; delete pchrp; @@ -197,82 +247,3 @@ } -#if 0 -GrResult GrSegment::GetUniscribePositions(int ichBase, IGrGraphics * pgg, - RECT rs, RECT rd, int cgidMax, int *pcgidRet, - int * prgxd, int * prgyd, int * prgdxdAdv) -{ - ChkGrArgPtr(pgg); - ChkGrOutPtr(pcgidRet); - ChkGrArrayArg(prgxd, cgidMax); - ChkGrArrayArg(prgyd, cgidMax); - ChkGrArrayArg(prgdxdAdv, cgidMax); - - GrResult res; - - SetUpGraphics(ichBase, pgg, true); - - if (m_fJustify) - { - res = ComputeDimensions(ichBase, pgg); - if (ResultFailed(res)) - { - RestoreFont(pgg); - ReturnResult(res); - } - } - - int cgbb = NumGbb(); - *pcgidRet = cgbb; - if (cgidMax < cgbb) - { - res = (cgidMax == 0) ? kresFalse : kresInvalidArg; - RestoreFont(pgg); - ReturnResult(res); - } - - if (m_dysAscent < 0) - { - res = ComputeDimensions(ichBase, pgg); - if (ResultFailed(res)) - { - RestoreFont(pgg); - ReturnResult(res); - } - } - - int * rgxdTmp = new int[cgidMax]; - int * rgdxdAdvTmp = new int[cgidMax]; - res = GetGlyphsAndPositions(ichBase, pgg, rs, rd, cgidMax, pcgidRet, - NULL, rgxdTmp, prgyd, rgdxdAdvTmp); - if (ResultFailed(res)) - { - delete[] rgxdTmp; - delete[] rgdxdAdvTmp; - RestoreFont(pgg); - ReturnResult(res); - } - - int xdLeft = ScaleX(0, rs, rd); - int xdXPosNatural = xdLeft; - for (int igbb = 0; igbb < *pcgidRet; igbb++) - { - int islout = SlotIndexForGbb(igbb); - GrSlotOutput * pslout = OutputSlot(islout); - int dxsAdvNatural = pslout->AdvanceXMetric(); - int dxdAdvNatural = ScaleX(dxsAdvNatural, rs, rd) - xdLeft; - prgdxdAdv[igbb] = dxdAdvNatural; - prgxd[igbb] = rgxdTmp[igbb] - xdXPosNatural; - - xdXPosNatural += dxdAdvNatural; - } - - delete[] rgxdTmp; - delete[] rgdxdAdvTmp; - - RestoreFont(pgg); - - ReturnResult(res); - -} -#endif |