From 4bb58257a8bfb97458d675d2951d9adf3bea63d3 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Mon, 16 Nov 2020 14:33:32 +0300 Subject: [PATCH] DrawStringASCII --- .../doctrenderer/embed/GraphicsEmbed.cpp | 13 +- .../doctrenderer/embed/GraphicsEmbed.h | 4 +- .../doctrenderer/embed/v8/v8_Graphics.cpp | 4 +- DesktopEditor/doctrenderer/graphics.cpp | 24 +- DesktopEditor/doctrenderer/graphics.h | 4 +- .../doctrenderer/js/NativeGraphics.js | 414 +----------------- DesktopEditor/doctrenderer/js/test.js | 3 + 7 files changed, 35 insertions(+), 431 deletions(-) diff --git a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp index ac21349c9a..16741fe66b 100644 --- a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp +++ b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp @@ -177,9 +177,9 @@ JSSmart CGraphicsEmbed::SetTextPr(JSSmart textPr, JSSmartSetTextPr(); return NULL; } -JSSmart CGraphicsEmbed::SetFontSlot(JSSmart path, JSSmart face, JSSmart size, JSSmart style) +JSSmart CGraphicsEmbed::SetFontSlot(JSSmart slot, JSSmart fontSizeKoef) { - m_pInternal->SetFont(path->toStringW(), face->toInt32(), size->toDouble(), style->toInt32()); + m_pInternal->SetFontSlot(); return NULL; } JSSmart CGraphicsEmbed::GetTextPr() @@ -204,7 +204,7 @@ JSSmart CGraphicsEmbed::FillText2(JSSmart x, JSSmart CGraphicsEmbed::t2(JSSmart x, JSSmart y, JSSmart _arr, JSSmart cropX, JSSmart cropW) { - m_pInternal->t2(); + m_pInternal->t(x->toDouble(), y->toDouble(), _arr->toStringW()); return NULL; } JSSmart CGraphicsEmbed::FillTextCode(JSSmart x, JSSmart y, JSSmart lUnicode) @@ -244,12 +244,11 @@ JSSmart CGraphicsEmbed::SetIntegerGrid(JSSmart param) } JSSmart CGraphicsEmbed::GetIntegerGrid() { - m_pInternal->GetIntegerGrid(); - return NULL; + return CJSContext::createBool(m_pInternal->GetIntegerGrid()); } -JSSmart CGraphicsEmbed::DrawStringASCII (JSSmart name, JSSmart size, JSSmart bold, JSSmart italic, JSSmart text, JSSmart x, JSSmart y, JSSmart bIsHeader) +JSSmart CGraphicsEmbed::DrawStringASCII (JSSmart text, JSSmart x, JSSmart y) { - m_pInternal->DrawStringASCII(); + m_pInternal->DrawStringASCII(text->toStringW(), x->toDouble(), y->toDouble()); return NULL; } JSSmart CGraphicsEmbed::DrawStringASCII2(JSSmart name, JSSmart size, JSSmart bold, JSSmart italic, JSSmart text, JSSmart x, JSSmart y, JSSmart bIsHeader) diff --git a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h index 566153d220..b7c6369f35 100644 --- a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h +++ b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h @@ -57,7 +57,7 @@ public: JSSmart font(JSSmart font_id, JSSmart font_size); JSSmart SetFont(JSSmart path, JSSmart face, JSSmart size, JSSmart style); JSSmart SetTextPr(JSSmart textPr, JSSmart theme); - JSSmart SetFontSlot(JSSmart path, JSSmart face, JSSmart size, JSSmart style); + JSSmart SetFontSlot(JSSmart slot, JSSmart fontSizeKoef); JSSmart GetTextPr(); JSSmart FillText(JSSmart x, JSSmart y, JSSmart text); JSSmart t(JSSmart x, JSSmart y, JSSmart _arr); @@ -72,7 +72,7 @@ public: JSSmart private_FillGlyph2(JSSmart pGlyph); JSSmart SetIntegerGrid(JSSmart param); JSSmart GetIntegerGrid(); - JSSmart DrawStringASCII (JSSmart name, JSSmart size, JSSmart bold, JSSmart italic, JSSmart text, JSSmart x, JSSmart y, JSSmart bIsHeader); + JSSmart DrawStringASCII (JSSmart text, JSSmart x, JSSmart y); JSSmart DrawStringASCII2(JSSmart name, JSSmart size, JSSmart bold, JSSmart italic, JSSmart text, JSSmart x, JSSmart y, JSSmart bIsHeader); JSSmart DrawHeaderEdit(JSSmart yPos, JSSmart lock_type, JSSmart sectionNum, JSSmart bIsRepeat, JSSmart type); JSSmart DrawFooterEdit(JSSmart yPos, JSSmart lock_type, JSSmart sectionNum, JSSmart bIsRepeat, JSSmart type); diff --git a/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp b/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp index 027fb376ce..4dde783d4d 100644 --- a/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp +++ b/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp @@ -46,7 +46,7 @@ namespace NSGraphics FUNCTION_WRAPPER_V8_2(_font, font) FUNCTION_WRAPPER_V8_4(_SetFont, SetFont) FUNCTION_WRAPPER_V8_2(_SetTextPr, SetTextPr) - FUNCTION_WRAPPER_V8_4(_SetFontSlot, SetFontSlot) + FUNCTION_WRAPPER_V8_2(_SetFontSlot, SetFontSlot) FUNCTION_WRAPPER_V8 (_GetTextPr, GetTextPr) FUNCTION_WRAPPER_V8_3(_FillText, FillText) FUNCTION_WRAPPER_V8_3(_t, t) @@ -61,7 +61,7 @@ namespace NSGraphics FUNCTION_WRAPPER_V8_1(_private_FillGlyph2, private_FillGlyph2) FUNCTION_WRAPPER_V8_1(_SetIntegerGrid, SetIntegerGrid) FUNCTION_WRAPPER_V8 (_GetIntegerGrid, GetIntegerGrid) - FUNCTION_WRAPPER_V8_8(_DrawStringASCII, DrawStringASCII) + FUNCTION_WRAPPER_V8_3(_DrawStringASCII, DrawStringASCII) FUNCTION_WRAPPER_V8_8(_DrawStringASCII2, DrawStringASCII2) FUNCTION_WRAPPER_V8_5(_DrawHeaderEdit, DrawHeaderEdit) FUNCTION_WRAPPER_V8_5(_DrawFooterEdit, DrawFooterEdit) diff --git a/DesktopEditor/doctrenderer/graphics.cpp b/DesktopEditor/doctrenderer/graphics.cpp index 008ab15738..481f71eca3 100644 --- a/DesktopEditor/doctrenderer/graphics.cpp +++ b/DesktopEditor/doctrenderer/graphics.cpp @@ -227,6 +227,15 @@ bool CGraphics::GetIntegerGrid() { return m_pRenderer->get_IntegerGrid(); } +void CGraphics::DrawStringASCII(const std::wstring& text, double x, double y) +{ + b_color1(225, 225, 225, 255); + m_pRenderer->GetFontManager()->LoadString2(text, x, y); + TBBox oBox = m_pRenderer->GetFontManager()->MeasureString2(); + rect(x, y, oBox.fMaxX, oBox.fMaxY); + df(); + ds(); +} void CGraphics::DrawHeaderEdit(double yPos) { m_pRenderer->PathCommandEnd(); @@ -645,7 +654,6 @@ void CGraphics::AddClipRect(double x, double y, double w, double h) EndClipPath(); } - void CGraphics::drawCollaborativeChanges(double x, double y, double w, double h, int r, int g, int b, int a) { b_color1(r, g, b, a); @@ -653,7 +661,6 @@ void CGraphics::drawCollaborativeChanges(double x, double y, double w, double h, df(); m_pRenderer->PathCommandEnd(); } - void CGraphics::drawMailMergeField(double x, double y, double w, double h) { b_color1(206, 212, 223, 204); @@ -661,7 +668,6 @@ void CGraphics::drawMailMergeField(double x, double y, double w, double h) df(); m_pRenderer->PathCommandEnd(); } - void CGraphics::drawSearchResult(double x, double y, double w, double h) { b_color1(255, 238, 128, 255); @@ -669,14 +675,12 @@ void CGraphics::drawSearchResult(double x, double y, double w, double h) df(); m_pRenderer->PathCommandEnd(); } - void CGraphics::SavePen() { CGrStatePen* pState = new CGrStatePen(); m_pRenderer->SavePen(pState->m_oPen); m_oGrState.States.push_back(pState); } - void CGraphics::RestorePen() { if (m_oGrState.States.empty()) @@ -690,14 +694,12 @@ void CGraphics::RestorePen() RELEASEOBJECT(pState); } } - void CGraphics::SaveBrush() { CGrStateBrush* pState = new CGrStateBrush(); m_pRenderer->SaveBrush(pState->m_oBrush); m_oGrState.States.push_back(pState); } - void CGraphics::RestoreBrush() { if (m_oGrState.States.empty()) @@ -711,7 +713,6 @@ void CGraphics::RestoreBrush() RELEASEOBJECT(pState); } } - void CGraphics::SavePenBrush() { CGrStatePenBrush* pState = new CGrStatePenBrush(); @@ -719,7 +720,6 @@ void CGraphics::SavePenBrush() m_pRenderer->SaveBrush(pState->m_oBrush); m_oGrState.States.push_back(pState); } - void CGraphics::RestorePenBrush() { if (m_oGrState.States.empty()) @@ -734,7 +734,6 @@ void CGraphics::RestorePenBrush() RELEASEOBJECT(pState); } } - void CGraphics::SaveGrState() { CGrStateState* pState = new CGrStateState(); @@ -748,7 +747,6 @@ void CGraphics::SaveGrState() m_oGrState.Clips.clear(); m_oGrState.States.push_back(pState); } - void CGraphics::RestoreGrState() { if (m_oGrState.States.empty()) @@ -810,22 +808,18 @@ void CGraphics::RestoreGrState() RELEASEOBJECT(pState); } - void CGraphics::StartClipPath() { m_pRenderer->BeginCommand(c_nClipType); } - void CGraphics::EndClipPath() { m_pRenderer->EndCommand(c_nClipType); } - void CGraphics::AddSmartRect(double x, double y, double w, double h, double pen_w) { m_pRenderer->AddRect(x, y, w, h); } - std::string CGraphics::toDataURL(std::wstring type) { m_oFrame.SaveFile(m_sApplicationImagesDirectory + L"/img." + type, _CXIMAGE_FORMAT_PNG); diff --git a/DesktopEditor/doctrenderer/graphics.h b/DesktopEditor/doctrenderer/graphics.h index e6414055e3..24e886df34 100644 --- a/DesktopEditor/doctrenderer/graphics.h +++ b/DesktopEditor/doctrenderer/graphics.h @@ -152,10 +152,10 @@ namespace NSGraphics void font() {} void SetFont(const std::wstring& name, int face, double size, int style); void SetTextPr() {} + void SetFontSlot() {} void GetTextPr() {} void FillText(double x, double y, int text); void t(double x, double y, const std::wstring& text); - void t2() {} void tg(int text, double x, double y); void charspace() {} // private methods @@ -164,7 +164,7 @@ namespace NSGraphics void private_FillGlyph2() {} void SetIntegerGrid(bool param); bool GetIntegerGrid(); - void DrawStringASCII() {} + void DrawStringASCII(const std::wstring& text, double x, double y); void DrawStringASCII2() {} void DrawHeaderEdit(double yPos); void DrawFooterEdit(double yPos); diff --git a/DesktopEditor/doctrenderer/js/NativeGraphics.js b/DesktopEditor/doctrenderer/js/NativeGraphics.js index 913d9fa652..16d6b0da17 100644 --- a/DesktopEditor/doctrenderer/js/NativeGraphics.js +++ b/DesktopEditor/doctrenderer/js/NativeGraphics.js @@ -220,231 +220,15 @@ CNativeGraphics.prototype = }, SetTextPr : function(textPr, theme) { - this.m_oTextPr = textPr; - if (theme) - this.m_oGrFonts.checkFromTheme(theme.themeElements.fontScheme, this.m_oTextPr.RFonts); - else - this.m_oGrFonts = this.m_oTextPr.RFonts; // this.Native["SetTextPr"](textPr, theme); }, SetFontSlot : function(slot, fontSizeKoef) { - var _rfonts = this.m_oGrFonts; - var _lastFont = this.IsUseFonts2 ? this.m_oLastFont2 : this.m_oLastFont; - - switch (slot) - { - case fontslot_ASCII: - { - _lastFont.Name = _rfonts.Ascii.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_CS: - { - _lastFont.Name = _rfonts.CS.Name; - _lastFont.Size = this.m_oTextPr.FontSizeCS; - _lastFont.Bold = this.m_oTextPr.BoldCS; - _lastFont.Italic = this.m_oTextPr.ItalicCS; - - break; - } - case fontslot_EastAsia: - { - _lastFont.Name = _rfonts.EastAsia.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - case fontslot_HAnsi: - default: - { - _lastFont.Name = _rfonts.HAnsi.Name; - _lastFont.Size = this.m_oTextPr.FontSize; - _lastFont.Bold = this.m_oTextPr.Bold; - _lastFont.Italic = this.m_oTextPr.Italic; - - break; - } - } - - if (undefined !== fontSizeKoef) - _lastFont.Size *= fontSizeKoef; - - var _style = 0; - if (_lastFont.Italic) - _style += 2; - if (_lastFont.Bold) - _style += 1; - - var _font_manager = this.IsUseFonts2 ? this.m_oFontManager2 : this.m_oFontManager; - - if (_lastFont.Name != _lastFont.SetUpName || _lastFont.Size != _lastFont.SetUpSize || _style != _lastFont.SetUpStyle || !_font_manager.m_pFont) - { - _lastFont.SetUpName = _lastFont.Name; - _lastFont.SetUpSize = _lastFont.Size; - _lastFont.SetUpStyle = _style; - - var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo); - - // подбираем шрифт по стилю - var bNeedBold = false; - var bNeedItalic = false; - var index = -1; - var faceIndex = 0; - var bSrcItalic = false; - var bSrcBold = false; - - switch (_lastFont.SetUpStyle) - { - case AscFonts.FontStyle.FontStyleBoldItalic: - { - bSrcItalic = true; - bSrcBold = true; - - bNeedBold = true; - bNeedItalic = true; - if (-1 != _fontinfo.indexBI) - { - index = _fontinfo.indexBI; - faceIndex = _fontinfo.faceIndexBI; - bNeedBold = false; - bNeedItalic = false; - } - else if (-1 != _fontinfo.indexB) - { - index = _fontinfo.indexB; - faceIndex = _fontinfo.faceIndexB; - bNeedBold = false; - } - else if (-1 != _fontinfo.indexI) - { - index = _fontinfo.indexI; - faceIndex = _fontinfo.faceIndexI; - bNeedItalic = false; - } - else - { - index = _fontinfo.indexR; - faceIndex = _fontinfo.faceIndexR; - } - break; - } - case AscFonts.FontStyle.FontStyleBold: - { - bSrcBold = true; - - bNeedBold = true; - bNeedItalic = false; - if (-1 != _fontinfo.indexB) - { - index = _fontinfo.indexB; - faceIndex = _fontinfo.faceIndexB; - bNeedBold = false; - } - else if (-1 != _fontinfo.indexR) - { - index = _fontinfo.indexR; - faceIndex = _fontinfo.faceIndexR; - } - else if (-1 != _fontinfo.indexBI) - { - index = _fontinfo.indexBI; - faceIndex = _fontinfo.faceIndexBI; - bNeedBold = false; - } - else - { - index = _fontinfo.indexI; - faceIndex = _fontinfo.faceIndexI; - } - break; - } - case AscFonts.FontStyle.FontStyleItalic: - { - bSrcItalic = true; - - bNeedBold = false; - bNeedItalic = true; - if (-1 != _fontinfo.indexI) - { - index = _fontinfo.indexI; - faceIndex = _fontinfo.faceIndexI; - bNeedItalic = false; - } - else if (-1 != _fontinfo.indexR) - { - index = _fontinfo.indexR; - faceIndex = _fontinfo.faceIndexR; - } - else if (-1 != _fontinfo.indexBI) - { - index = _fontinfo.indexBI; - faceIndex = _fontinfo.faceIndexBI; - bNeedItalic = false; - } - else - { - index = _fontinfo.indexB; - faceIndex = _fontinfo.faceIndexB; - } - break; - } - case AscFonts.FontStyle.FontStyleRegular: - { - bNeedBold = false; - bNeedItalic = false; - if (-1 != _fontinfo.indexR) - { - index = _fontinfo.indexR; - faceIndex = _fontinfo.faceIndexR; - } - else if (-1 != _fontinfo.indexI) - { - index = _fontinfo.indexI; - faceIndex = _fontinfo.faceIndexI; - } - else if (-1 != _fontinfo.indexB) - { - index = _fontinfo.indexB; - faceIndex = _fontinfo.faceIndexB; - } - else - { - index = _fontinfo.indexBI; - faceIndex = _fontinfo.faceIndexBI; - } - } - } - - var _info = - { - Path : AscFonts.g_font_files[index].Id, - FaceIndex : faceIndex, - NeedBold : bNeedBold, - NeedItalic : bNeedItalic, - SrcBold : bSrcBold, - SrcItalic : bSrcItalic - }; - - var flag = 0; - if (_info.NeedBold) flag |= 0x01; - if (_info.NeedItalic) flag |= 0x02; - if (_info.SrcBold) flag |= 0x04; - if (_info.SrcItalic) flag |= 0x08; - - this.Native["SetFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag); - } + // this.Native["SetFontSlot"](slot, fontSizeKoef); }, GetTextPr : function() { - // this.Native["GetTextPr"](); - return this.m_oTextPr; + // return this.Native["GetTextPr"](); }, FillText : function(x, y, text) { @@ -458,26 +242,16 @@ CNativeGraphics.prototype = FillText2 : function(x, y, text, cropX, cropW) { var _code = text.charCodeAt(0); - if (null != this.LastFontOriginInfo.Replace) - _code = AscFonts.g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace); - this.Native["FillText2"](x, y, _code, cropX, cropW); }, t2 : function(text, x, y, cropX, cropW) { - var _arr = []; - var _len = text.length; - for (var i = 0; i < _len; i++) - _arr.push(text.charCodeAt(i)); - - this.Native["t2"](x, y, _arr, cropX, cropW); + this.Native["t2"](x, y, text, cropX, cropW); }, FillTextCode : function(x, y, lUnicode) { - if (null != this.LastFontOriginInfo.Replace) - lUnicode = AscFonts.g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace); - - this.Native["FillTextCode"](x, y, lUnicode); + var _code = lUnicode.charCodeAt(0); + this.Native["FillTextCode"](x, y, _code); }, tg : function(text, x, y) { @@ -491,191 +265,28 @@ CNativeGraphics.prototype = // private methods private_FillGlyph : function(pGlyph, _bounds) { - // new scheme - var nW = pGlyph.oBitmap.nWidth; - var nH = pGlyph.oBitmap.nHeight; - - if (0 == nW || 0 == nH) - return; - - var _font_manager = this.IsUseFonts2 ? this.m_oFontManager2 : this.m_oFontManager; - - var nX = (_font_manager.m_oGlyphString.m_fX >> 0) + (pGlyph.fX + pGlyph.oBitmap.nX) >> 0; - var nY = (_font_manager.m_oGlyphString.m_fY >> 0) + (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); - - 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); - - if (_bounds) - { - var _r = nX + pGlyph.oBitmap.nWidth; - var _b = nY + pGlyph.oBitmap.nHeight; - if (_bounds.x > nX) - _bounds.x = nX; - if (_bounds.y > nY) - _bounds.y = nY; - if (_bounds.r < _r) - _bounds.r = _r; - if (_bounds.b < _b) - _bounds.b = _b; - } - - this.Native["private_FillGlyph"](pGlyph, _bounds); + // this.Native["private_FillGlyph"](pGlyph, _bounds); }, private_FillGlyphC : function(pGlyph, cropX, cropW) { - // new scheme - var nW = pGlyph.oBitmap.nWidth; - var nH = pGlyph.oBitmap.nHeight; - - if (0 == nW || 0 == nH) - return; - - var _font_manager = this.IsUseFonts2 ? this.m_oFontManager2 : this.m_oFontManager; - - var nX = (_font_manager.m_oGlyphString.m_fX + pGlyph.fX + pGlyph.oBitmap.nX) >> 0; - var nY = (_font_manager.m_oGlyphString.m_fY + pGlyph.fY - pGlyph.oBitmap.nY) >> 0; - - var d_koef = this.m_dDpiX / 25.4; - - var cX = Math.max((cropX * d_koef) >> 0, 0); - var cW = Math.min((cropW * d_koef) >> 0, nW); - if (cW <= 0) - cW = 1; - - pGlyph.oBitmap.oGlyphData.checkColor(this.m_oBrush.Color1.R, this.m_oBrush.Color1.G, this.m_oBrush.Color1.B, nW, nH); - pGlyph.oBitmap.drawCrop(this.m_oContext, nX, nY, cW, nH, cX); - - this.Native["private_FillGlyphC"](pGlyph, cropX, cropW); + // this.Native["private_FillGlyphC"](pGlyph, cropX, cropW); }, private_FillGlyph2 : function(pGlyph) { - var i = 0; - var j = 0; - - var nW = pGlyph.oBitmap.nWidth; - var nH = pGlyph.oBitmap.nHeight; - - if (0 == nW || 0 == nH) - return; - - var _font_manager = this.IsUseFonts2 ? this.m_oFontManager2 : this.m_oFontManager; - - var nX = (_font_manager.m_oGlyphString.m_fX + pGlyph.fX + pGlyph.oBitmap.nX) >> 0; - var nY = (_font_manager.m_oGlyphString.m_fY + pGlyph.fY - pGlyph.oBitmap.nY) >> 0; - - var imageData = this.m_oContext.getImageData(nX, nY, nW, nH); - var pPixels = imageData.data; - - var _r = this.m_oBrush.Color1.R; - var _g = this.m_oBrush.Color1.G; - var _b = this.m_oBrush.Color1.B; - - for (; j < nH; ++j) - { - var indx = 4 * j * nW; - for (i = 0; i < nW; ++i) - { - var weight = pGlyph.oBitmap.pData[j * pGlyph.oBitmap.nWidth + i]; - - if (255 == weight) - { - pPixels[indx] = _r; - pPixels[indx + 1] = _g; - pPixels[indx + 2] = _b; - pPixels[indx + 3] = 255; - } - else - { - var r = pPixels[indx]; - var g = pPixels[indx + 1]; - var b = pPixels[indx + 2]; - var a = pPixels[indx + 3]; - - pPixels[indx] = ((_r - r) * weight + (r << 8)) >>> 8; - pPixels[indx + 1] = ((_g - g) * weight + (g << 8)) >>> 8; - pPixels[indx + 2] = ((_b - b) * weight + (b << 8)) >>> 8; - pPixels[indx + 3] = (weight + a) - ((weight * a + 256) >>> 8); - } - - indx += 4; - } - } - this.m_oContext.putImageData(imageData, nX, nY); - - this.Native["private_FillGlyph2"](pGlyph); + // this.Native["private_FillGlyph2"](pGlyph); }, SetIntegerGrid : function(param) { - this.m_bIntegerGrid = param; this.Native["SetIntegerGrid"](param); }, GetIntegerGrid : function() { - // this.Native["GetIntegerGrid"](); - return this.m_bIntegerGrid; + return this.Native["GetIntegerGrid"](); }, DrawStringASCII : function(name, size, bold, italic, text, x, y, bIsHeader) { - var _textProp = { - RFonts : { Ascii : { Name : name, Index : -1 } }, - FontSize : (((size * 2 * 96 / this.m_dDpiY) + 0.5) >> 0) / 2, - Bold : false, - Italic : false - }; - - this.m_oTextPr = _textProp; - this.m_oGrFonts.Ascii.Name = this.m_oTextPr.RFonts.Ascii.Name; - this.m_oGrFonts.Ascii.Index = -1; - - this.SetFontSlot(fontslot_ASCII, 1); - - this.m_oFontManager.LoadString2(text, 0, 0); - var measure = this.m_oFontManager.MeasureString2(); - - var _ctx = this.m_oContext; - _ctx.beginPath(); - _ctx.fillStyle = "#E1E1E1"; - _ctx.strokeStyle = GlobalSkin.RulerOutline; - this.m_bBrushColorInit = false; - this.m_bPenColorInit = false; - - var _xPxOffset = 10; - var _yPxOffset = 5; - if (AscCommon.AscBrowser.isRetina) - { - _xPxOffset = (_xPxOffset * AscCommon.AscBrowser.retinaPixelRatio) >> 0; - _yPxOffset = (_yPxOffset * AscCommon.AscBrowser.retinaPixelRatio) >> 0; - } - - var __x = this.m_oFullTransform.TransformPointX(x, y) >> 0; - var __y = this.m_oFullTransform.TransformPointY(x, y) >> 0; - var __w = (measure.fWidth >> 0) + 2 * _xPxOffset; - var __h = (Math.abs(measure.fY) >> 0) + 2 * _yPxOffset; - - if (!bIsHeader) - __y -= __h; - - if (!AscCommon.AscBrowser.isRetina) - _ctx.rect(__x + 0.5, __y + 0.5, __w, __h); - else - _ctx.rect(__x, __y, __w, __h); - - _ctx.fill(); - _ctx.stroke(); - _ctx.beginPath(); - - this.b_color1(68, 68, 68, 255); - - var _koef_px_to_mm = 25.4 / this.m_dDpiY; - - this.t(text, x + _xPxOffset * _koef_px_to_mm, y + ((bIsHeader ? __h : 0) - _yPxOffset) * _koef_px_to_mm); - - this.Native["DrawStringASCII"](name, size, bold, italic, text, x, y, bIsHeader); + this.SetFont({FontFamily : {Name : name, Index : -1}, FontSize : size, Italic : italic, Bold : bold}); + this.Native["DrawStringASCII"](text, x, y); }, DrawStringASCII2 : function(name, size, bold, italic, text, x, y, bIsHeader) { @@ -752,9 +363,6 @@ CNativeGraphics.prototype = }, DrawLockObjectRect : function(lock_type, x, y, w, h) { - if (this.IsThumbnail || lock_type == AscCommon.locktype_None || this.IsDemonstrationMode) - return; - this.Native["DrawLockObjectRect"](lock_type, x, y, w, h); }, DrawEmptyTableLine : function(x1, y1, x2, y2) diff --git a/DesktopEditor/doctrenderer/js/test.js b/DesktopEditor/doctrenderer/js/test.js index 528a940f48..bc03e8bd7f 100644 --- a/DesktopEditor/doctrenderer/js/test.js +++ b/DesktopEditor/doctrenderer/js/test.js @@ -73,6 +73,9 @@ MyGraphics.transform3({ sx : 1, shy : 0.5, shx : 0.1, sy : 1, tx : 0, ty : 0 }, // Рисуем изображение из файла MyGraphics.drawImage2("image1.png", 95, 76, 60, 48, 0, null); +MyGraphics.reset(); +MyGraphics.DrawStringASCII("Times New Roman", 16, false, false, "Test TEXT", 10, 210, false); + var imageBase64 = MyGraphics.toDataURL("png"); MyGraphics.save(); MyGraphics.GetFont();