diff --git a/Common/FontsFreeType/FontManager.js b/Common/FontsFreeType/FontManager.js index 43f12dcac4c8995dbba9108eca8088250b9fe250..8694f27f369fad3991c8daa7fb5244e7c85aa1ae 100644 --- a/Common/FontsFreeType/FontManager.js +++ b/Common/FontsFreeType/FontManager.js @@ -224,6 +224,61 @@ TGlyphBitmap.prototype = } }, + drawCropInRect : function(context2D, x, y, clipRect) + { + var _x = x; + var _y = y; + var _r = x + this.nWidth; + var _b = y + this.nHeight; + + var _dstX = 0; + var _dstY = 0; + var _dstW = this.nWidth; + var _dstH = this.nHeight; + + if (_x < clipRect.l) + { + _dstX = clipRect.l - _x; + _x += _dstX; + _dstW -= _dstX; + } + if (_y < clipRect.t) + { + _dstY = clipRect.t - _y; + _y += _dstY; + _dstH -= _dstY; + } + if (_r > clipRect.r) + { + _dstW -= (_r - clipRect.r); + } + if (_b > clipRect.b) + { + _dstH -= (_b - clipRect.b); + } + + if (_dstW <= 0 || _dstH <= 0) + return; + + if (null != this.oGlyphData.TempImage) + { + context2D.drawImage(this.oGlyphData.TempImage, _dstX, _dstY, _dstW, _dstH, _x, _y, _dstW, _dstH); + this.oGlyphData.TempImage = null; + } + else if (null != this.oGlyphData.m_oCanvas) + { + // ÑÐ²Ð¾Ñ Ð¿Ð°Ð¼ÑÑ‚ÑŒ + context2D.drawImage(this.oGlyphData.m_oCanvas, _dstX, _dstY, _dstW, _dstH, _x, _y, _dstW, _dstH); + } + else + { + var _raster = this.oGlyphData.RasterData; + var __x = _raster.Line.Height * _raster.Index; + var __y = _raster.Line.Y; + context2D.drawImage(_raster.Chunk.CanvasImage, __x + _dstX, __y + _dstY, _dstW, _dstH, _x, _y, _dstW, _dstH); + } + }, + Free : function() { if (null != this.oGlyphData.RasterData) diff --git a/Word/Drawing/Graphics.js b/Word/Drawing/Graphics.js index 3a54ea2f5e4ec646ef3e603c9cb18a5f647d8e7a..c38e682adb61f931eaffa7c051b7f7484d29e1c3 100644 --- a/Word/Drawing/Graphics.js +++ b/Word/Drawing/Graphics.js @@ -1244,7 +1244,7 @@ CGraphics.prototype = } catch(err) { - } + } if (false === this.m_bIntegerGrid) { @@ -1459,7 +1459,11 @@ CGraphics.prototype = var nY = (this.m_oFontManager.m_oGlyphString.m_fY + pGlyph.fY - pGlyph.oBitmap.nY) >> 0; pGlyph.oBitmap.oGlyphData.checkColor(this.m_oBrush.Color1.R,this.m_oBrush.Color1.G,this.m_oBrush.Color1.B,nW,nH); - pGlyph.oBitmap.draw(this.m_oContext, nX, nY); + + if (null == this.TextClipRect) + pGlyph.oBitmap.draw(this.m_oContext, nX, nY, this.TextClipRect); + else + pGlyph.oBitmap.drawCropInRect(this.m_oContext, nX, nY, this.TextClipRect); }, private_FillGlyphC : function(pGlyph,cropX,cropW) { @@ -2518,5 +2522,15 @@ CGraphics.prototype = { if (bIsRestore) this.RestoreGrState(); + }, + + SetTextClipRect : function(_l, _t, _r, _b) + { + this.TextClipRect = { + l : _l, + t : _t, + r : _r, + b : _b + }; } }; \ No newline at end of file diff --git a/Word/Drawing/documentrenderer.js b/Word/Drawing/documentrenderer.js index 07693dddfc208429524906e87521f1783ce44893..175bdb95c75e1944b559d600efcab9776180cd88 100644 --- a/Word/Drawing/documentrenderer.js +++ b/Word/Drawing/documentrenderer.js @@ -780,12 +780,7 @@ function CDocMeta() case 164: { // text clip rect - g.TextClipRect = { - l : s.GetDouble(), - t : s.GetDouble(), - r : s.GetDouble(), - b : s.GetDouble() - }; + g.SetTextClipRect(s.GetDouble(), s.GetDouble(), s.GetDouble(), s.GetDouble()); break; } default: