Copyright 2010, SIL International All rights reserved.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should also have received a copy of the GNU Lesser General Public License along with this library in the file named "LICENSE". If not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA or visit their web page on the internet at http://www.fsf.org/licenses/lgpl.html.
Alternatively, the contents of this file may be used under the terms of the Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public License, as published by the Free Software Foundation, either version 2 of the License or (at your option) any later version.
*/ #include <cstring>
if (!p) returntrue; if (sill.size() < 12) returnfalse; if (be::read<uint32>(p) != 0x00010000UL) returnfalse;
m_numLanguages = be::read<uint16>(p);
m_langFeats = new LangFeaturePair[m_numLanguages]; if (!m_langFeats || !m_FeatureMap.m_numFeats) { m_numLanguages = 0; returntrue; } //defensive
p += 6; // skip the fast search if (sill.size() < m_numLanguages * 8U + 12) returnfalse;
for (int i = 0; i < m_numLanguages; i++)
{
uint32 langid = be::read<uint32>(p);
uint16 numSettings = be::read<uint16>(p);
uint16 offset = be::read<uint16>(p); if (offset + 8U * numSettings > sill.size() && numSettings > 0) returnfalse;
Features* feats = new Features(m_FeatureMap.m_defaultFeatures); if (!feats) returnfalse; const byte *pLSet = sill + offset;
// Apply langauge specific settings for (int j = 0; j < numSettings; j++)
{
uint32 name = be::read<uint32>(pLSet);
uint16 val = be::read<uint16>(pLSet);
pLSet += 2; const FeatureRef* pRef = m_FeatureMap.findFeatureRef(name); if (pRef) pRef->applyValToFeature(val, *feats);
} // Add the language id feature which is always feature id 1 const FeatureRef* pRef = m_FeatureMap.findFeatureRef(1); if (pRef) pRef->applyValToFeature(langid, *feats);
Features* SillMap::cloneFeatures(uint32 langname/*0 means default*/) const
{ if (langname)
{ // the number of languages in a font is usually small e.g. 8 in Doulos // so this loop is not very expensive for (uint16 i = 0; i < m_numLanguages; i++)
{ if (m_langFeats[i].m_lang == langname) returnnew Features(*m_langFeats[i].m_pFeatures);
}
} returnnew Features (m_FeatureMap.m_defaultFeatures);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.