Compare commits

..

13 Commits

Author SHA1 Message Date
8cdaf43001 Feature/font bugs (#202)
* Fonts bugs

* Move fonts_check version to src file
2019-10-16 14:07:24 +03:00
21984680ce XlsFormat - fix bug #43072 (#200) 2019-10-11 14:15:37 +03:00
c8def9eb7b v5.4.1 2019-10-02 12:02:37 +03:00
048318e341 Fix icu building (#198)
Change icu repos
2019-09-30 15:59:13 +03:00
49ee434202 Fix fonts bug (#196) 2019-09-30 14:39:57 +03:00
a76e93cea6 [x2t] Remove reply duplicates. Fix bug 42969 2019-09-27 12:04:56 +03:00
c26252d25f [x2t] Fix Excel recovery error; Fix bug 42968 2019-09-27 10:51:48 +03:00
2e23b79ab8 [x2t] Fix GenerateGuid. For bug 42947 2019-09-26 20:08:58 +03:00
7faa83eb8a Fix bug 42926 2019-09-26 16:17:24 +03:00
e9c1deaca6 fix error #42938 2019-09-24 18:56:54 +03:00
0b34858d49 fix error #42932 2019-09-24 18:56:28 +03:00
095c53a61a Merge pull request #195 from ONLYOFFICE/feature/fix_errors7_v5.4.1
RtfFormat - fix after testing
2019-09-18 12:42:49 +03:00
640b914ff8 RtfFormat - fix after testing 2019-09-18 12:40:50 +03:00
27 changed files with 584 additions and 315 deletions

View File

@ -385,6 +385,78 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSele
return;
}
size_t getColAddressInv(const std::wstring & a_)
{
std::wstring a = a_;
::boost::algorithm::to_upper(a);
static const size_t r = (L'Z' - L'A' + 1);
size_t mul = 1;
bool f = true;
size_t res = 0;
for (int i = a.length() - 1; i >= 0; i--)
{
size_t v = a[i] - L'A';
if (f)
f = false;
else
v += 1;
res += v * mul;
mul *= r;
}
return res;
}
size_t getRowAdderssInv(const std::wstring & a_)
{
int sz = a_.length();
if (a_.length()>0)
{
return boost::lexical_cast<size_t>(a_)-1;
}
else
return 0;
}
void splitCellAddress(const std::wstring & a_, std::wstring & col, std::wstring & row)
{
std::wstring a = a_;
std::reverse(a.begin(), a.end());
::XmlUtils::replace_all( a, L"$", L"");
//::XmlUtils::replace_all( a, L"'", L"");
::boost::algorithm::to_upper(a);
for (size_t i = 0; i < a.length(); i++)
{
if (a[i] >= L'0' && a[i] <= L'9')
row += a[i];
else
col += a[i];
}
std::reverse(col.begin(), col.end());
std::reverse(row.begin(), row.end());
}
void getCellAddressInv(const std::wstring & a_, int & col, int & row)
{
std::wstring colStr=L"", rowStr=L"";
splitCellAddress(a_, colStr, rowStr);
col = getColAddressInv(colStr);
row = getRowAdderssInv(rowStr);
if (col > 16384) col= -1;
}
bool IsRefPresent(const std::wstring& ref_test)
{
int col = -1, row = -1;
getCellAddressInv(ref_test, col, row);
if (col >= 0 && row >=0) return true;
return false;
}
std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmatch const & what)
{
const size_t sz = what.size();
@ -413,8 +485,21 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
if (!c2.empty() && c2.substr(0, 1) == L":")
c2 = c2.substr(1);
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
bool bRefPresent = true;
if (sheet.empty() && c2.empty())
{
bRefPresent = IsRefPresent(c1);
}
if (bRefPresent)
{
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
}
else
{
s = c1;
}
}
return s;
}
@ -856,67 +941,6 @@ std::wstring oox2odf_converter::convert_spacechar(std::wstring expr)
}
return expr;
}
size_t getColAddressInv(const std::wstring & a_)
{
std::wstring a = a_;
::boost::algorithm::to_upper(a);
static const size_t r = (L'Z' - L'A' + 1);
size_t mul = 1;
bool f = true;
size_t res = 0;
for (int i = a.length() - 1; i >= 0; i--)
{
size_t v = a[i] - L'A';
if (f)
f = false;
else
v += 1;
res += v * mul;
mul *= r;
}
return res;
}
size_t getRowAdderssInv(const std::wstring & a_)
{
int sz = a_.length();
if (a_.length()>0)
{
return boost::lexical_cast<size_t>(a_)-1;
}
else
return 0;
}
void splitCellAddress(const std::wstring & a_, std::wstring & col, std::wstring & row)
{
std::wstring a = a_;
std::reverse(a.begin(), a.end());
::XmlUtils::replace_all( a, L"$", L"");
//::XmlUtils::replace_all( a, L"'", L"");
::boost::algorithm::to_upper(a);
for (size_t i = 0; i < a.length(); i++)
{
if (a[i] >= L'0' && a[i] <= L'9')
row += a[i];
else
col += a[i];
}
std::reverse(col.begin(), col.end());
std::reverse(row.begin(), row.end());
}
void getCellAddressInv(const std::wstring & a_, int & col, int & row)
{
std::wstring colStr=L"", rowStr=L"";
splitCellAddress(a_, colStr, rowStr);
col = getColAddressInv(colStr);
row = getRowAdderssInv(rowStr);
}
int oox2odf_converter::get_count_value_points(std::wstring expr)
{
int count =0;

View File

@ -2411,7 +2411,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
odf_writer::style_text_properties * text_properties = ods_context->styles_context()->last_state()->get_text_properties();
odf_writer::style_table_cell_properties * table_cell_properties = ods_context->styles_context()->last_state()->get_table_cell_properties();
if (xlsx_styles->m_oFonts.IsInit() && font_id >=0 && (id_parent < 0 || xfc_style->m_oApplyFont.IsInit()))
bool bApplyFont = xfc_style->m_oApplyFont.IsInit() ? xfc_style->m_oApplyFont->ToBool() : true;
if (xlsx_styles->m_oFonts.IsInit() && font_id >=0 && (id_parent < 0 || bApplyFont))
{
std::map<int, OOX::Spreadsheet::CFont*>::iterator pFind = xlsx_styles->m_oFonts->m_mapFonts.find(font_id);
if (pFind != xlsx_styles->m_oFonts->m_mapFonts.end())
@ -2419,7 +2420,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
convert(pFind->second, text_properties);
}
}
if (xlsx_styles->m_oFills.IsInit() && fill_id >= 0 && (id_parent < 0 || xfc_style->m_oApplyFill.IsInit()))
bool bApplyFill = xfc_style->m_oApplyFill.IsInit() ? xfc_style->m_oApplyFill->ToBool() : true;
if (xlsx_styles->m_oFills.IsInit() && fill_id >= 0 && (id_parent < 0 || bApplyFill))
{
std::map<int, OOX::Spreadsheet::CFill*>::iterator pFind = xlsx_styles->m_oFills->m_mapFills.find(fill_id);
if (pFind != xlsx_styles->m_oFills->m_mapFills.end())
@ -2427,12 +2429,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
convert(pFind->second, table_cell_properties);
}
}
if (numFmt_id >= 0/* && (id_parent < 0 || xfc_style->m_oApplyNumberFormat.IsInit())*/)
bool bApplyNumberFormat = xfc_style->m_oApplyNumberFormat.IsInit() ? xfc_style->m_oApplyNumberFormat->ToBool() : true;
if (numFmt_id >= 0 && (id_parent < 0 || bApplyNumberFormat))
{
ods_context->styles_context()->last_state()->set_data_style_name(ods_context->numbers_styles_context()->add_or_find(numFmt_id).style_name);
ods_context->styles_context()->last_state()->set_number_format(numFmt_id);
}
if (xlsx_styles->m_oBorders.IsInit() && border_id >=0 && (id_parent < 0 || xfc_style->m_oApplyBorder.IsInit()))
bool bApplyBorder = xfc_style->m_oApplyBorder.IsInit() ? xfc_style->m_oApplyBorder->ToBool() : true;
if (xlsx_styles->m_oBorders.IsInit() && border_id >=0 && (id_parent < 0 || bApplyBorder))
{
std::map<int, OOX::Spreadsheet::CBorder*>::iterator pFind = xlsx_styles->m_oBorders->m_mapBorders.find(border_id);
if (pFind != xlsx_styles->m_oBorders->m_mapBorders.end())

View File

@ -1018,8 +1018,8 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
//применяем default
oNewProperty = oParam.oRtf->m_oDefaultCharProp;
//применяем внешний стиль
oNewProperty.Merge( oOutputParagraph.m_oProperty.m_oCharProperty );
//применяем внешний стиль (часть свойств не наследуется!!)
oNewProperty.Merge( oOutputParagraph.m_oProperty.m_oCharProperty, false );
oNewProperty.Merge( m_oCharProperty );
if( NULL != poStyle && TYPE_RTF_PROPERTY_STYLE_CHAR == poStyle->GetType() )

View File

@ -1142,13 +1142,12 @@ public:
m_pOldCharProp = RtfCharPropertyPtr();
}
void Merge( RtfCharProperty& oCharPr )
void Merge( RtfCharProperty& oCharPr, bool bAll = true )
{
MERGE_PROPERTY( m_nAnimated, oCharPr )
MERGE_PROPERTY( m_bBold, oCharPr )
MERGE_PROPERTY( m_bCaps, oCharPr )
MERGE_PROPERTY( m_nScalex, oCharPr )
MERGE_PROPERTY( m_nCharStyle, oCharPr )
MERGE_PROPERTY( m_nDown, oCharPr )
MERGE_PROPERTY( m_bEmbo, oCharPr )
MERGE_PROPERTY( m_nCharacterSpacing, oCharPr )
@ -1166,12 +1165,9 @@ public:
MERGE_PROPERTY( m_bOutline, oCharPr )
MERGE_PROPERTY( m_bScaps, oCharPr )
MERGE_PROPERTY( m_bShadow, oCharPr )
MERGE_PROPERTY( m_bStrike, oCharPr )
MERGE_PROPERTY( m_nStriked, oCharPr )
MERGE_PROPERTY( m_bSub, oCharPr )
MERGE_PROPERTY( m_bSuper, oCharPr )
MERGE_PROPERTY( m_bHidden, oCharPr )
MERGE_PROPERTY( m_nHightlited, oCharPr )
MERGE_PROPERTY( m_nForeColor, oCharPr )
MERGE_PROPERTY( m_nCrAuth, oCharPr )
MERGE_PROPERTY( m_nCrDate, oCharPr )
@ -1183,11 +1179,18 @@ public:
MERGE_PROPERTY( m_nRevdttmDel, oCharPr )
MERGE_PROPERTY( m_nInsrsid, oCharPr )
//свойство должно быть как единое целое, поэтому если oBorPr задано, то переписыватся целиком
if ( uls_none != oCharPr.m_eUnderStyle || PROP_DEF != oCharPr.m_nUnderlineColor )
if (bAll)
{
m_eUnderStyle = oCharPr.m_eUnderStyle;
m_nUnderlineColor = oCharPr.m_nUnderlineColor;
MERGE_PROPERTY( m_nCharStyle, oCharPr )
MERGE_PROPERTY( m_bStrike, oCharPr )
MERGE_PROPERTY( m_nStriked, oCharPr )
MERGE_PROPERTY( m_nHightlited, oCharPr )
//свойство должно быть как единое целое, поэтому если oBorPr задано, то переписыватся целиком
if ( uls_none != oCharPr.m_eUnderStyle || PROP_DEF != oCharPr.m_nUnderlineColor )
{
m_eUnderStyle = oCharPr.m_eUnderStyle;
m_nUnderlineColor = oCharPr.m_nUnderlineColor;
}
}
MERGE_PROPERTY_DEF ( m_bSub, oCharPr, uls_none )
MERGE_PROPERTY ( m_nUp, oCharPr )

View File

@ -45,7 +45,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/xml/build/vs2005;&quot;../../DesktopEditor/freetype-2.5.2/include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS;DONT_USED_EXTRA_LIBRARY"
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="3"

View File

@ -37,7 +37,8 @@ namespace XLS
Row::Row()
{
iOutLevel = ixfe_val = 0;
iOutLevel = 0;
ixfe_val = 0;
}
@ -86,6 +87,10 @@ int Row::serialize(std::wostream &stream)
bool xf_set = true;
if (fGhostDirty == false) xf_set = false;
if (colMic >= 0 && colMac > colMic)
{
CP_XML_ATTR(L"spans", std::to_wstring(colMic + 1) + L":" + std::to_wstring(colMac));
}
if (xf_set)
{
int xf = ixfe_val >= global_info_->cellStyleXfs_count ? ixfe_val - global_info_->cellStyleXfs_count : -1/*ixfe_val*/;
@ -96,7 +101,7 @@ int Row::serialize(std::wostream &stream)
CP_XML_ATTR(L"customFormat", true);
}
}
if (miyRw > 0/* && std::abs(miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/)
if (miyRw > 0 && miyRw < 0x8000 && fUnsynced/* && std::abs(miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/)
{
CP_XML_ATTR(L"ht", miyRw / 20.);
CP_XML_ATTR(L"customHeight", true);

View File

@ -56,8 +56,11 @@ public:
//-----------------------------
Rw rw;
BackwardOnlyParam<unsigned short> colMic;
BackwardOnlyParam<unsigned short> colMac;
//BackwardOnlyParam<unsigned short> colMic;
//BackwardOnlyParam<unsigned short> colMac;
unsigned short colMic;
unsigned short colMac;
_UINT16 miyRw;

View File

@ -236,6 +236,10 @@ int CELLTABLE::serialize(std::wostream & stream)
bool xf_set = true;
if (row->fGhostDirty == false) xf_set = false;
if (row->colMic >= 0 && row->colMac > row->colMic)
{
CP_XML_ATTR(L"spans", std::to_wstring(row->colMic + 1) + L":" + std::to_wstring(row->colMac)); //zero based & one based
}
if (xf_set)
{
int xf = row->ixfe_val >= global_info_->cellStyleXfs_count ? row->ixfe_val - global_info_->cellStyleXfs_count : -1/*row->ixfe_val*/;
@ -246,7 +250,7 @@ int CELLTABLE::serialize(std::wostream & stream)
CP_XML_ATTR(L"customFormat", true);
}
}
if (row->miyRw > 0 && row->miyRw < 0x8000) //v8_14A_1b13.xls
if (row->miyRw > 0 && row->miyRw < 0x8000 && row->fUnsynced) //v8_14A_1b13.xls //Department_Sales_and_Stock_Monthly_Recap_Store_778_2019-09-03.xls
{
CP_XML_ATTR(L"ht", row->miyRw / 20.);
CP_XML_ATTR(L"customHeight", true);

View File

@ -57,7 +57,7 @@ for %%a in (%BUILD_PLATFORMS%) do (
if exist "icu" (
echo "icu already exported"
) else (
svn export http://source.icu-project.org/repos/icu/tags/release-%ICU_MAJOR_VER%-%ICU_MINOR_VER%/icu4c ./icu
svn export https://github.com/unicode-org/icu/tags/release-%ICU_MAJOR_VER%-%ICU_MINOR_VER%/icu4c ./icu
)
if "%%a" == "win_64" (

View File

@ -54,7 +54,7 @@ if [ -d "./icu" ]
then
echo "icu already exported"
else
svn export http://source.icu-project.org/repos/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
svn export https://github.com/unicode-org/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
fi
if [[ "$platform" == *"linux"* ]]

View File

@ -45,4 +45,4 @@ fi
cd "$SCRIPTPATH/$platform$arch"
svn export http://source.icu-project.org/repos/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
svn export https://github.com/unicode-org/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu

View File

@ -338,6 +338,10 @@ namespace SimpleTypes
SimpleType_Operator_Equal (CGuid)
bool IsZero()
{
return 0 == m_oGUID.a && 0 == m_oGUID.b && 0 == m_oGUID.c && 0 == m_oGUID.d && 0 == m_oGUID.e && 0 == m_oGUID.f && 0 == m_oGUID.g && 0 == m_oGUID.h && 0 == m_oGUID.i && 0 == m_oGUID.j && 0 == m_oGUID.k;
}
private:
bool HexToInt(std::wstring& sValue, T_ULONG64& unResult)

View File

@ -311,7 +311,7 @@ namespace XmlUtils
// CoTaskMemFree(guidString);
//#else
std::wstringstream sstream;
sstream << boost::wformat(L"%04X%04X-%04X-%04X-%04X-%04X%04X%04X") % Rand() % Rand() % Rand() % ((Rand() & 0x0fff) | 0x4000) % ((Rand() % 0x3fff) + 0x8000) % Rand() % Rand() % Rand();
sstream << boost::wformat(L"%04X%04X-%04X-%04X-%04X-%04X%04X%04X") % (Rand() & 0xff) % (Rand() & 0xff) % (Rand() & 0xff) % ((Rand() & 0x0fff) | 0x4000) % ((Rand() % 0x3fff) + 0x8000) % (Rand() & 0xff) % (Rand() & 0xff) % (Rand() & 0xff);
result = sstream.str();
//#endif
return result;

View File

@ -463,6 +463,12 @@ namespace OOX
WritingElement_ReadAttributes_End( oReader )
//todo IsZero() is added to fix comments with zero ids(5.4.0)(bug 42947). Remove after few releases
if(id.IsInit() && id->IsZero())
{
id = L"{" + XmlUtils::GenerateGuid() + L"}";
}
}
public:
nullable_string ref;
@ -580,16 +586,38 @@ namespace OOX
m_mapTopLevelThreadedComments[pThreadedComment->id->ToString()] = pThreadedComment;
}
}
//to remove reply duplicates
std::unordered_map<std::wstring, bool> mapUniqueue;
//add Replies
for(size_t i = 0; i < m_arrItems.size(); ++i)
{
CThreadedComment* pThreadedComment = m_arrItems[i];
if(pThreadedComment->parentId.IsInit())
{
std::unordered_map<std::wstring, CThreadedComment*>::const_iterator oFind = m_mapTopLevelThreadedComments.find(pThreadedComment->parentId->ToString());
if(m_mapTopLevelThreadedComments.end() != oFind)
//todo IsZero() is added to fix comments with zero ids(5.4.0)(bug 42947). Remove after few releases
if(pThreadedComment->parentId->IsZero() && pThreadedComment->ref.IsInit())
{
oFind->second->m_arrReplies.push_back(pThreadedComment);
if (pThreadedComment->dT.IsInit() && mapUniqueue.find(pThreadedComment->dT->ToString()) == mapUniqueue.end())
{
mapUniqueue[pThreadedComment->dT->ToString()] = true;
//find parents by ref
for (std::unordered_map<std::wstring, CThreadedComment*>::const_iterator it = m_mapTopLevelThreadedComments.begin(); it != m_mapTopLevelThreadedComments.end(); ++it)
{
if (it->second->ref.IsInit() && pThreadedComment->ref.get() == it->second->ref.get())
{
it->second->m_arrReplies.push_back(pThreadedComment);
break;
}
}
}
}
else
{
std::unordered_map<std::wstring, CThreadedComment*>::const_iterator oFind = m_mapTopLevelThreadedComments.find(pThreadedComment->parentId->ToString());
if(m_mapTopLevelThreadedComments.end() != oFind)
{
oFind->second->m_arrReplies.push_back(pThreadedComment);
}
}
}
}

