Commit 65324480 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@61020 954022d7-b5bf-4e40-9824-e11837661b57
parent b808093b
......@@ -508,6 +508,8 @@ function CDrawingStream(_writer)
this.m_oGrFonts = new CGrRFonts();
this.m_oLastFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null };
this.IsUseFonts2 = false;
this.m_oLastFont2 = null;
......@@ -671,12 +673,6 @@ CDrawingStream.prototype =
Italic : font.Italic
};
if (-1 == font.FontFamily.Index || undefined === font.FontFamily.Index || null == font.FontFamily.Index)
font.FontFamily.Index = window.g_map_font_index[font.FontFamily.Name];
if (font.FontFamily.Index == undefined || font.FontFamily.Index == -1)
return;
var bItalic = true === font.Italic;
var bBold = true === font.Bold;
......@@ -688,7 +684,9 @@ CDrawingStream.prototype =
else if ( bItalic && bBold )
oFontStyle = FontStyle.FontStyleBoldItalic;
var _info = GetLoadInfoForMeasurer(window.g_font_infos[font.FontFamily.Index], oFontStyle);
var _fontinfo = g_fontApplication.GetFontInfo(font.FontFamily.Name, oFontStyle, this.LastFontOriginInfo);
var _info = GetLoadInfoForMeasurer(_fontinfo, oFontStyle);
var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
......@@ -721,13 +719,6 @@ CDrawingStream.prototype =
case fontslot_ASCII:
{
_lastFont.Name = _rfonts.Ascii.Name;
_lastFont.Index = _rfonts.Ascii.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.Name];
}
_lastFont.Size = this.m_oTextPr.FontSize;
_lastFont.Bold = this.m_oTextPr.Bold;
_lastFont.Italic = this.m_oTextPr.Italic;
......@@ -737,13 +728,6 @@ CDrawingStream.prototype =
case fontslot_CS:
{
_lastFont.Name = _rfonts.CS.Name;
_lastFont.Index = _rfonts.CS.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.Name];
}
_lastFont.Size = this.m_oTextPr.FontSizeCS;
_lastFont.Bold = this.m_oTextPr.BoldCS;
_lastFont.Italic = this.m_oTextPr.ItalicCS;
......@@ -753,13 +737,6 @@ CDrawingStream.prototype =
case fontslot_EastAsia:
{
_lastFont.Name = _rfonts.EastAsia.Name;
_lastFont.Index = _rfonts.EastAsia.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.Name];
}
_lastFont.Size = this.m_oTextPr.FontSize;
_lastFont.Bold = this.m_oTextPr.Bold;
_lastFont.Italic = this.m_oTextPr.Italic;
......@@ -770,13 +747,6 @@ CDrawingStream.prototype =
default:
{
_lastFont.Name = _rfonts.HAnsi.Name;
_lastFont.Index = _rfonts.HAnsi.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.Name];
}
_lastFont.Size = this.m_oTextPr.FontSize;
_lastFont.Bold = this.m_oTextPr.Bold;
_lastFont.Italic = this.m_oTextPr.Italic;
......@@ -794,13 +764,15 @@ CDrawingStream.prototype =
if (_lastFont.Bold)
_style += 1;
if (_lastFont.Index != _lastFont.SetUpIndex || _lastFont.Size != _lastFont.SetUpSize || _style != _lastFont.SetUpStyle)
if (_lastFont.Name != _lastFont.SetUpName || _lastFont.Size != _lastFont.SetUpSize || _style != _lastFont.SetUpStyle)
{
_lastFont.SetUpIndex = _lastFont.Index;
_lastFont.SetUpName = _lastFont.Name;
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
var _info = GetLoadInfoForMeasurer(window.g_font_infos[_lastFont.SetUpIndex], _style);
var _fontinfo = g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo);
var _info = GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle);
var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
......@@ -813,7 +785,11 @@ CDrawingStream.prototype =
FillText : function(x,y,text)
{
this.Native["PD_FillText"](x,y,text.charCodeAt(0));
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
this.Native["PD_FillText"](x,y,_code);
},
t : function(text,x,y)
{
......@@ -825,7 +801,11 @@ CDrawingStream.prototype =
},
FillText2 : function(x,y,text,cropX,cropW)
{
this.Native["PD_FillText2"](x,y,text.charCodeAt(0),cropX,cropW);
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
this.Native["PD_FillText2"](x,y,_code,cropX,cropW);
},
t2 : function(text,x,y,cropX,cropW)
{
......@@ -837,6 +817,9 @@ CDrawingStream.prototype =
},
FillTextCode : function(x,y,lUnicode)
{
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
this.Native["PD_FillText"](x,y,lUnicode);
},
......
......@@ -9,6 +9,8 @@
this.m_oGrFonts = new CGrRFonts();
this.m_oLastFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null };
// font params
this.Ascender = 0;
this.Descender = 0;
......@@ -30,12 +32,6 @@ CTextMeasurerWrapper.prototype =
this.m_oFont = font;
if (-1 == font.FontFamily.Index || undefined === font.FontFamily.Index || null == font.FontFamily.Index)
font.FontFamily.Index = window.g_map_font_index[font.FontFamily.Name];
if (font.FontFamily.Index == undefined || font.FontFamily.Index == -1)
return;
var bItalic = true === font.Italic;
var bBold = true === font.Bold;
......@@ -48,13 +44,15 @@ CTextMeasurerWrapper.prototype =
oFontStyle = FontStyle.FontStyleBoldItalic;
var _lastSetUp = this.m_oLastFont;
if (_lastSetUp.SetUpIndex != font.FontFamily.Index || _lastSetUp.SetUpSize != font.FontSize || _lastSetUp.SetUpStyle != oFontStyle)
if (_lastSetUp.SetUpName != font.FontFamily.Name || _lastSetUp.SetUpSize != font.FontSize || _lastSetUp.SetUpStyle != oFontStyle)
{
_lastSetUp.SetUpIndex = font.FontFamily.Index;
_lastSetUp.SetUpName = font.FontFamily.Name;
_lastSetUp.SetUpSize = font.FontSize;
_lastSetUp.SetUpStyle = oFontStyle;
var _info = GetLoadInfoForMeasurer(window.g_font_infos[_lastSetUp.SetUpIndex], _lastSetUp.SetUpStyle);
var _fontinfo = g_fontApplication.GetFontInfo(_lastSetUp.SetUpName, _lastSetUp.SetUpStyle, this.LastFontOriginInfo);
var _info = GetLoadInfoForMeasurer(_fontinfo, _lastSetUp.SetUpStyle);
var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
......@@ -90,13 +88,6 @@ CTextMeasurerWrapper.prototype =
case fontslot_ASCII:
{
_lastFont.Name = _rfonts.Ascii.Name;
_lastFont.Index = _rfonts.Ascii.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.Name];
}
_lastFont.Size = this.m_oTextPr.FontSize;
_lastFont.Bold = this.m_oTextPr.Bold;
_lastFont.Italic = this.m_oTextPr.Italic;
......@@ -106,13 +97,6 @@ CTextMeasurerWrapper.prototype =
case fontslot_CS:
{
_lastFont.Name = _rfonts.CS.Name;
_lastFont.Index = _rfonts.CS.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.Name];
}
_lastFont.Size = this.m_oTextPr.FontSizeCS;
_lastFont.Bold = this.m_oTextPr.BoldCS;
_lastFont.Italic = this.m_oTextPr.ItalicCS;
......@@ -123,12 +107,6 @@ CTextMeasurerWrapper.prototype =
{
_lastFont.Name = _rfonts.EastAsia.Name;
_lastFont.Index = _rfonts.EastAsia.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.Name];
}
_lastFont.Size = this.m_oTextPr.FontSize;
_lastFont.Bold = this.m_oTextPr.Bold;
_lastFont.Italic = this.m_oTextPr.Italic;
......@@ -140,12 +118,6 @@ CTextMeasurerWrapper.prototype =
{
_lastFont.Name = _rfonts.HAnsi.Name;
_lastFont.Index = _rfonts.HAnsi.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.Name];
}
_lastFont.Size = this.m_oTextPr.FontSize;
_lastFont.Bold = this.m_oTextPr.Bold;
_lastFont.Italic = this.m_oTextPr.Italic;
......@@ -163,13 +135,15 @@ CTextMeasurerWrapper.prototype =
if (_lastFont.Bold)
_style += 1;
if (_lastFont.Index != _lastFont.SetUpIndex || _lastFont.Size != _lastFont.SetUpSize || _style != _lastFont.SetUpStyle)
if (_lastFont.Name != _lastFont.SetUpName || _lastFont.Size != _lastFont.SetUpSize || _style != _lastFont.SetUpStyle)
{
_lastFont.SetUpIndex = _lastFont.Index;
_lastFont.SetUpName = _lastFont.Name;
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
var _info = GetLoadInfoForMeasurer(window.g_font_infos[_lastFont.SetUpIndex], _lastFont.SetUpStyle);
var _fontinfo = g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo);
var _info = GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle);
var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
......@@ -198,25 +172,37 @@ CTextMeasurerWrapper.prototype =
Measure : function(text)
{
var _width = this.Measurer["MeasureChar"](text.charCodeAt(0));
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
var _width = this.Measurer["MeasureChar"](_code);
return { Width : _width, Height : 0 };
},
Measure2 : function(text)
{
var _bounds = this.Measurer["GetDrawingBox"](text.charCodeAt(0));
var _code = text.charCodeAt(0);
if (null != this.LastFontOriginInfo.Replace)
_code = g_fontApplication.GetReplaceGlyph(_code, this.LastFontOriginInfo.Replace);
var _bounds = this.Measurer["GetDrawingBox"](_code);
return { Width : _bounds[0], Ascent : _bounds[4], Height : (_bounds[4] - _bounds[3]), WidthG: (_bounds[2] - _bounds[1]) };
},
MeasureCode : function(lUnicode)
{
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
var _width = this.Measurer["MeasureChar"](lUnicode);
return { Width : _width, Height : 0 };
},
Measure2Code : function(lUnicode)
{
var _bounds = this.Measurer["GetDrawingBox"](lUnicode);
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
var _bounds = this.Measurer["GetDrawingBox"](lUnicode);
return { Width : _bounds[0], Ascent : _bounds[4], Height : (_bounds[4] - _bounds[3]), WidthG: (_bounds[2] - _bounds[1]) };
},
......
......@@ -123,7 +123,7 @@ native_context2d.prototype =
{
var _data = new _image_data();
_data.length = imagedata_or_sw * sh * 4;
_data.data = new Uint8Array(imagedata_or_sw * sh * 4);
_data.data = (typeof(Uint8Array) != 'undefined') ? new Uint8Array(_data.length) : new Array(_data.length);
return _data;
},
getImageData : function(sx,sy,sw,sh) {},
......@@ -524,4 +524,111 @@ window.native.Call_VR_Table = function(_params, _cols, _margins, _rows)
window.native.Call_Menu_Event = function(type, _params)
{
return _api.Call_Menu_Event(type, _params);
};
\ No newline at end of file
};
// FT_Common
function _FT_Common()
{
this.UintToInt = function(v)
{
return (v>2147483647)?v-4294967296:v;
};
this.UShort_To_Short = function(v)
{
return (v>32767)?v-65536:v;
};
this.IntToUInt = function(v)
{
return (v<0)?v+4294967296:v;
};
this.Short_To_UShort = function(v)
{
return (v<0)?v+65536:v;
};
this.memset = function(d,v,s)
{
for (var i=0;i<s;i++)
d[i]=v;
};
this.memcpy = function(d,s,l)
{
for (var i=0;i<l;i++)
d[i]=s[i];
};
this.memset_p = function(d,v,s)
{
var _d = d.data;
var _e = d.pos+s;
for (var i=d.pos;i<_e;i++)
_d[i]=v;
};
this.memcpy_p = function(d,s,l)
{
var _d1=d.data;
var _p1=d.pos;
var _d2=s.data;
var _p2=s.pos;
for (var i=0;i<l;i++)
_d1[_p1++]=_d2[_p2++];
};
this.memcpy_p2 = function(d,s,p,l)
{
var _d1=d.data;
var _p1=d.pos;
var _p2=p;
for (var i=0;i<l;i++)
_d1[_p1++]=s[_p2++];
};
this.realloc = function(memory, pointer, cur_count, new_count)
{
var ret = { block: null, err : 0, size : new_count};
if (cur_count < 0 || new_count < 0)
{
/* may help catch/prevent nasty security issues */
ret.err = 6;
}
else if (new_count == 0)
{
ret.block = null;
}
else if (cur_count == 0)
{
ret.block = memory.Alloc(new_count);
}
else
{
var block2 = memory.Alloc(new_count);
FT_Common.memcpy_p(block2, pointer, cur_count);
ret.block = block2;
}
return ret;
};
this.realloc_long = function(memory, pointer, cur_count, new_count)
{
var ret = { block: null, err : 0, size : new_count};
if (cur_count < 0 || new_count < 0)
{
/* may help catch/prevent nasty security issues */
ret.err = 6;
}
else if (new_count == 0)
{
ret.block = null;
}
else if (cur_count == 0)
{
ret.block = CreateIntArray(new_count);
}
else
{
var block2 = CreateIntArray(new_count);
for (var i = 0; i < cur_count; i++)
block2[i] = pointer[i];
ret.block = block2;
}
return ret;
};
}
var FT_Common = new _FT_Common();
\ No newline at end of file
......@@ -54,7 +54,7 @@ CFontSetup.prototype =
this.Bold = false;
this.Italic = false;
this.SetupName = "";
this.SetUpName = "";
this.SetUpIndex = -1;
this.SetUpSize = 12;
this.SetUpStyle = -1;
......
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