Commit b06b7208 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander.Trofimov

реализован механизм подмены глифов

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61000 954022d7-b5bf-4e40-9824-e11837661b57
parent b8c4220a
......@@ -263,13 +263,22 @@ function FD_FontDictionary()
// шрифты в массиве this.FD_Ascii_Font_Like_Names - в порядке важности.
this.FD_Ascii_Font_Like_Names = [
["Cambria Math", "Asana Math", "XITS Math", "Latin Modern"]
["Cambria Math", "Asana Math", "XITS Math", "Latin Modern"],
["OpenSymbol"]
];
this.FD_Ascii_Font_Like_Main = {
"Cambria Math" : 0,
"Asana Math" : 0,
"XITS Math" : 0,
"Latin Modern" : 0
"Latin Modern" : 0,
"Symbol" : 1,
"Wingdings" : 1
};
this.ChangeGlyphsMap = {
"Symbol" : { Name : "OpenSymbol", IsSymbolSrc : true, MapSrc : [0xB7, 0xA8], MapDst : [0xE12C, 0xE442] },
"Wingdings" : { Name : "OpenSymbol", IsSymbolSrc : true, MapSrc : [0x76, 0xD8, 0xA7, 0xFC, 0x71], MapDst : [0xE441, 0xE25F, 0xE46F, 0xE330, 0x2751] }
};
}
......@@ -2696,16 +2705,49 @@ function CApplicationFonts()
this.DefaultIndex = this.g_fontDictionary.GetFontIndex(oSelect, this.g_fontSelections.List, undefined);
};
this.LoadFont = function(name, font_loader, fontManager, fEmSize, lStyle, dHorDpi, dVerDpi, transform)
this.LoadFont = function(name, font_loader, fontManager, fEmSize, lStyle, dHorDpi, dVerDpi, transform, objDst)
{
var _font = this.GetFontFileWeb(name, lStyle);
var font_name_index = window.g_map_font_index[_font.m_wsFontName];
if (undefined !== objDst)
{
objDst.Name = _font.m_wsFontName;
objDst.Replace = this.CheckReplaceGlyphsMap(name, objDst.Name);
}
// используем стиль, пришедший извне, а не стиль _font
// так как подвираем вез стиля в Web версии
return window.g_font_infos[font_name_index].LoadFont(window.g_font_loader, fontManager, fEmSize, /*_font.GetStyle()*/lStyle, dHorDpi, dVerDpi, transform);
};
this.CheckReplaceGlyphsMap = function(name, objDst)
{
var _replaceInfo = this.g_fontDictionary.ChangeGlyphsMap[name];
if (!_replaceInfo)
return null;
if (_replaceInfo.Name != objDst.Name)
return null;
return _replaceInfo;
};
this.GetReplaceGlyph = function(src, objDst)
{
// TODO: must be faster!!!
var _arr = objDst.MapSrc;
var _arrLen = _arr.length;
for (var i = 0; i < _arrLen; i++)
{
if (_arr[i] == src)
return objDst.MapDst[i];
if (objDst.IsSymbolSrc && (src == (0xF000 + _arr[i])))
{
return objDst.MapDst[i];
}
}
};
this.GetFontFile = function(name, lStyle)
{
if (lStyle === undefined)
......@@ -2749,15 +2791,29 @@ function CApplicationFonts()
}
};
this.GetFontInfo = function(name, lStyle)
this.GetFontInfo = function(name, lStyle, objDst)
{
var _font = this.GetFontFileWeb(name, lStyle);
var font_name_index = window.g_map_font_index[_font.m_wsFontName];
if (undefined !== objDst)
{
objDst.Name = _font.m_wsFontName;
objDst.Replace = this.CheckReplaceGlyphsMap(name, objDst.Name);
}
return window.g_font_infos[font_name_index];
};
this.GetFontInfoName = function(name)
this.GetFontInfoName = function(name, objDst)
{
var _font = this.GetFontFileWeb(name);
if (undefined !== objDst)
{
objDst.Name = _font.m_wsFontName;
objDst.Replace = this.CheckReplaceGlyphsMap(name, objDst.Name);
}
return _font.m_wsFontName;
};
......
......@@ -149,6 +149,7 @@ function CTextMeasurer()
// RFonts
this.m_oTextPr = null;
this.m_oLastFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null };
this.Init = function()
{
......@@ -180,7 +181,7 @@ function CTextMeasurer()
_lastSetUp.SetUpSize = font.FontSize;
_lastSetUp.SetUpStyle = oFontStyle;
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72);
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
}
}
......@@ -264,7 +265,7 @@ function CTextMeasurer()
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72);
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
}
}
......@@ -283,7 +284,11 @@ function CTextMeasurer()
var Width = 0;
var Height = 0;
var Temp = this.m_oManager.MeasureChar( text.charCodeAt(0) );
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( _code);
Width = Temp.fAdvanceX * 25.4 / 72;
Height = 0;//Temp.fHeight;
......@@ -294,7 +299,11 @@ function CTextMeasurer()
{
var Width = 0;
var Temp = this.m_oManager.MeasureChar( text.charCodeAt(0) );
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( _code );
Width = Temp.fAdvanceX * 25.4 / 72;
......@@ -307,6 +316,9 @@ function CTextMeasurer()
var Width = 0;
var Height = 0;
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( lUnicode );
Width = Temp.fAdvanceX * 25.4 / 72;
......@@ -318,6 +330,9 @@ function CTextMeasurer()
{
var Width = 0;
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( lUnicode );
Width = Temp.fAdvanceX * 25.4 / 72;
......
......@@ -491,6 +491,8 @@ function CGraphics()
this.m_oGrFonts = new CGrRFonts();
this.m_oLastFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null };
this.m_bIntegerGrid = true;
this.ClipManager = new CClipManager();
......@@ -1165,7 +1167,7 @@ CGraphics.prototype =
_last_font.SetUpSize = font.FontSize;
_last_font.SetUpStyle = oFontStyle;
g_fontApplication.LoadFont(_last_font.SetUpName, window.g_font_loader, _font_manager, font.FontSize, oFontStyle, this.m_dDpiX, this.m_dDpiY, this.m_oTransform);
g_fontApplication.LoadFont(_last_font.SetUpName, window.g_font_loader, _font_manager, font.FontSize, oFontStyle, this.m_dDpiX, this.m_dDpiY, this.m_oTransform, this.LastFontOriginInfo);
var _mD = _last_font.SetUpMatrix;
var _mS = this.m_oTransform;
......@@ -1255,7 +1257,7 @@ CGraphics.prototype =
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, _font_manager, _lastFont.SetUpSize, _lastFont.SetUpStyle, this.m_dDpiX, this.m_dDpiY, this.m_oTransform);
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, _font_manager, _lastFont.SetUpSize, _lastFont.SetUpStyle, this.m_dDpiX, this.m_dDpiY, this.m_oTransform, this.LastFontOriginInfo);
var _mD = _lastFont.SetUpMatrix;
var _mS = this.m_oTransform;
......@@ -1306,7 +1308,12 @@ CGraphics.prototype =
try
{
_font_manager.LoadString2C(text,_x,_y);
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
_font_manager.LoadString4C(_code,_x,_y);
}
catch(err)
{
......@@ -1379,7 +1386,12 @@ CGraphics.prototype =
try
{
_font_manager.LoadString2C(text,_x,_y);
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
_font_manager.LoadString4C(_code,_x,_y);
}
catch(err)
{
......@@ -1450,6 +1462,9 @@ CGraphics.prototype =
try
{
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
_font_manager.LoadString4C(lUnicode,_x,_y);
}
catch(err)
......
......@@ -305,6 +305,8 @@ function CTextMeasurer()
this.m_oGrFonts = new CGrRFonts();
this.m_oLastFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null };
this.Init = function()
{
this.m_oManager.Initialize();
......@@ -335,7 +337,7 @@ function CTextMeasurer()
_lastSetUp.SetUpSize = font.FontSize;
_lastSetUp.SetUpStyle = oFontStyle;
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72);
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
}
}
......@@ -419,7 +421,7 @@ function CTextMeasurer()
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72);
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
}
}
......@@ -438,7 +440,11 @@ function CTextMeasurer()
var Width = 0;
var Height = 0;
var Temp = this.m_oManager.MeasureChar( text.charCodeAt(0) );
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( _code );
Width = Temp.fAdvanceX * 25.4 / 72;
Height = 0;//Temp.fHeight;
......@@ -449,7 +455,11 @@ function CTextMeasurer()
{
var Width = 0;
var Temp = this.m_oManager.MeasureChar( text.charCodeAt(0), true );
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( _code, true );
Width = Temp.fAdvanceX * 25.4 / 72;
......@@ -480,6 +490,9 @@ function CTextMeasurer()
var Width = 0;
var Height = 0;
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( lUnicode );
Width = Temp.fAdvanceX * 25.4 / 72;
......@@ -491,6 +504,9 @@ function CTextMeasurer()
{
var Width = 0;
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( lUnicode, true );
Width = Temp.fAdvanceX * 25.4 / 72;
......
......@@ -148,6 +148,8 @@ function CTextMeasurer()
this.m_oGrFonts = new CGrRFonts();
this.m_oLastFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null };
this.Init = function()
{
this.m_oManager.Initialize();
......@@ -183,7 +185,7 @@ function CTextMeasurer()
_lastSetUp.SetUpSize = font.FontSize;
_lastSetUp.SetUpStyle = oFontStyle;
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72);
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
}
};
......@@ -265,7 +267,7 @@ function CTextMeasurer()
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72);
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
}
};
......@@ -284,7 +286,11 @@ function CTextMeasurer()
var Width = 0;
var Height = 0;
var Temp = this.m_oManager.MeasureChar( text.charCodeAt(0) );
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( _code );
Width = Temp.fAdvanceX * 25.4 / 72;
Height = 0;//Temp.fHeight;
......@@ -295,7 +301,11 @@ function CTextMeasurer()
{
var Width = 0;
var Temp = this.m_oManager.MeasureChar( text.charCodeAt(0), true );
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( _code, true );
Width = Temp.fAdvanceX * 25.4 / 72;
......@@ -326,6 +336,9 @@ function CTextMeasurer()
var Width = 0;
var Height = 0;
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( lUnicode );
Width = Temp.fAdvanceX * 25.4 / 72;
......@@ -337,6 +350,9 @@ function CTextMeasurer()
{
var Width = 0;
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
var Temp = this.m_oManager.MeasureChar( lUnicode, true );
Width = Temp.fAdvanceX * 25.4 / 72;
......
......@@ -460,7 +460,7 @@ function CGraphics()
this.m_lWidthPix = 0;
this.m_lHeightPix = 0;
this.m_dDpiX = 96.0;
this.m_dDpiY = 96.0;
this.m_dDpiY = 96.0;
this.m_bIsBreak = false;
this.textBB_l = 10000;
......@@ -495,6 +495,8 @@ function CGraphics()
this.m_oGrFonts = new CGrRFonts();
this.m_oLastFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null };
this.m_bIntegerGrid = true;
this.ClipManager = new CClipManager();
......@@ -651,7 +653,7 @@ CGraphics.prototype =
_c.A = a;
this.m_oContext.fillStyle = "rgba(" + _c.R + "," + _c.G + "," + _c.B + "," + (_c.A / 255) + ")";
this.m_bIsFillTextCanvasColor = 0;
},
b_color2 : function(r,g,b,a)
......@@ -1191,7 +1193,7 @@ CGraphics.prototype =
_last_font.SetUpSize = font.FontSize;
_last_font.SetUpStyle = oFontStyle;
g_fontApplication.LoadFont(_last_font.SetUpName, window.g_font_loader, _font_manager, font.FontSize, oFontStyle, this.m_dDpiX, this.m_dDpiY, this.m_oTransform);
g_fontApplication.LoadFont(_last_font.SetUpName, window.g_font_loader, _font_manager, font.FontSize, oFontStyle, this.m_dDpiX, this.m_dDpiY, this.m_oTransform, this.LastFontOriginInfo);
var _mD = _last_font.SetUpMatrix;
var _mS = this.m_oTransform;
......@@ -1279,7 +1281,7 @@ CGraphics.prototype =
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, _font_manager, _lastFont.SetUpSize, _lastFont.SetUpStyle, this.m_dDpiX, this.m_dDpiY, this.m_oTransform);
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, _font_manager, _lastFont.SetUpSize, _lastFont.SetUpStyle, this.m_dDpiX, this.m_dDpiY, this.m_oTransform, this.LastFontOriginInfo);
var _mD = _lastFont.SetUpMatrix;
var _mS = this.m_oTransform;
......@@ -1330,7 +1332,12 @@ CGraphics.prototype =
try
{
_font_manager.LoadString2C(text,_x,_y);
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
_font_manager.LoadString4C(_code,_x,_y);
}
catch(err)
{
......@@ -1403,7 +1410,12 @@ CGraphics.prototype =
try
{
_font_manager.LoadString2C(text,_x,_y);
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
_font_manager.LoadString4C(_code,_x,_y);
}
catch(err)
{
......@@ -1474,6 +1486,9 @@ CGraphics.prototype =
try
{
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
_font_manager.LoadString4C(lUnicode,_x,_y);
}
catch(err)
......@@ -1610,7 +1625,7 @@ CGraphics.prototype =
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;
......
......@@ -845,6 +845,7 @@ function CMetafile(width, height)
// просто чтобы не создавать каждый раз
this.m_oFontSlotFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null };
}
CMetafile.prototype =
......@@ -1247,7 +1248,7 @@ CMetafile.prototype =
if (font.Bold == true)
style += 1;
var fontinfo = g_fontApplication.GetFontInfo(font.FontFamily.Name, style);
var fontinfo = g_fontApplication.GetFontInfo(font.FontFamily.Name, style, this.LastFontOriginInfo);
style = fontinfo.GetBaseStyle(style);
if (this.m_oFont.Name != fontinfo.Name)
......@@ -1272,6 +1273,14 @@ CMetafile.prototype =
FillText : function(x,y,text)
{
this.Memory.WriteByte(CommandType.ctDrawText);
if (null != this.LastFontOriginInfo.Replace && 1 == text.length)
{
var _code = text.charCodeAt(0);
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
text = String.fromCharCode(_code);
}
this.Memory.WriteString(text);
this.Memory.WriteDouble(x);
this.Memory.WriteDouble(y);
......@@ -1287,6 +1296,12 @@ CMetafile.prototype =
var _old_pos = this.Memory.pos;
g_fontApplication.LoadFont(_font_info.Name, window.g_font_loader, g_oTextMeasurer.m_oManager, this.m_oFont.FontSize, Math.max(this.m_oFont.Style, 0), 72, 72);
if (null != this.LastFontOriginInfo.Replace)
{
code = g_fontApplication.GetReplaceGlyph(code, this.LastFontOriginInfo.Replace);
}
g_oTextMeasurer.m_oManager.LoadStringPathCode(code, false, x, y, this);
// start (1) + draw(1) + typedraw(4) + end(1) = 7!
......@@ -1422,7 +1437,7 @@ CMetafile.prototype =
if (_lastFont.Bold == true)
style += 1;
var fontinfo = g_fontApplication.GetFontInfo(_lastFont.Name, style);
var fontinfo = g_fontApplication.GetFontInfo(_lastFont.Name, style, this.LastFontOriginInfo);
style = fontinfo.GetBaseStyle();
if (this.m_oFont.Name != fontinfo.Name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment