Commit 1f8135e6 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@60927 954022d7-b5bf-4e40-9824-e11837661b57
parent 359141e3
This diff is collapsed.
......@@ -151,12 +151,12 @@ function CTextMeasurer()
this.Init = function()
{
this.m_oManager.Initialize();
}
};
this.SetStringGid = function(bGID)
{
this.m_oManager.SetStringGID(bGID);
}
};
this.SetFont = function(font)
{
......@@ -165,12 +165,6 @@ function CTextMeasurer()
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;
......@@ -183,15 +177,15 @@ function CTextMeasurer()
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;
window.g_font_infos[_lastSetUp.SetUpIndex].LoadFont(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);
}
}
};
this.SetTextPr = function(textPr, theme)
{
......@@ -214,11 +208,6 @@ function CTextMeasurer()
_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;
......@@ -230,11 +219,6 @@ function CTextMeasurer()
_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;
......@@ -246,11 +230,6 @@ function CTextMeasurer()
_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;
......@@ -263,11 +242,6 @@ function CTextMeasurer()
_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;
......@@ -285,25 +259,25 @@ function CTextMeasurer()
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;
window.g_font_infos[_lastFont.SetUpIndex].LoadFont(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);
}
}
};
this.GetTextPr = function()
{
return this.m_oTextPr;
}
};
this.GetFont = function()
{
return this.m_oFont;
}
};
this.Measure = function(text)
{
......@@ -316,7 +290,7 @@ function CTextMeasurer()
Height = 0;//Temp.fHeight;
return { Width : Width, Height : Height };
}
};
this.Measure2 = function(text)
{
var Width = 0;
......@@ -345,7 +319,7 @@ function CTextMeasurer()
rasterOffsetX: Temp.oBBox.rasterDistances.dist_l * 25.4 / 72,
rasterOffsetY: Temp.oBBox.rasterDistances.dist_t * 25.4 / 72
};
}
};
this.MeasureCode = function(lUnicode)
{
......@@ -358,7 +332,7 @@ function CTextMeasurer()
Height = ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72);
return { Width : Width, Height : Height, Ascent : (Temp.oBBox.fMaxY * 25.4 / 72) };
}
};
this.Measure2Code = function(lUnicode)
{
var Width = 0;
......@@ -387,7 +361,7 @@ function CTextMeasurer()
rasterOffsetX: (Temp.oBBox.rasterDistances.dist_l + Temp.oBBox.fMinX) * 25.4 / 72,
rasterOffsetY: Temp.oBBox.rasterDistances.dist_t * 25.4 / 72
};
}
};
this.GetAscender = function()
{
......@@ -395,21 +369,21 @@ function CTextMeasurer()
var Ascender = this.m_oManager.m_lAscender;
return Ascender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
}
};
this.GetDescender = function()
{
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
var Descender = this.m_oManager.m_lDescender;
return Descender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
}
};
this.GetHeight = function()
{
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
var Height = this.m_oManager.m_lLineHeight;
return Height * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
}
};
}
var g_oTextMeasurer = new CTextMeasurer();
......@@ -4745,7 +4719,7 @@ function CDrawingDocument()
var api = this.m_oWordControl.m_oApi;
for (var i in map_used)
{
var key = GenerateMapId(api, map_used[i].Name, map_used[i].Style, map_used[i].Size);
var key = GenerateMapId(api, g_fontApplication.GetFontInfoName(map_used[i].Name), map_used[i].Style, map_used[i].Size);
map_keys[key] = true;
}
......@@ -6603,15 +6577,7 @@ function CMathPainter(_api)
this.StartLoad = function()
{
var loader = window.g_font_loader;
var nIndex = loader.map_font_index["Cambria Math"];
if (undefined === nIndex)
{
// нет Cambria Math - нет и формул
return;
}
var fontinfo = loader.fontInfos[nIndex];
var fontinfo = g_fontApplication.GetFontInfo("Cambria Math");
if (undefined === fontinfo)
{
// нет Cambria Math - нет и формул
......
This diff is collapsed.
......@@ -218,7 +218,15 @@
}
};
this.AddLoadFonts = function(info, need_styles)
this.AddLoadFonts = function(name, need_styles)
{
var fontinfo = g_fontApplication.GetFontInfo(name);
this.fonts_loading[this.fonts_loading.length] = fontinfo;
this.fonts_loading[this.fonts_loading.length - 1].NeedStyles = (need_styles == undefined) ? 0x0F : need_styles;
};
this.AddLoadFontsNotPick = function(info, need_styles)
{
this.fonts_loading[this.fonts_loading.length] = info;
this.fonts_loading[this.fonts_loading.length - 1].NeedStyles = (need_styles == undefined) ? 0x0F : need_styles;
......@@ -247,9 +255,7 @@
{
if (_fonts[i].Type != FONT_TYPE_EMBEDDED)
{
var info = this.fontInfos[this.map_font_index[_fonts[i].name]];
this.AddLoadFonts(info, _fonts[i].NeedStyles);
this.AddLoadFonts(_fonts[i].name, _fonts[i].NeedStyles);
if (info.Type == FONT_TYPE_ADDITIONAL)
{
......@@ -267,7 +273,7 @@
{
if (this.embeddedFontInfos[j].Name == _fonts[i].name)
{
this.AddLoadFonts(this.embeddedFontInfos[j], 0);
this.AddLoadFontsNotPick(this.embeddedFontInfos[j], 0);
break;
}
}
......@@ -280,14 +286,11 @@
if (this.Api.IsNeedDefaultFonts())
{
// теперь добавим шрифты, без которых редактор как без рук (спецсимволы + дефолтовые стили документа)
this.AddLoadFonts(this.fontInfos[this.map_font_index["Arial"]], 0x0F);
this.AddLoadFonts(this.fontInfos[this.map_font_index["Symbol"]], 0x0F);
this.AddLoadFonts(this.fontInfos[this.map_font_index["Wingdings"]], 0x0F);
this.AddLoadFonts(this.fontInfos[this.map_font_index["Courier New"]], 0x0F);
//if (is_default === true)
{
this.AddLoadFonts(this.fontInfos[this.map_font_index["Times New Roman"]], 0x0F);
}
this.AddLoadFonts("Arial", 0x0F);
this.AddLoadFonts("Symbol", 0x0F);
this.AddLoadFonts("Wingdings", 0x0F);
this.AddLoadFonts("Courier New", 0x0F);
this.AddLoadFonts("Times New Roman", 0x0F);
}
this.Api.asyncFontsDocumentStartLoaded();
......@@ -329,8 +332,7 @@
// сначала заполняем массив this.fonts_loading объекстами fontinfo
for (var i in _fonts)
{
var info = this.fontInfos[this.map_font_index[_fonts[i].name]];
this.AddLoadFonts(info, 0x0F);
this.AddLoadFonts(_fonts[i].name, 0x0F);
}
if (null == this.ThemeLoader)
......
......@@ -482,7 +482,13 @@ function CGraphics()
this.ArrayPoints = null;
this.m_oCurFont = null;
this.m_oCurFont =
{
Name : "",
FontSize : 10,
Bold : false,
Italic : false
};
// RFonts
this.m_oTextPr = null;
......@@ -1162,24 +1168,10 @@ CGraphics.prototype =
if (null == font)
return;
this.m_oCurFont =
{
FontFamily :
{
Index : font.FontFamily.Index,
Name : font.FontFamily.Name
},
FontSize : font.FontSize,
Bold : font.Bold,
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;
this.m_oCurFont.Name = font.FontFamily.Name;
this.m_oCurFont.FontSize = font.FontSize;
this.m_oCurFont.Bold = font.Bold;
this.m_oCurFont.Italic = font.Italic;
var bItalic = true === font.Italic;
var bBold = true === font.Bold;
......@@ -1195,11 +1187,11 @@ CGraphics.prototype =
var _last_font = this.IsUseFonts2 ? this.m_oLastFont2 : this.m_oLastFont;
var _font_manager = this.IsUseFonts2 ? this.m_oFontManager2 : this.m_oFontManager;
_last_font.SetUpIndex = font.FontFamily.Index;
_last_font.SetUpName = font.FontFamily.Name;
_last_font.SetUpSize = font.FontSize;
_last_font.SetUpStyle = oFontStyle;
window.g_font_infos[font.FontFamily.Index].LoadFont(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);
var _mD = _last_font.SetUpMatrix;
var _mS = this.m_oTransform;
......@@ -1234,13 +1226,6 @@ CGraphics.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;
......@@ -1250,13 +1235,6 @@ CGraphics.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;
......@@ -1266,13 +1244,6 @@ CGraphics.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;
......@@ -1283,13 +1254,6 @@ CGraphics.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;
......@@ -1309,13 +1273,13 @@ CGraphics.prototype =
var _font_manager = this.IsUseFonts2 ? this.m_oFontManager2 : this.m_oFontManager;
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;
window.g_font_infos[_lastFont.SetUpIndex].LoadFont(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);
var _mD = _lastFont.SetUpMatrix;
var _mS = this.m_oTransform;
......
......@@ -3931,8 +3931,6 @@ function CEditorPage(api)
this.TextBoxInputMode = isEA;
if (isEA)
{
g_fontSelections.fromStream();
if (null == this.TextBoxInput)
{
this.TextBoxInput = document.createElement('textarea');
......@@ -4099,7 +4097,8 @@ function CEditorPage(api)
this.TextBoxInput.style.top = "-1000px";
this.TextBoxInputFocus = false;
var _language = g_fontSelections.checkText(oThis.TextBoxInput.value);
var _fontSelections = g_fontApplication.g_fontSelections;
var _language = _fontSelections.checkText(oThis.TextBoxInput.value);
/*
switch (_language)
......@@ -4145,16 +4144,15 @@ function CEditorPage(api)
{
var _textPr = oThis.m_oLogicDocument.Get_Paragraph_TextPr();
var _check_obj = g_fontSelections.checkPasteText(_textPr, _language);
var _check_obj = _fontSelections.checkPasteText(_textPr, _language);
if (_check_obj.is_async)
{
var loader = window.g_font_loader;
var nIndex = loader.map_font_index[_check_obj.name];
var fontinfo = loader.fontInfos[nIndex];
var fontinfo = g_fontApplication.GetFontInfo(_check_obj.name);
var isasync = loader.LoadFont(fontinfo);
if (false === isasync)
{
var _rfonts = g_fontSelections.getSetupRFonts(_check_obj);
var _rfonts = _fontSelections.getSetupRFonts(_check_obj);
oThis.m_oLogicDocument.TextBox_Put(oThis.TextBoxInput.value, _rfonts);
this.ReinitTB();
}
......@@ -4162,7 +4160,7 @@ function CEditorPage(api)
{
oThis.m_oApi.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadFont);
_check_obj.text = oThis.TextBoxInput.value;
g_fontSelections.CurrentLoadedObj = _check_obj;
_fontSelections.CurrentLoadedObj = _check_obj;
}
}
else
......
This diff is collapsed.
......@@ -76,6 +76,7 @@
<script src="../Common/FontsFreeType/FontFile.js"></script>
<script src="../Common/FontsFreeType/FontManager.js"></script>
<script src="../Common/FontsFreeType/font_map.js"></script>
<script src="../Common/apiCommon.js"></script>
......
......@@ -515,6 +515,8 @@ var DocumentPageSize = new function() {
function asc_docs_api(name)
{
g_fontApplication.Init();
var CDocsCoApi = window["CDocsCoApi"];
var CSpellCheckApi = window["CSpellCheckApi"];
......@@ -1992,13 +1994,10 @@ asc_docs_api.prototype.put_FramePr = function(Obj)
{
if ( undefined != Obj.FontFamily )
{
var name = Obj.FontFamily;
Obj.FontFamily = new CTextFontFamily( { Name : Obj.FontFamily, Index : -1 } );
var loader = window.g_font_loader;
var nIndex = loader.map_font_index[name];
var fontinfo = loader.fontInfos[nIndex];
var fontinfo = g_fontApplication.GetFontInfo(Obj.FontFamily);
var isasync = loader.LoadFont(fontinfo, editor.asyncFontEndLoaded_DropCap, Obj);
Obj.FontFamily = new CTextFontFamily( { Name : fontinfo.Name, Index : -1 } );
if (false === isasync)
{
......@@ -3262,15 +3261,14 @@ asc_docs_api.prototype.sync_SearchEndCallback = function()
asc_docs_api.prototype.put_TextPrFontName = function(name)
{
var loader = window.g_font_loader;
var nIndex = loader.map_font_index[name];
var fontinfo = loader.fontInfos[nIndex];
var fontinfo = g_fontApplication.GetFontInfo(name);
var isasync = loader.LoadFont(fontinfo);
if (false === isasync)
{
if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_Paragraph_Content) )
{
this.WordControl.m_oLogicDocument.Create_NewHistoryPoint();
this.WordControl.m_oLogicDocument.Paragraph_Add( new ParaTextPr( { FontFamily : { Name : fontinfo.Name , Index : nIndex } } ) );
this.WordControl.m_oLogicDocument.Paragraph_Add( new ParaTextPr( { FontFamily : { Name : fontinfo.Name , Index : -1 } } ) );
}
}
}
......@@ -6619,13 +6617,14 @@ asc_docs_api.prototype.asyncFontEndLoaded = function(fontinfo)
{
this.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadFont);
if (g_fontSelections.CurrentLoadedObj != null)
var _fontSelections = g_fontApplication.g_fontSelections;
if (_fontSelections.CurrentLoadedObj != null)
{
var _rfonts = g_fontSelections.getSetupRFonts(g_fontSelections.CurrentLoadedObj);
this.WordControl.m_oLogicDocument.TextBox_Put(g_fontSelections.CurrentLoadedObj.text, _rfonts);
var _rfonts = _fontSelections.getSetupRFonts(_fontSelections.CurrentLoadedObj);
this.WordControl.m_oLogicDocument.TextBox_Put(_fontSelections.CurrentLoadedObj.text, _rfonts);
this.WordControl.ReinitTB();
g_fontSelections.CurrentLoadedObj = null;
_fontSelections.CurrentLoadedObj = null;
this.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadFont);
return;
}
......@@ -7767,8 +7766,7 @@ asc_docs_api.prototype.asc_setDrawCollaborationMarks = function (bDraw)
asc_docs_api.prototype.asc_AddMath = function(Type)
{
var loader = window.g_font_loader;
var nIndex = loader.map_font_index["Cambria Math"];
var fontinfo = loader.fontInfos[nIndex];
var fontinfo = g_fontApplication.GetFontInfo("Cambria Math");
var isasync = loader.LoadFont(fontinfo);
if (false === isasync)
{
......
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