View File

@ -38,6 +38,7 @@ namespace OOX
namespace SpreadsheetCommon
{
std::wstring WriteDouble(double dVal);
const int MAX_STRING_LEN = 0x7FFF;
}
}
}

View File

@ -280,7 +280,22 @@ namespace OOX
if(pComment->m_oUid.IsInit())
{
pFind = pThreadedComments->m_mapTopLevelThreadedComments.find(pComment->m_oUid->ToString());
//todo IsZero() is added to fix comments with zero ids(5.4.0)(bug 42947). Remove after few releases
if(pComment->m_oUid->IsZero() && pComment->m_oRef.IsInit())
{
for (std::unordered_map<std::wstring, CThreadedComment*>::iterator it = pThreadedComments->m_mapTopLevelThreadedComments.begin(); it != pThreadedComments->m_mapTopLevelThreadedComments.end(); ++it)
{
if (it->second->ref.IsInit() && pComment->m_oRef->GetValue() == it->second->ref.get())
{
pFind = it;
break;
}
}
}
else
{
pFind = pThreadedComments->m_mapTopLevelThreadedComments.find(pComment->m_oUid->ToString());
}
}
else if(pComment->m_oAuthorId.IsInit())
{

View File

@ -1352,17 +1352,9 @@ void CFontList::LoadFromArrayFiles(std::vector<std::wstring>& oArray, int nFlag)
continue;
}
std::string sFamilyName = "";
if (NULL != pFace->family_name)
sFamilyName = pFace->family_name;
std::wstring wsFamilyName = GetCorrectSfntName(pFace->family_name);
std::wstring wsStyleName = GetCorrectSfntName(pFace->style_name);
std::string sStyleName = "";
if (NULL != pFace->style_name)
sStyleName = pFace->style_name;
std::wstring wsFamilyName = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(sFamilyName);
std::wstring wsStyleName = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(sStyleName);
#ifdef _MAC
if (wsFamilyName.find(L".") == 0)
{
@ -1417,6 +1409,24 @@ void CFontList::LoadFromFolder(const std::wstring& strDirectory)
this->LoadFromArrayFiles(oArray);
}
void CFontList::InitializeRanges(unsigned char* data)
{
RELEASEARRAYOBJECTS(m_pRanges)
NSMemoryUtils::CByteReader oReader(data);
m_nRangesCount = oReader.GetInt();
if (m_nRangesCount > 0)
m_pRanges = new CFontRange[m_nRangesCount];
for (int nIndex = 0; nIndex < m_nRangesCount; ++nIndex)
{
m_pRanges[nIndex].Name = oReader.GetStringUTF8();
m_pRanges[nIndex].Start = oReader.GetInt();
m_pRanges[nIndex].End = oReader.GetInt();
}
}
bool CFontList::CheckLoadFromFolderBin(const std::wstring& strDirectory)
{
std::wstring strPath = strDirectory + L"/font_selection.bin";
@ -1443,18 +1453,7 @@ bool CFontList::CheckLoadFromFolderBin(const std::wstring& strDirectory)
if ((_pBuffer - pBuffer) < dwLen1)
{
NSMemoryUtils::CByteReader oReader(_pBuffer);
m_nRangesCount = oReader.GetInt();
if (m_nRangesCount > 0)
m_pRanges = new CFontRange[m_nRangesCount];
for (int nIndex = 0; nIndex < m_nRangesCount; ++nIndex)
{
m_pRanges[nIndex].Name = oReader.GetStringUTF8();
m_pRanges[nIndex].Start = oReader.GetInt();
m_pRanges[nIndex].End = oReader.GetInt();
}
InitializeRanges(_pBuffer);
}
RELEASEARRAYOBJECTS(pBuffer);
@ -1541,6 +1540,11 @@ void CApplicationFonts::Initialize(bool bIsCheckSelection)
m_oCache.m_pApplicationFontStreams = &m_oStreams;
}
void CApplicationFonts::InitializeRanges(unsigned char* data)
{
m_oList.InitializeRanges(data);
}
NSFonts::IFontManager* CApplicationFonts::GenerateFontManager()
{
CFontManager* pManager = new CFontManager();

View File

@ -302,6 +302,7 @@ public:
std::vector<NSFonts::CFontInfo*> GetAllByName (const std::wstring& strFontName);
std::wstring GetFontBySymbol(int symbol);
void InitializeRanges(unsigned char* data);
};
class CApplicationFonts : public NSFonts::IApplicationFonts
@ -322,6 +323,7 @@ public:
void InitializeFromFolder(std::wstring strFolder, bool bIsCheckSelection = true);
void Initialize(bool bIsCheckSelection = true);
void InitializeRanges(unsigned char* data);
std::vector<std::wstring> GetSetupFontFiles();
void InitializeFromArrayFiles(std::vector<std::wstring>& files, int nFlag = 0);

