本文整理汇总了C++中LE_FAILURE函数的典型用法代码示例。如果您正苦于以下问题:C++ LE_FAILURE函数的具体用法?C++ LE_FAILURE怎么用?C++ LE_FAILURE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LE_FAILURE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glyphProcessing
// Input: characters, tags
// Output: glyphs, char indices
le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
}
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
le_int32 retCount = OpenTypeLayoutEngine::glyphProcessing(chars, offset, count, max, rightToLeft, glyphStorage, success);
if (LE_FAILURE(success)) {
return 0;
}
if (fVersion2) {
IndicReordering::finalReordering(glyphStorage,retCount);
IndicReordering::applyPresentationForms(glyphStorage,retCount);
OpenTypeLayoutEngine::glyphSubstitution(count,max, rightToLeft, glyphStorage, success);
} else {
IndicReordering::adjustMPres(fMPreFixups, glyphStorage, success);
}
return retCount;
}
示例2: SWAPW
U_NAMESPACE_BEGIN
le_uint32 LookupProcessor::applyLookupTable(const LookupTable *lookupTable, GlyphIterator *glyphIterator,
const LEFontInstance *fontInstance, LEErrorCode& success) const
{
if (LE_FAILURE(success)) {
return 0;
}
le_uint16 lookupType = SWAPW(lookupTable->lookupType);
le_uint16 subtableCount = SWAPW(lookupTable->subTableCount);
le_int32 startPosition = glyphIterator->getCurrStreamPosition();
le_uint32 delta;
for (le_uint16 subtable = 0; subtable < subtableCount; subtable += 1) {
const LookupSubtable *lookupSubtable = lookupTable->getLookupSubtable(subtable);
delta = applySubtable(lookupSubtable, lookupType, glyphIterator, fontInstance, success);
if (delta > 0 && LE_FAILURE(success)) {
return 1;
}
glyphIterator->setCurrStreamPosition(startPosition);
}
return 1;
}
示例3: characterProcessing
// Input: characters
// Output: characters, char indices, tags
// Returns: output character count
le_int32 ArabicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
}
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
glyphStorage.adoptGlyphCount(count);
glyphStorage.allocateAuxData(success);
if (LE_FAILURE(success)) {
success = LE_MEMORY_ALLOCATION_ERROR;
return 0;
}
switch (fScriptCode) {
case arabScriptCode:
{
ArabicShaping::shape(chars, offset, count, max, rightToLeft, glyphStorage);
break;
}
case hebrScriptCode:
HebrewShaping::shape(chars, offset, count, max, rightToLeft, glyphStorage);
break;
}
return count;
}
示例4: mapCharsToGlyphs
// Input: characters, tags
// Output: glyphs, char indices
le_int32 OpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
}
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
mapCharsToGlyphs(chars, offset, count, rightToLeft, rightToLeft, glyphStorage, success);
if (LE_FAILURE(success)) {
return 0;
}
if (fGSUBTable.isValid()) {
if (fScriptTagV2 != nullScriptTag && fGSUBTable->coversScriptAndLanguage(fGSUBTable, fScriptTagV2, fLangSysTag, success)) {
count = fGSUBTable->process(fGSUBTable, glyphStorage, rightToLeft, fScriptTagV2, fLangSysTag, fGDEFTable, fSubstitutionFilter,
fFeatureMap, fFeatureMapCount, fFeatureOrder, success);
} else {
count = fGSUBTable->process(fGSUBTable, glyphStorage, rightToLeft, fScriptTag, fLangSysTag, fGDEFTable, fSubstitutionFilter,
fFeatureMap, fFeatureMapCount, fFeatureOrder, success);
}
}
return count;
}
示例5: SWAPW
U_NAMESPACE_BEGIN
le_uint32 LookupProcessor::applyLookupTable(const LEReferenceTo<LookupTable> &lookupTable, GlyphIterator *glyphIterator,
const LEFontInstance *fontInstance, LEErrorCode& success) const
{
if (LE_FAILURE(success)) {
return 0;
}
le_uint16 lookupType = SWAPW(lookupTable->lookupType);
le_uint16 subtableCount = SWAPW(lookupTable->subTableCount);
le_int32 startPosition = glyphIterator->getCurrStreamPosition();
le_uint32 delta;
for (le_uint16 subtable = 0; subtable < subtableCount; subtable += 1) {
LEReferenceTo<LookupSubtable> lookupSubtable = lookupTable->getLookupSubtable(lookupTable, subtable, success);
delta = applySubtable(lookupSubtable, lookupType, glyphIterator, fontInstance, success);
if (delta > 0 && LE_FAILURE(success)) {
#if LE_TRACE
_LETRACE("Posn #%d, type %X, applied subtable #%d/%d - %s\n", startPosition, lookupType, subtable, subtableCount, u_errorName((UErrorCode)success));
#endif
return 1;
}
glyphIterator->setCurrStreamPosition(startPosition);
}
return 1;
}
示例6: positionGlyphs
// Input: glyphs
// Output: positions
void LayoutEngine::positionGlyphs(LEGlyphStorage &glyphStorage, float x, float y, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
}
glyphStorage.allocatePositions(success);
if (LE_FAILURE(success)) {
return;
}
le_int32 i, glyphCount = glyphStorage.getGlyphCount();
for (i = 0; i < glyphCount; i += 1) {
LEPoint advance;
glyphStorage.setPosition(i, x, y, success);
fFontInstance->getGlyphAdvance(glyphStorage[i], advance);
x += advance.fX;
y += advance.fY;
}
glyphStorage.setPosition(glyphCount, x, y, success);
}
示例7: fParagraphLayout
Paragraph::Paragraph(const LEUnicode chars[], int32_t charCount, const FontRuns *fontRuns, LEErrorCode &status)
: fParagraphLayout(NULL), fLineCount(0), fLinesMax(0), fLinesGrow(LINE_GROW), fLines(NULL), fChars(NULL),
fLineHeight(-1), fAscent(-1), fWidth(-1), fHeight(-1)
{
if (LE_FAILURE(status)) {
return;
}
LocaleRuns *locales = NULL;
fChars = LE_NEW_ARRAY(LEUnicode, charCount);
LE_ARRAY_COPY(fChars, chars, charCount);
fParagraphLayout = new ParagraphLayout(fChars, charCount, fontRuns, NULL, NULL, locales, UBIDI_DEFAULT_LTR, FALSE, status);
if (LE_FAILURE(status)) {
return;
}
le_int32 ascent = fParagraphLayout->getAscent();
le_int32 descent = fParagraphLayout->getDescent();
le_int32 leading = fParagraphLayout->getLeading();
fLineHeight = ascent + descent + leading;
fAscent = ascent;
}
示例8: characterProcessing
le_int32 OpenTypeLayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
LEUnicode *outChars = NULL;
LEGlyphStorage fakeGlyphStorage;
le_int32 outCharCount, outGlyphCount, fakeGlyphCount;
if (LE_FAILURE(success)) {
return 0;
}
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
outCharCount = characterProcessing(chars, offset, count, max, rightToLeft, outChars, fakeGlyphStorage, success);
if (LE_FAILURE(success)) {
return 0;
}
if (outChars != NULL) {
fakeGlyphCount = glyphProcessing(outChars, 0, outCharCount, outCharCount, rightToLeft, fakeGlyphStorage, success);
LE_DELETE_ARRAY(outChars); // FIXME: a subclass may have allocated this, in which case this delete might not work...
//adjustGlyphs(outChars, 0, outCharCount, rightToLeft, fakeGlyphs, fakeGlyphCount);
} else {
fakeGlyphCount = glyphProcessing(chars, offset, count, max, rightToLeft, fakeGlyphStorage, success);
//adjustGlyphs(chars, offset, count, rightToLeft, fakeGlyphs, fakeGlyphCount);
}
outGlyphCount = glyphPostProcessing(fakeGlyphStorage, glyphStorage, success);
return outGlyphCount;
}
示例9: characterProcessing
le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/,
LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
}
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
glyphStorage.allocateGlyphArray(count, FALSE, success);
glyphStorage.allocateAuxData(success);
if (LE_FAILURE(success)) {
return 0;
}
// FIXME: do we want to add the 'trad' feature for 'ZHT' and the
// 'smpl' feature for 'ZHS'? If we do this, we can remove the exact
// flag from the language tag lookups, so we can use these features
// with the default LangSys...
for (le_int32 i = 0; i < count; i += 1) {
glyphStorage.setAuxData(i, features, success);
}
return count;
}
示例10: sprintf
const LEFontInstance *FontMap::getScriptFont(le_int32 scriptCode, LEErrorCode &status)
{
if (LE_FAILURE(status)) {
return NULL;
}
if (scriptCode <= -1 || scriptCode >= scriptCodeCount) {
status = LE_ILLEGAL_ARGUMENT_ERROR;
return NULL;
}
le_int32 fontIndex = fFontIndices[scriptCode];
if (fontIndex < 0) {
sprintf(errorMessage, "No font was set for script %s", uscript_getName((UScriptCode) scriptCode));
fGUISupport->postErrorMessage(errorMessage, "Font Map Error");
status = LE_FONT_FILE_NOT_FOUND_ERROR;
return NULL;
}
if (fFontInstances[fontIndex] == NULL) {
fFontInstances[fontIndex] = openFont(fFontNames[fontIndex], fPointSize, status);
if (LE_FAILURE(status)) {
sprintf(errorMessage, "Could not open font file %s", fFontNames[fontIndex]);
fGUISupport->postErrorMessage(errorMessage, "Font Map Error");
return NULL;
}
}
return fFontInstances[fontIndex];
}
示例11: main
int main(int argc, char *argv[])
{
le_int32 failures = 0;
for (le_int32 test = 0; test < testCount; test += 1) {
LEErrorCode fontStatus = LE_NO_ERROR;
printf("Test %d, font = %s... ", test, testInputs[test].fontName);
PortableFontInstance fontInstance(testInputs[test].fontName, 12, fontStatus);
if (LE_FAILURE(fontStatus)) {
printf("could not open font.\n");
continue;
}
LEErrorCode success = LE_NO_ERROR;
LayoutEngine *engine = LayoutEngine::layoutEngineFactory(&fontInstance, testInputs[test].scriptCode, -1, success);
le_int32 textLength = testInputs[test].textLength;
le_bool result;
TestResult actual;
if (LE_FAILURE(success)) {
// would be nice to print the script name here, but
// don't want to maintain a table, and don't want to
// require ICU just for the script name...
printf("could not create a LayoutEngine.\n");
continue;
}
actual.glyphCount = engine->layoutChars(testInputs[test].text, 0, textLength, textLength, testInputs[test].rightToLeft, 0, 0, success);
actual.glyphs = new LEGlyphID[actual.glyphCount];
actual.indices = new le_int32[actual.glyphCount];
actual.positions = new float[actual.glyphCount * 2 + 2];
engine->getGlyphs(actual.glyphs, success);
engine->getCharIndices(actual.indices, success);
engine->getGlyphPositions(actual.positions, success);
result = compareResults(test, &testResults[test], &actual);
if (result) {
printf("passed.\n");
} else {
failures += 1;
printf("failed.\n");
}
delete[] actual.positions;
delete[] actual.indices;
delete[] actual.glyphs;
delete engine;
}
return failures;
}
示例12: SWAPW
LEReferenceTo<ScriptTable> ScriptListTable::findScript(const LETableReference &base, LETag scriptTag, LEErrorCode &success) const
{
if (LE_FAILURE(success) ) {
return LEReferenceTo<ScriptTable>(); // get out
}
/*
* There are some fonts that have a large, bogus value for scriptCount. To try
* and protect against this, we use the offset in the first scriptRecord,
* which we know has to be past the end of the scriptRecordArray, to compute
* a value which is greater than or equal to the actual script count.
*
* Note: normally, the first offset will point to just after the scriptRecordArray,
* but there's no guarantee of this, only that it's *after* the scriptRecordArray.
* Because of this, a binary serach isn't safe, because the new count may include
* data that's not actually in the scriptRecordArray and hence the array will appear
* to be unsorted.
*/
le_uint16 count = SWAPW(scriptCount);
if (count == 0) {
return LEReferenceTo<ScriptTable>(); // no items, no search
}
// attempt to construct a ref with at least one element
LEReferenceToArrayOf<ScriptRecord> oneElementTable(base, success, &scriptRecordArray[0], 1);
if( LE_FAILURE(success) ) {
return LEReferenceTo<ScriptTable>(); // couldn't even read the first record - bad font.
}
le_uint16 limit = ((SWAPW(scriptRecordArray[0].offset) - sizeof(ScriptListTable)) / sizeof(scriptRecordArray)) + ANY_NUMBER;
Offset scriptTableOffset = 0;
if (count > limit) {
// the scriptCount value is bogus; do a linear search
// because limit may still be too large.
LEReferenceToArrayOf<ScriptRecord> scriptRecordArrayRef(base, success, &scriptRecordArray[0], limit);
for(le_int32 s = 0; (s < limit)&&LE_SUCCESS(success); s += 1) {
if (SWAPT(scriptRecordArrayRef(s,success).tag) == scriptTag) {
scriptTableOffset = SWAPW(scriptRecordArrayRef(s,success).offset);
break;
}
}
} else {
LEReferenceToArrayOf<ScriptRecord> scriptRecordArrayRef(base, success, &scriptRecordArray[0], count);
scriptTableOffset = OpenTypeUtilities::getTagOffset(scriptTag, scriptRecordArrayRef, success);
}
if (scriptTableOffset != 0) {
return LEReferenceTo<ScriptTable>(base, success, scriptTableOffset);
}
return LEReferenceTo<ScriptTable>();
}
示例13: XeTeXFontInst
XeTeXFontInst_FT2::XeTeXFontInst_FT2(const char* pathname, int index, float pointSize, LEErrorCode &status)
: XeTeXFontInst(pointSize, status)
, face(0)
, fFreeTypeOnly(false)
{
if (LE_FAILURE(status)) {
return;
}
FT_Error err;
if (!gFreeTypeLibrary) {
err = FT_Init_FreeType(&gFreeTypeLibrary);
if (err != 0) {
fprintf(stderr, "FreeType initialization failed! (%d)\n", err);
exit(1);
}
}
err = FT_New_Face(gFreeTypeLibrary, (char*)pathname, index, &face);
if (err != 0) {
status = LE_FONT_FILE_NOT_FOUND_ERROR;
return;
}
/* for non-sfnt-packaged fonts (presumably Type 1), see if there is an AFM file we can attach */
if (index == 0 && !FT_IS_SFNT(face)) {
char* afm = new char[strlen((const char*)pathname) + 5]; // room to append ".afm"
strcpy(afm, (const char*)pathname);
char* p = strrchr(afm, '.');
if (p == NULL || strlen(p) != 4 || tolower(*(p+1)) != 'p' || tolower(*(p+2)) != 'f')
strcat(afm, ".afm"); // append .afm if the extension didn't seem to be .pf[ab]
else
strcpy(p, ".afm"); // else replace extension with .afm
FT_Attach_File(face, afm); // ignore error code; AFM might not exist
delete[] afm;
fFreeTypeOnly = true;
}
initialize(status);
if (LE_FAILURE(status))
return;
char buf[20];
if (index > 0)
sprintf(buf, ":%d", index);
else
buf[0] = 0;
fFilename = new char[strlen(pathname) + 2 + strlen(buf) + 1];
sprintf(fFilename, "[%s%s]", pathname, buf);
}
示例14: getGlyphCoverage
le_uint32 PairPositioningFormat1Subtable::process(const LEReferenceTo<PairPositioningFormat1Subtable> &base, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode &success) const
{
LEGlyphID firstGlyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(base, firstGlyph, success);
if (LE_FAILURE(success)) {
return 0;
}
GlyphIterator tempIterator(*glyphIterator);
if (coverageIndex >= 0 && glyphIterator->next()) {
Offset pairSetTableOffset = SWAPW(pairSetTableOffsetArray[coverageIndex]);
LEReferenceTo<PairSetTable> pairSetTable(base, success, ((char *) this + pairSetTableOffset));
if (LE_FAILURE(success)) {
return 0;
}
le_uint16 pairValueCount = SWAPW(pairSetTable->pairValueCount);
le_int16 valueRecord1Size = ValueRecord::getSize(SWAPW(valueFormat1));
le_int16 valueRecord2Size = ValueRecord::getSize(SWAPW(valueFormat2));
le_int16 recordSize = sizeof(PairValueRecord) - sizeof(ValueRecord) + valueRecord1Size + valueRecord2Size;
LEGlyphID secondGlyph = glyphIterator->getCurrGlyphID();
LEReferenceTo<PairValueRecord> pairValueRecord;
if (pairValueCount != 0) {
pairValueRecord = findPairValueRecord(base, (TTGlyphID) LE_GET_GLYPH(secondGlyph), pairSetTable->pairValueRecordArray, pairValueCount, recordSize, success);
}
if (pairValueRecord.isEmpty()) {
return 0;
}
if (valueFormat1 != 0) {
pairValueRecord->valueRecord1.adjustPosition(SWAPW(valueFormat1), (char *) this, tempIterator, fontInstance);
}
if (valueFormat2 != 0) {
const ValueRecord *valueRecord2 = (const ValueRecord *) ((char *) &pairValueRecord->valueRecord1 + valueRecord1Size);
valueRecord2->adjustPosition(SWAPW(valueFormat2), (char *) this, *glyphIterator, fontInstance);
}
// back up glyphIterator so second glyph can be
// first glyph in the next pair
glyphIterator->prev();
return 1;
}
return 0;
}
示例15: CharSubstitutionFilter
le_int32 LayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
}
if (offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
const GlyphSubstitutionTableHeader *canonGSUBTable = (GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable;
LETag scriptTag = OpenTypeLayoutEngine::getScriptTag(fScriptCode);
LETag langSysTag = OpenTypeLayoutEngine::getLangSysTag(fLanguageCode);
le_int32 i, dir = 1, out = 0, outCharCount = count;
if (rightToLeft) {
out = count - 1;
dir = -1;
}
if (canonGSUBTable->coversScript(scriptTag)) {
CharSubstitutionFilter *substitutionFilter = new CharSubstitutionFilter(fFontInstance);
glyphStorage.allocateGlyphArray(count, rightToLeft, success);
glyphStorage.allocateAuxData(success);
if (LE_FAILURE(success)) {
return 0;
}
for (i = 0; i < count; i += 1, out += dir) {
glyphStorage[i] = (LEGlyphID) chars[offset + i];
glyphStorage.setAuxData(i, (void *) canonFeatures, success);
}
outCharCount = canonGSUBTable->process(glyphStorage, rightToLeft, scriptTag, langSysTag, NULL, substitutionFilter, NULL);
outChars = LE_NEW_ARRAY(LEUnicode, outCharCount);
for (i = 0; i < outCharCount; i += 1) {
outChars[i] = (LEUnicode) LE_GET_GLYPH(glyphStorage[i]);
}
delete substitutionFilter;
}
return outCharCount;
}