View File

@ -32,6 +32,8 @@
#include "ApplicationFontsWorker.h"
#include "application_generate_fonts.h"
#define ONLYOFFICE_FONTS_VERSION_ 3
CApplicationFontsWorker::CApplicationFontsWorker()
{
m_bIsUseSystemFonts = true;
@ -52,11 +54,12 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
std::wstring strFontsSelectionBin = m_sDirectory + L"/font_selection.bin";
std::vector<std::string> strFonts;
std::wstring strFontsCheckPath = m_sDirectory + L"/fonts.log";
if (true)
{
NSFile::CFileBinary oFile;
if (oFile.OpenFile(m_sDirectory + L"/fonts.log"))
if (oFile.OpenFile(strFontsCheckPath))
{
int nSize = oFile.GetFileSize();
char* pBuffer = new char[nSize];
@ -141,28 +144,16 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
if (!bIsEqual)
{
if (NSFile::CFileBinary::Exists(strFontsCheckPath))
NSFile::CFileBinary::Remove(strFontsCheckPath);
if (NSFile::CFileBinary::Exists(strAllFontsJSPath))
NSFile::CFileBinary::Remove(strAllFontsJSPath);
if (NSFile::CFileBinary::Exists(strFontsSelectionBin))
NSFile::CFileBinary::Remove(strFontsSelectionBin);
if (strFonts.size() != 0)
NSFile::CFileBinary::Remove(m_sDirectory + L"/fonts.log");
NSFile::CFileBinary oFile;
oFile.CreateFileW(m_sDirectory + L"/fonts.log");
#ifdef ONLYOFFICE_FONTS_VERSION_
oFile.WriteStringUTF8(L"ONLYOFFICE_FONTS_VERSION_");
oFile.WriteStringUTF8(std::to_wstring(ONLYOFFICE_FONTS_VERSION_));
oFile.WriteFile((BYTE*)"\n", 1);
#endif
int nCount = (int)strFontsW_Cur.size();
for (int i = 0; i < nCount; ++i)
{
oFile.WriteStringUTF8(strFontsW_Cur[i]);
oFile.WriteFile((BYTE*)"\n", 1);
}
oFile.CloseFile();
if (NSFile::CFileBinary::Exists(m_sDirectory + L"/fonts_thumbnail.png"))
NSFile::CFileBinary::Remove(m_sDirectory + L"/fonts_thumbnail.png");
if (NSFile::CFileBinary::Exists(m_sDirectory + L"/fonts_thumbnail@2x.png"))
NSFile::CFileBinary::Remove(m_sDirectory + L"/fonts_thumbnail@2x.png");
int nFlag = 3;
if (!m_bIsUseOpenType)
@ -173,6 +164,21 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
NSCommon::SaveAllFontsJS(pApplicationF, strAllFontsJSPath, m_bIsNeedThumbnails ? m_sDirectory : L"", strFontsSelectionBin);
}
NSFile::CFileBinary oFile;
oFile.CreateFileW(strFontsCheckPath);
#ifdef ONLYOFFICE_FONTS_VERSION_
oFile.WriteStringUTF8(L"ONLYOFFICE_FONTS_VERSION_");
oFile.WriteStringUTF8(std::to_wstring(ONLYOFFICE_FONTS_VERSION_));
oFile.WriteFile((BYTE*)"\n", 1);
#endif
int nCount = (int)strFontsW_Cur.size();
for (int i = 0; i < nCount; ++i)
{
oFile.WriteStringUTF8(strFontsW_Cur[i]);
oFile.WriteFile((BYTE*)"\n", 1);
}
oFile.CloseFile();
pApplicationF->Release();
pApplicationF = NSFonts::NSApplication::Create();
pApplicationF->InitializeFromFolder(m_sDirectory);

View File

@ -682,9 +682,9 @@ void CFontFile::CheckHintsSupport()
return;
}
std::string sFamilyName((NULL != m_pFace->family_name) ? m_pFace->family_name : "");
std::wstring sFamilyName = GetCorrectSfntName(m_pFace->family_name);
if (sFamilyName == "MS Mincho" || sFamilyName == "Castellar")
if (m_sName == L"MS Mincho" || m_sName == L"Castellar")
m_bHintsSupport = FALSE;
}

View File

@ -1,4 +1,4 @@
/*
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
@ -44,6 +44,36 @@
#include "FontPath.h"
#include "GlyphString.h"
#include "../common/File.h"
static std::wstring GetCorrectSfntName(const char* name)
{
if (NULL == name)
return L"";
const char* name_cur = name;
int name_len = 0;
while (*name_cur++)
++name_len;
name_cur = name;
bool isUtf8 = false;
if (6 < name_len)
{
if ('<' == name[0] && 'u' == name[1] && 't' == name[2] &&
'f' == name[3] && '8' == name[4] && '>' == name[5])
{
name_cur = name + 6;
name_len -= 6;
isUtf8 = true;
}
}
if (isUtf8)
{
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)name_cur, (LONG)name_len);
}
return NSFile::CUtf8Converter::GetUnicodeFromCharPtr(name_cur, (LONG)name_len);
}
//-------------------------------------------------------------------------------------------------------------------------------
// TODO: RasterHeep

View File

@ -686,9 +686,9 @@ INT CFontManager::LoadFontFromFile(const std::wstring& sPath, const int& lFaceIn
m_pFont->SetSizeAndDpi(dSize, (UINT)dDpiX, (UINT)dDpiY);
m_sName = L"";
if (m_pFont->m_pFace && m_pFont->m_pFace->family_name)
if (m_pFont->m_pFace)
{
m_pFont->m_sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pFont->m_pFace->family_name, strlen(m_pFont->m_pFace->family_name));
m_pFont->m_sName = GetCorrectSfntName(m_pFont->m_pFace->family_name);
m_sName = m_pFont->m_sName;
}
@ -710,9 +710,10 @@ INT CFontManager::LoadFontFromFile2(NSFonts::IFontsCache* pCache, const std::wst
m_pFont->SetSizeAndDpi(dSize, (UINT)dDpiX, (UINT)dDpiY);
m_sName = L"";
if (m_pFont->m_pFace && m_pFont->m_pFace->family_name)
if (m_pFont->m_pFace)
{
m_sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pFont->m_pFace->family_name, strlen(m_pFont->m_pFace->family_name));
m_pFont->m_sName = GetCorrectSfntName(m_pFont->m_pFace->family_name);
m_sName = m_pFont->m_sName;
}
return TRUE;

View File

@ -52,7 +52,7 @@
//#define _GENERATE_FONT_MAP_
#ifdef _GENERATE_FONT_MAP_
#include "../../freetype_names/FontMaps/FontDictionary.h"
#include "./../freetype_names/FontMaps/FontDictionary.h"
#endif
namespace NSCommon
@ -460,179 +460,6 @@ namespace NSCommon
}
}
}
// -------------------------------------------
#ifndef ASC_APPLICATION_FONTS_NO_THUMBNAILS
if (L"" != strFolderThumbnails)
{
NSFonts::IFontManager* pManager = applicationFonts->GenerateFontManager();
NSFonts::IFontsCache* pCache = NSFonts::NSFontCache::Create();
pCache->SetStreams(applicationFonts->GetStreams());
pManager->SetOwnerCache(pCache);
for (int iX = 1; iX <= 2; ++iX)
{
// создаем картинку для табнейлов
double dDpi = 96 * iX;
double dW_mm = 80;
LONG lH1_px = LONG(7 * dDpi / 25.4);
LONG lWidthPix = (LONG)(dW_mm * dDpi / 25.4);
LONG lHeightPix = (LONG)(nCountFonts * lH1_px);
LONG lCountPixels = 4 * lWidthPix * lHeightPix;
BYTE* pImageData = new BYTE[lCountPixels];
memset(pImageData, 0xFF, lCountPixels);
CBgraFrame oFrame;
oFrame.put_Data(pImageData);
oFrame.put_Width((int)lWidthPix);
oFrame.put_Height((int)lHeightPix);
oFrame.put_Stride(4 * (int)lWidthPix);
for (LONG i = 3; i < lWidthPix * lHeightPix * 4; i += 4)
{
pImageData[i] = 0;
}
NSGraphics::IGraphicsRenderer* pRenderer = NSGraphics::Create();
pRenderer->CreateFromBgraFrame(&oFrame);
pRenderer->SetFontManager(pManager);
pRenderer->put_Width(lWidthPix * 25.4 / dDpi);
pRenderer->put_Height(lHeightPix * 25.4 / dDpi);
for (int index = 0; index < nCountFonts; ++index)
{
std::map<std::wstring, CFontInfoJS>::iterator pPair = mapFonts.find(arrFonts[index]);
// thumbnail
int lFontIndex = 0;
int lFaceIndex = 0;
if (pPair->second.m_lIndexR != -1)
{
lFontIndex = pPair->second.m_lIndexR;
lFaceIndex = pPair->second.m_lFaceIndexR;
}
else if (pPair->second.m_lIndexI != -1)
{
lFontIndex = pPair->second.m_lIndexI;
lFaceIndex = pPair->second.m_lFaceIndexI;
}
else if (pPair->second.m_lIndexB != -1)
{
lFontIndex = pPair->second.m_lIndexB;
lFaceIndex = pPair->second.m_lFaceIndexB;
}
else if (pPair->second.m_lIndexBI != -1)
{
lFontIndex = pPair->second.m_lIndexBI;
lFaceIndex = pPair->second.m_lFaceIndexBI;
}
std::map<LONG, std::wstring>::iterator pPair2 = mapFontFiles2.find(lFontIndex);
std::wstring strFontPath = L"";
if (mapFontFiles2.end() != pPair2)
strFontPath = pPair2->second;
pRenderer->put_FontPath(strFontPath);
pRenderer->put_FontFaceIndex(lFaceIndex);
pManager->LoadFontFromFile(strFontPath, lFaceIndex, 14, dDpi, dDpi);
bool bIsSymbol = false;
NSFonts::IFontFile* pFile = pManager->GetFile();
if (pFile)
bIsSymbol = pFile->IsSymbolic(false);
std::wstring sFontName = pPair->second.m_sName;
if (bIsSymbol)
{
NSFonts::CFontSelectFormat oSelectFormat;
oSelectFormat.wsName = new std::wstring(L"Courier New");
NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
if (NULL != pInfoCur)
{
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
}
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
pRenderer->put_FontFaceIndex(0);
}
else if (pFile)
{
int nFontNameLen = (int)sFontName.length();
bool bIsPresentAll = true;
for (int nC = 0; nC < nFontNameLen; nC++)
{
int nCMapIndex = 0;
int nGid = pFile->SetCMapForCharCode(sFontName.at(nC), &nCMapIndex);
if (0 >= nGid)
{
bIsPresentAll = false;
break;
}
else
{
double offsetG = pFile->GetCharWidth(nGid);
if (offsetG < 0.0001)
{
bIsPresentAll = false;
break;
}
}
}
if (!bIsPresentAll)
{
NSFonts::CFontSelectFormat oSelectFormat;
oSelectFormat.wsName = new std::wstring(L"Arial");
NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
if (NULL != pInfoCur)
{
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
}
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
pRenderer->put_FontFaceIndex(0);
}
}
pRenderer->PathCommandStart();
pRenderer->BeginCommand(c_nClipType);
pRenderer->PathCommandRect(0, 25.4 * (index * lH1_px) / dDpi, dW_mm, 25.4 * lH1_px / dDpi);
pRenderer->EndCommand(c_nClipType);
pRenderer->PathCommandEnd();
pRenderer->put_FontStringGID(FALSE);
pRenderer->put_FontCharSpace(0);
pRenderer->put_FontSize(14);
pRenderer->CommandDrawText(sFontName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0);
pRenderer->BeginCommand(c_nResetClipType);
pRenderer->EndCommand(c_nResetClipType);
pRenderer->CloseFont();
pCache->Clear();
applicationFonts->GetStreams()->Clear();
}
RELEASEOBJECT(pRenderer);
std::wstring strThumbnailPath = strFolderThumbnails + L"/fonts_thumbnail";
if (iX == 1)
strThumbnailPath += L".png";
else
strThumbnailPath += L"@2x.png";
oFrame.SaveFile(strThumbnailPath, 4);
}
RELEASEOBJECT(pManager);
}
#endif
NSMemoryUtils::CByteBuilder* pRangeBuilder = NULL;
int nRangeBuilderCount = 0;
@ -1035,6 +862,9 @@ namespace NSCommon
pRangeBuilder->WriteInt(nRangeBuilderCount);
pRangeBuilder->SetCurSize(nPosCur);
oFile.WriteFile(pRangeBuilder->GetData(), (DWORD)pRangeBuilder->GetCurSize());
// init ranges
applicationFonts->InitializeRanges(pRangeBuilder->GetData());
}
oFile.CloseFile();
@ -1043,6 +873,173 @@ namespace NSCommon
}
RELEASEOBJECT(pRangeBuilder);
// -------------------------------------------
#ifndef ASC_APPLICATION_FONTS_NO_THUMBNAILS
if (L"" != strFolderThumbnails)
{
NSFonts::IFontManager* pManager = applicationFonts->GenerateFontManager();
NSFonts::IFontsCache* pCache = NSFonts::NSFontCache::Create();
pCache->SetStreams(applicationFonts->GetStreams());
pManager->SetOwnerCache(pCache);
for (int iX = 1; iX <= 2; ++iX)
{
// создаем картинку для табнейлов
double dDpi = 96 * iX;
double dW_mm = 80;
LONG lH1_px = LONG(7 * dDpi / 25.4);
LONG lWidthPix = (LONG)(dW_mm * dDpi / 25.4);
LONG lHeightPix = (LONG)(nCountFonts * lH1_px);
LONG lCountPixels = 4 * lWidthPix * lHeightPix;
BYTE* pImageData = new BYTE[lCountPixels];
memset(pImageData, 0xFF, lCountPixels);
CBgraFrame oFrame;
oFrame.put_Data(pImageData);
oFrame.put_Width((int)lWidthPix);
oFrame.put_Height((int)lHeightPix);
oFrame.put_Stride(4 * (int)lWidthPix);
for (LONG i = 3; i < lWidthPix * lHeightPix * 4; i += 4)
{
pImageData[i] = 0;
}
NSGraphics::IGraphicsRenderer* pRenderer = NSGraphics::Create();
pRenderer->CreateFromBgraFrame(&oFrame);
pRenderer->SetFontManager(pManager);
pRenderer->put_Width(lWidthPix * 25.4 / dDpi);
pRenderer->put_Height(lHeightPix * 25.4 / dDpi);
for (int index = 0; index < nCountFonts; ++index)
{
std::map<std::wstring, CFontInfoJS>::iterator pPair = mapFonts.find(arrFonts[index]);
// thumbnail
int lFontIndex = 0;
int lFaceIndex = 0;
if (pPair->second.m_lIndexR != -1)
{
lFontIndex = pPair->second.m_lIndexR;
lFaceIndex = pPair->second.m_lFaceIndexR;
}
else if (pPair->second.m_lIndexI != -1)
{
lFontIndex = pPair->second.m_lIndexI;
lFaceIndex = pPair->second.m_lFaceIndexI;
}
else if (pPair->second.m_lIndexB != -1)
{
lFontIndex = pPair->second.m_lIndexB;
lFaceIndex = pPair->second.m_lFaceIndexB;
}
else if (pPair->second.m_lIndexBI != -1)
{
lFontIndex = pPair->second.m_lIndexBI;
lFaceIndex = pPair->second.m_lFaceIndexBI;
}
std::map<LONG, std::wstring>::iterator pPair2 = mapFontFiles2.find(lFontIndex);
std::wstring strFontPath = L"";
if (mapFontFiles2.end() != pPair2)
strFontPath = pPair2->second;
pRenderer->put_FontPath(strFontPath);
pRenderer->put_FontFaceIndex(lFaceIndex);
pManager->LoadFontFromFile(strFontPath, lFaceIndex, 14, dDpi, dDpi);
bool bIsSymbol = false;
NSFonts::IFontFile* pFile = pManager->GetFile();
if (pFile)
bIsSymbol = pFile->IsSymbolic(false);
std::wstring sFontName = pPair->second.m_sName;
if (bIsSymbol)
{
NSFonts::CFontSelectFormat oSelectFormat;
oSelectFormat.wsName = new std::wstring(L"Courier New");
NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
if (NULL != pInfoCur)
{
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
}
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
pRenderer->put_FontFaceIndex(0);
}
else if (pFile)
{
// у нас режим "без квадратов"
// но есть шрифты, в которых символы есть, но нулевой ширины.
// только из-за таких шрифтов делаем заглушку
int nFontNameLen = (int)sFontName.length();
bool bIsExistEmpty = false;
for (int nC = 0; nC < nFontNameLen; nC++)
{
int nCMapIndex = 0;
int nGid = pFile->SetCMapForCharCode(sFontName.at(nC), &nCMapIndex);
if (0 < nGid && 0.0001 > pFile->GetCharWidth(nGid))
{
bIsExistEmpty = true;
break;
}
}
if (bIsExistEmpty)
{
NSFonts::CFontSelectFormat oSelectFormat;
oSelectFormat.wsName = new std::wstring(L"Arial");
NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
if (NULL != pInfoCur)
{
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
}
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
pRenderer->put_FontFaceIndex(0);
}
}
pRenderer->PathCommandStart();
pRenderer->BeginCommand(c_nClipType);
pRenderer->PathCommandRect(0, 25.4 * (index * lH1_px) / dDpi, dW_mm, 25.4 * lH1_px / dDpi);
pRenderer->EndCommand(c_nClipType);
pRenderer->PathCommandEnd();
pRenderer->put_FontStringGID(FALSE);
pRenderer->put_FontCharSpace(0);
pRenderer->put_FontSize(14);
pRenderer->CommandDrawText(sFontName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0);
pRenderer->BeginCommand(c_nResetClipType);
pRenderer->EndCommand(c_nResetClipType);
pRenderer->CloseFont();
pCache->Clear();
applicationFonts->GetStreams()->Clear();
}
RELEASEOBJECT(pRenderer);
std::wstring strThumbnailPath = strFolderThumbnails + L"/fonts_thumbnail";
if (iX == 1)
strThumbnailPath += L".png";
else
strThumbnailPath += L"@2x.png";
oFrame.SaveFile(strThumbnailPath, 4);
}
RELEASEOBJECT(pManager);
}
#endif
}
#ifdef _GENERATE_FONT_MAP_

View File

@ -44,8 +44,138 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_sfobjs
#ifdef FT_SUPPORT_UTF8_IN_NAMES
// common funcs
static void tt_name_entry_unicode_from_utf16(FT_Byte* string, FT_UShort len, FT_Int** out, FT_UShort* out_len, FT_Memory memory)
{
FT_Int* unicode = NULL;
FT_UShort alloc_len = len / 2;
FT_UShort n = 0;
FT_UShort cur = 0, cur2 = 0;
FT_UShort out_len_cur = 0;
FT_Error error;
*out = NULL;
*out_len = 0;
if ( FT_NEW_ARRAY( unicode, alloc_len ) )
return;
for ( n = 0; n < alloc_len; n++ )
{
cur = FT_NEXT_USHORT( string );
if ( cur == 0 )
break;
if (cur < 0xD800 || cur > 0xDBFF)
{
unicode[out_len_cur++] = cur;
}
else
{
cur2 = FT_NEXT_USHORT( string );
++n;
unicode[out_len_cur++] = ((((cur - 0xD800) & 0x03FF) << 10) | ((cur2 - 0xDC00) & 0x03FF)) + 0x10000;
}
}
*out = unicode;
*out_len = out_len_cur;
}
static FT_String* tt_name_entry_utf8_from_unicode(FT_Int* unicode, FT_UShort len, FT_Memory memory)
{
FT_String* ret = NULL;
FT_String* retCur = NULL;
FT_UShort index = 0;
FT_UInt alloc_len = 6 * len + 6 + 1;
FT_Int code;
FT_Error error;
if (0 == len)
return ret;
if ( FT_NEW_ARRAY( ret, alloc_len ) )
return ret;
retCur = ret;
*retCur++ = '<';
*retCur++ = 'u';
*retCur++ = 't';
*retCur++ = 'f';
*retCur++ = '8';
*retCur++ = '>';
for ( index = 0; index < len; index++ )
{
code = unicode[index];
if (code < 0x80)
{
*retCur++ = (FT_String)code;
}
else if (code < 0x0800)
{
*retCur++ = (0xC0 | (code >> 6));
*retCur++ = (0x80 | (code & 0x3F));
}
else if (code < 0x10000)
{
*retCur++ = (0xE0 | (code >> 12));
*retCur++ = (0x80 | (code >> 6 & 0x3F));
*retCur++ = (0x80 | (code & 0x3F));
}
else if (code < 0x1FFFFF)
{
*retCur++ = (0xF0 | (code >> 18));
*retCur++ = (0x80 | (code >> 12 & 0x3F));
*retCur++ = (0x80 | (code >> 6 & 0x3F));
*retCur++ = (0x80 | (code & 0x3F));
}
else if (code < 0x3FFFFFF)
{
*retCur++ = (0xF8 | (code >> 24));
*retCur++ = (0x80 | (code >> 18 & 0x3F));
*retCur++ = (0x80 | (code >> 12 & 0x3F));
*retCur++ = (0x80 | (code >> 6 & 0x3F));
*retCur++ = (0x80 | (code & 0x3F));
}
else if (code < 0x7FFFFFFF)
{
*retCur++ = (0xFC | (code >> 30));
*retCur++ = (0x80 | (code >> 24 & 0x3F));
*retCur++ = (0x80 | (code >> 18 & 0x3F));
*retCur++ = (0x80 | (code >> 12 & 0x3F));
*retCur++ = (0x80 | (code >> 6 & 0x3F));
*retCur++ = (0x80 | (code & 0x3F));
}
}
*retCur = 0;
return ret;
}
// ft interface
static FT_String* tt_name_entry_utf8_from_utf16(TT_NameEntry entry,
FT_Memory memory)
{
FT_Int* unicode = NULL;
FT_UShort unicode_len = 0;
FT_String* retValue = NULL;
tt_name_entry_unicode_from_utf16(entry->string, entry->stringLength, &unicode, &unicode_len, memory);
retValue = tt_name_entry_utf8_from_unicode(unicode, unicode_len, memory);
FT_FREE(unicode);
return retValue;
}
/* convert a UTF-16 name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
FT_Memory memory )
{
return tt_name_entry_utf8_from_utf16(entry, memory);
}
#else
/* convert a UTF-16 name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
@ -79,7 +209,7 @@
return string;
}
#endif
/* convert an Apple Roman or symbol name entry to ASCII */
static FT_String*

View File

@ -623,6 +623,7 @@ namespace NSFonts
virtual void InitializeFromFolder(std::wstring strFolder, bool bIsCheckSelection = true) = 0;
virtual void Initialize(bool bIsCheckSelection = true) = 0;
virtual void InitializeRanges(unsigned char* data) = 0;
virtual std::vector<std::wstring> GetSetupFontFiles() = 0;
virtual void InitializeFromArrayFiles(std::vector<std::wstring>& files, int nFlag = 0) = 0;

View File

@ -32,6 +32,8 @@ DEFINES += \
MNG_STORE_CHUNKS\
MNG_ERROR_TELLTALE
DEFINES += FT_SUPPORT_UTF8_IN_NAMES
core_linux {
DEFINES += \
HAVE_UNISTD_H

View File

@ -3333,6 +3333,11 @@ void BinaryCommentReader::addThreadedComment(OOX::Spreadsheet::CSi& oSi, OOX::Sp
pText->m_sText.append(L"\n\n");
}
}
//Fix Excel recovery error
if (pText->m_sText.length() > OOX::Spreadsheet::SpreadsheetCommon::MAX_STRING_LEN)
{
pText->m_sText.erase(OOX::Spreadsheet::SpreadsheetCommon::MAX_STRING_LEN);
}
oSi.m_arrItems.push_back(pText);
}