ICU-22713 Delete long since dead code.

None of the code in this directory is ever compiled unless USING_ICULEHB
is set, so all such conditionally compiled code has been dead ever since
commit 4136a2f257 deleted the layout engine.
This commit is contained in:
Fredrik Roubert 2024-12-20 13:59:19 +09:00 committed by Fredrik Roubert
parent df0422ed3f
commit c49a9c2a33
16 changed files with 3 additions and 1526 deletions

View file

@ -36,7 +36,6 @@ LIBS = $(LIBICULX) $(LIBICUUC) $(LIBICUI18N) $(LIBCTESTFW) $(LIBICUTOOLUTIL) $(D
COMMONOBJECTS = letsutil.o cmaps.o FontTableCache.o SimpleFontInstance.o PortableFontInstance.o
TESTOBJECTS = letest.o
CTESTOBJECTS = cfonts.o xmlreader.o cletest.o
GENOBJECTS = gendata.o
OBJECTS = $(COMMONOBJECTS) $(TESTOBJECTS) $(GENOBJECTS)
@ -67,7 +66,7 @@ dist-local:
clean-local:
test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
$(RMV) $(COMMONOBJECTS) $(TESTOBJECTS) $(CTESTOBJECTS) $(GENOBJECTS) $(TARGET)
$(RMV) $(COMMONOBJECTS) $(TESTOBJECTS) $(GENOBJECTS) $(TARGET)
distclean-local: clean-local
$(RMV) Makefile
@ -83,7 +82,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(TESTTARGET) : $(COMMONOBJECTS) $(TESTOBJECTS) $(CTESTOBJECTS)
$(TESTTARGET) : $(COMMONOBJECTS) $(TESTOBJECTS)
$(LINK.cc) $(OUTOPT)$@ $^ $(LIBS)
$(POST_BUILD_STEP)

View file

@ -19,10 +19,6 @@
#include "layout/LETypes.h"
#include "layout/LEFontInstance.h"
#ifndef USING_ICULEHB
#include "layout/CanonShaping.h"
#endif
#include "SimpleFontInstance.h"
SimpleFontInstance::SimpleFontInstance(float pointSize, LEErrorCode &status)
@ -41,18 +37,9 @@ SimpleFontInstance::~SimpleFontInstance()
// nothing to do...
}
const void *SimpleFontInstance::getFontTable(LETag tableTag, size_t &length) const
const void *SimpleFontInstance::getFontTable(LETag /*tableTag*/, size_t &length) const
{
length = -1; // unknown for this test.
#ifndef USING_ICULEHB
if (tableTag == LE_GSUB_TABLE_TAG) {
return CanonShaping::glyphSubstitutionTable;
}
if (tableTag == LE_GDEF_TABLE_TAG) {
return CanonShaping::glyphDefinitionTable;
}
#endif
return nullptr;
}

View file

@ -1,74 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*
* (C) Copyright IBM Corp. 1998-2014 - All Rights Reserved
*
*/
#ifndef USING_ICULEHB /* C API not available under HB */
#include "layout/LETypes.h"
#include "loengine.h"
#include "PortableFontInstance.h"
#include "SimpleFontInstance.h"
U_CDECL_BEGIN
le_font *le_portableFontOpen(const char *fileName,
float pointSize,
LEErrorCode *status)
{
return (le_font *) new PortableFontInstance(fileName, pointSize, *status);
}
le_font *le_simpleFontOpen(float pointSize,
LEErrorCode *status)
{
return (le_font *) new SimpleFontInstance(pointSize, *status);
}
void le_fontClose(le_font *font)
{
LEFontInstance *fontInstance = (LEFontInstance *) font;
delete fontInstance;
}
const char *le_getNameString(le_font *font, le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language)
{
PortableFontInstance *pfi = (PortableFontInstance *) font;
return pfi->getNameString(nameID, platform, encoding, language);
}
const LEUnicode16 *le_getUnicodeNameString(le_font *font, le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language)
{
PortableFontInstance *pfi = (PortableFontInstance *) font;
return pfi->getUnicodeNameString(nameID, platform, encoding, language);
}
void le_deleteNameString(le_font *font, const char *name)
{
PortableFontInstance *pfi = (PortableFontInstance *) font;
pfi->deleteNameString(name);
}
void le_deleteUnicodeNameString(le_font *font, const LEUnicode16 *name)
{
PortableFontInstance *pfi = (PortableFontInstance *) font;
pfi->deleteNameString(name);
}
le_uint32 le_getFontChecksum(le_font *font)
{
PortableFontInstance *pfi = (PortableFontInstance *) font;
return pfi->getFontChecksum();
}
U_CDECL_END
#endif

View file

@ -1,37 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*
* (C) Copyright IBM Corp. 1998-2014 - All Rights Reserved
*
*/
#ifndef USING_ICULEHB /* C API not available under HB */
#ifndef __CFONTS_H
#define __CFONTS_H
#include "LETypes.h"
#include "loengine.h"
le_font *le_portableFontOpen(const char *fileName,
float pointSize,
LEErrorCode *status);
le_font *le_simpleFontOpen(float pointSize,
LEErrorCode *status);
void le_fontClose(le_font *font);
const char *le_getNameString(le_font *font, le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language);
const LEUnicode16 *le_getUnicodeNameString(le_font *font, le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language);
void le_deleteNameString(le_font *font, const char *name);
void le_deleteUnicodeNameString(le_font *font, const LEUnicode16 *name);
le_uint32 le_getFontChecksum(le_font *font);
#endif
#endif

View file

@ -1,749 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 1999-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#ifndef USING_ICULEHB /* C API not available under HB */
#include "unicode/utypes.h"
#include "unicode/ubidi.h"
#include "unicode/uscript.h"
#include "unicode/ctest.h"
#include "layout/LETypes.h"
#include "layout/LEScripts.h"
#include "layout/loengine.h"
#include "layout/playout.h"
#include "layout/plruns.h"
#include "cfonts.h"
#include "letest.h"
#include "sfnt.h"
#include "xmlreader.h"
#include "putilimp.h" /* for U_FILE_SEP_STRING */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define CH_COMMA 0x002C
U_CDECL_BEGIN
static void U_CALLCONV ParamTest(void)
{
LEErrorCode status = LE_NO_ERROR;
le_font *font = le_simpleFontOpen(12, &status);
le_engine *engine = le_create(font, arabScriptCode, -1, 0, &status);
LEGlyphID *glyphs = NULL;
le_int32 *indices = NULL;
float *positions = NULL;
le_int32 glyphCount = 0;
float x = 0.0, y = 0.0;
LEUnicode chars[] = {
0x0045, 0x006E, 0x0067, 0x006C, 0x0069, 0x0073, 0x0068, 0x0020, /* "English " */
0x0645, 0x0627, 0x0646, 0x062A, 0x0648, 0x0634, /* MEM ALIF KAF NOON TEH WAW SHEEN */
0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x02E /* " text." */
};
glyphCount = le_getGlyphCount(engine, &status);
if (glyphCount != 0) {
log_err("Calling getGlyphCount() on an empty layout returned %d.\n", glyphCount);
}
glyphs = NEW_ARRAY(LEGlyphID, glyphCount + 10);
indices = NEW_ARRAY(le_int32, glyphCount + 10);
positions = NEW_ARRAY(float, glyphCount + 10);
le_getGlyphs(engine, NULL, &status);
if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
log_err("Calling getGlyphs(NULL, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
}
status = LE_NO_ERROR;
le_getGlyphs(engine, glyphs, &status);
if (status != LE_NO_LAYOUT_ERROR) {
log_err("Calling getGlyphs(glyphs, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
}
status = LE_NO_ERROR;
le_getCharIndices(engine, NULL, &status);
if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
log_err("Calling getCharIndices(NULL, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
}
status = LE_NO_ERROR;
le_getCharIndices(engine, indices, &status);
if (status != LE_NO_LAYOUT_ERROR) {
log_err("Calling getCharIndices(indices, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
}
status = LE_NO_ERROR;
le_getCharIndicesWithBase(engine, NULL, 1024, &status);
if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
log_err("Calling getCharIndices(NULL, 1024, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
}
status = LE_NO_ERROR;
le_getCharIndicesWithBase(engine, indices, 1024, &status);
if (status != LE_NO_LAYOUT_ERROR) {
log_err("Calling getCharIndices(indices, 1024, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
}
status = LE_NO_ERROR;
le_getGlyphPositions(engine, NULL, &status);
if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
log_err("Calling getGlyphPositions(NULL, status) did not return LE_ILLEGAL_ARGUMENT_ERROR.\n");
}
status = LE_NO_ERROR;
le_getGlyphPositions(engine, positions, &status);
if (status != LE_NO_LAYOUT_ERROR) {
log_err("Calling getGlyphPositions(positions, status) on an empty layout did not return LE_NO_LAYOUT_ERROR.\n");
}
DELETE_ARRAY(positions);
DELETE_ARRAY(indices);
DELETE_ARRAY(glyphs);
status = LE_NO_ERROR;
glyphCount = le_layoutChars(engine, NULL, 0, 0, 0, false, 0.0, 0.0, &status);
if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
log_err("Calling layoutChars(NULL, 0, 0, 0, false, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
}
status = LE_NO_ERROR;
glyphCount = le_layoutChars(engine, chars, -1, 6, 20, true, 0.0, 0.0, &status);
if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
log_err("Calling layoutChars(chars, -1, 6, 20, true, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
}
status = LE_NO_ERROR;
glyphCount = le_layoutChars(engine, chars, 8, -1, 20, true, 0.0, 0.0, &status);
if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
log_err("Calling layoutChars(chars, 8, -1, 20, true, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
}
status = LE_NO_ERROR;
glyphCount = le_layoutChars(engine, chars, 8, 6, -1, true, 0.0, 0.0, &status);
if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
log_err("Calling layoutChars((chars, 8, 6, -1, true, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
}
status = LE_NO_ERROR;
glyphCount = le_layoutChars(engine, chars, 8, 6, 10, true, 0.0, 0.0, &status);
if (status != LE_ILLEGAL_ARGUMENT_ERROR) {
log_err("Calling layoutChars(chars, 8, 6, 10, true, 0.0, 0.0, status) did not fail w/ LE_ILLEGAL_ARGUMENT_ERROR.\n");
}
status = LE_NO_ERROR;
glyphCount = le_layoutChars(engine, chars, 8, 6, 20, true, 0.0, 0.0, &status);
if (LE_FAILURE(status)) {
log_err("Calling layoutChars(chars, 8, 6, 20, true, 0.0, 0.0, status) failed.\n");
goto bail;
}
le_getGlyphPosition(engine, -1, &x, &y, &status);
if (status != LE_INDEX_OUT_OF_BOUNDS_ERROR) {
log_err("Calling getGlyphPosition(-1, x, y, status) did not fail w/ LE_INDEX_OUT_OF_BOUNDS_ERROR.\n");
}
status = LE_NO_ERROR;
le_getGlyphPosition(engine, glyphCount + 1, &x, &y, &status);
if (status != LE_INDEX_OUT_OF_BOUNDS_ERROR) {
log_err("Calling getGlyphPosition(glyphCount + 1, x, y, status) did not fail w/ LE_INDEX_OUT_OF_BOUNDS_ERROR.\n");
}
bail:
le_close(engine);
le_fontClose(font);
}
U_CDECL_END
U_CDECL_BEGIN
static void U_CALLCONV FactoryTest(void)
{
LEErrorCode status = LE_NO_ERROR;
le_font *font = le_simpleFontOpen(12, &status);
le_engine *engine = NULL;
le_int32 scriptCode;
for(scriptCode = 0; scriptCode < scriptCodeCount; scriptCode += 1) {
status = LE_NO_ERROR;
engine = le_create(font, scriptCode, -1, 0, &status);
if (LE_FAILURE(status)) {
log_err("Could not create a LayoutEngine for script \'%s\'.\n", uscript_getShortName((UScriptCode)scriptCode));
}
le_close(engine);
}
le_fontClose(font);
}
U_CDECL_END
U_CDECL_BEGIN
static void U_CALLCONV AccessTest(void)
{
LEErrorCode status = LE_NO_ERROR;
le_font *font = le_simpleFontOpen(12, &status);
le_engine *engine =le_create(font, arabScriptCode, -1, 0, &status);
le_int32 glyphCount;
LEGlyphID glyphs[6];
le_int32 biasedIndices[6], indices[6], glyph;
float positions[6 * 2 + 2];
LEUnicode chars[] = {
0x0045, 0x006E, 0x0067, 0x006C, 0x0069, 0x0073, 0x0068, 0x0020, /* "English " */
0x0645, 0x0627, 0x0646, 0x062A, 0x0648, 0x0634, /* MEM ALIF KAF NOON TEH WAW SHEEN */
0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x02E /* " text." */
};
if (LE_FAILURE(status)) {
log_err("Could not create LayoutEngine.\n");
goto bail;
}
glyphCount = le_layoutChars(engine, chars, 8, 6, 20, true, 0.0, 0.0, &status);
if (LE_FAILURE(status) || glyphCount != 6) {
log_err("layoutChars(chars, 8, 6, 20, true, 0.0, 0.0, status) failed.\n");
goto bail;
}
le_getGlyphs(engine, glyphs, &status);
le_getCharIndices(engine, indices, &status);
le_getGlyphPositions(engine, positions, &status);
if (LE_FAILURE(status)) {
log_err("Could not get glyph, indices and position arrays.\n");
goto bail;
}
status = LE_NO_ERROR;
le_getCharIndicesWithBase(engine, biasedIndices, 1024, &status);
if (LE_FAILURE(status)) {
log_err("getCharIndices(biasedIndices, 1024, status) failed.\n");
} else {
for (glyph = 0; glyph < glyphCount; glyph += 1) {
if (biasedIndices[glyph] != (indices[glyph] + 1024)) {
log_err("biasedIndices[%d] != indices[%d] + 1024: %8X, %8X\n",
glyph, glyph, biasedIndices[glyph], indices[glyph]);
break;
}
}
}
status = LE_NO_ERROR;
for (glyph = 0; glyph <= glyphCount; glyph += 1) {
float x = 0.0, y = 0.0;
le_getGlyphPosition(engine, glyph, &x, &y, &status);
if (LE_FAILURE(status)) {
log_err("getGlyphPosition(%d, x, y, status) failed.\n", glyph);
break;
}
if (x != positions[glyph*2] || y != positions[glyph*2 + 1]) {
log_err("getGlyphPosition(%d, x, y, status) returned bad position: (%f, %f) != (%f, %f)\n",
glyph, x, y, positions[glyph*2], positions[glyph*2 + 1]);
break;
}
}
bail:
le_close(engine);
le_fontClose(font);
}
U_CDECL_END
static le_bool compareResults(const char *testID, TestResult *expected, TestResult *actual)
{
le_int32 i;
/* NOTE: we'll stop on the first failure 'cause once there's one error, it may cascade... */
if (actual->glyphCount != expected->glyphCount) {
log_err("Test %s: incorrect glyph count: expected %d, got %d\n",
testID, expected->glyphCount, actual->glyphCount);
return false;
}
for (i = 0; i < actual->glyphCount; i += 1) {
if (actual->glyphs[i] != expected->glyphs[i]) {
log_err("Test %s: incorrect id for glyph %d: expected %4X, got %4X\n",
testID, i, expected->glyphs[i], actual->glyphs[i]);
return false;
}
}
for (i = 0; i < actual->glyphCount; i += 1) {
if (actual->indices[i] != expected->indices[i]) {
log_err("Test %s: incorrect index for glyph %d: expected %8X, got %8X\n",
testID, i, expected->indices[i], actual->indices[i]);
return false;
}
}
for (i = 0; i <= actual->glyphCount; i += 1) {
double xError = uprv_fabs(actual->positions[i * 2] - expected->positions[i * 2]);
double yError = uprv_fabs(actual->positions[i * 2 + 1] - expected->positions[i * 2 + 1]);
if (xError > 0.0001) {
log_err("Test %s: incorrect x position for glyph %d: expected %f, got %f\n",
testID, i, expected->positions[i * 2], actual->positions[i * 2]);
return false;
}
if (yError < 0) {
yError = -yError;
}
if (yError > 0.0001) {
log_err("Test %s: incorrect y position for glyph %d: expected %f, got %f\n",
testID, i, expected->positions[i * 2 + 1], actual->positions[i * 2 + 1]);
return false;
}
}
return true;
}
static void checkFontVersion(le_font *font, const char *testVersionString,
le_uint32 testChecksum, const char *testID)
{
le_uint32 fontChecksum = le_getFontChecksum(font);
if (fontChecksum != testChecksum) {
const char *fontVersionString = le_getNameString(font, NAME_VERSION_STRING,
PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH);
const LEUnicode16 *uFontVersionString = NULL;
if (fontVersionString == NULL) {
uFontVersionString = le_getUnicodeNameString(font, NAME_VERSION_STRING,
PLATFORM_MICROSOFT, MICROSOFT_UNICODE_BMP, MICROSOFT_ENGLISH);
}
log_info("Test %s: this may not be the same font used to generate the test data.\n", testID);
if (uFontVersionString != NULL) {
log_info("Your font's version string is \"%S\"\n", uFontVersionString);
le_deleteUnicodeNameString(font, uFontVersionString);
} else {
log_info("Your font's version string is \"%s\"\n", fontVersionString);
le_deleteNameString(font, fontVersionString);
}
log_info("The expected version string is \"%s\"\n", testVersionString);
log_info("If you see errors, they may be due to the version of the font you're using.\n");
}
}
/* Returns the path to icu/source/test/testdata/ */
static const char *getSourceTestData() {
#ifdef U_TOPSRCDIR
const char *srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
#else
const char *srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
FILE *f = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"rbbitst.txt", "r");
if (f != NULL) {
/* We're in icu/source/test/letest/ */
fclose(f);
} else {
/* We're in icu/source/test/letest/(Debug|Release) */
srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
}
#endif
return srcDataDir;
}
static const char *getPath(char buffer[2048], const char *filename) {
const char *testDataDirectory = getSourceTestData();
strcpy(buffer, testDataDirectory);
strcat(buffer, filename);
return buffer;
}
static le_font *openFont(const char *fontName, const char *checksum, const char *version, const char *testID)
{
char path[2048];
le_font *font;
LEErrorCode fontStatus = LE_NO_ERROR;
if (fontName != NULL) {
font = le_portableFontOpen(getPath(path, fontName), 12, &fontStatus);
if (LE_FAILURE(fontStatus)) {
log_info("Test %s: can't open font %s - test skipped.\n", testID, fontName);
le_fontClose(font);
return NULL;
} else {
le_uint32 cksum = 0;
sscanf(checksum, "%x", &cksum);
checkFontVersion(font, version, cksum, testID);
}
} else {
font = le_simpleFontOpen(12, &fontStatus);
}
return font;
}
static le_bool getRTL(const LEUnicode *text, le_int32 charCount)
{
UBiDiLevel level;
le_int32 limit = -1;
UErrorCode status = U_ZERO_ERROR;
UBiDi *ubidi = ubidi_openSized(charCount, 0, &status);
ubidi_setPara(ubidi, text, charCount, UBIDI_DEFAULT_LTR, NULL, &status);
/* TODO: Should check that there's only a single logical run... */
ubidi_getLogicalRun(ubidi, 0, &limit, &level);
ubidi_close(ubidi);
return level & 1;
}
static void doTestCase (const char *testID,
const char *fontName,
const char *fontVersion,
const char *fontChecksum,
le_int32 scriptCode,
le_int32 languageCode,
const LEUnicode *text,
le_int32 charCount,
TestResult *expected)
{
LEErrorCode status = LE_NO_ERROR;
le_engine *engine;
le_font *font = openFont(fontName, fontChecksum, fontVersion, testID);
le_int32 typoFlags = 3; /* kerning + ligatures */
TestResult actual;
if (font == NULL) {
/* error message already printed. */
return;
}
if (fontName == NULL) {
typoFlags |= 0x80000000L; /* use CharSubstitutionFilter... */
}
engine = le_create(font, scriptCode, languageCode, typoFlags, &status);
if (LE_FAILURE(status)) {
log_err("Test %s: could not create a LayoutEngine.\n", testID);
goto free_expected;
}
actual.glyphCount = le_layoutChars(engine, text, 0, charCount, charCount, getRTL(text, charCount), 0, 0, &status);
actual.glyphs = NEW_ARRAY(LEGlyphID, actual.glyphCount);
actual.indices = NEW_ARRAY(le_int32, actual.glyphCount);
actual.positions = NEW_ARRAY(float, actual.glyphCount * 2 + 2);
le_getGlyphs(engine, actual.glyphs, &status);
le_getCharIndices(engine, actual.indices, &status);
le_getGlyphPositions(engine, actual.positions, &status);
compareResults(testID, expected, &actual);
DELETE_ARRAY(actual.positions);
DELETE_ARRAY(actual.indices);
DELETE_ARRAY(actual.glyphs);
le_close(engine);
free_expected:
le_fontClose(font);
}
static void U_CALLCONV DataDrivenTest(void)
{
char path[2048];
const char *testFilePath = getPath(path, "letest.xml");
readTestFile(testFilePath, doTestCase);
}
/*
* From ticket:5923:
*
* Build a paragraph that contains a mixture of left to right and right to left text.
* Break it into multiple lines and make sure that the glyphToCharMap for run in each
* line is correct.
*
* Note: it might be a good idea to also check the glyphs and positions for each run,
* that we get the expected number of runs per line and that the line breaks are where
* we expect them to be. Really, it would be a good idea to make a whole test suite
* for pl_paragraph.
*/
static void U_CALLCONV GlyphToCharTest(void)
{
#if !UCONFIG_NO_BREAK_ITERATION
LEErrorCode status = LE_NO_ERROR;
le_font *font;
pl_fontRuns *fontRuns;
pl_paragraph *paragraph;
const pl_line *line;
/*
* This is the same text that's in <icu>/source/samples/layout/Sample.txt
*/
LEUnicode chars[] = {
/*BOM*/ 0x0054, 0x0068, 0x0065, 0x0020, 0x004c, 0x0061, 0x0079,
0x006f, 0x0075, 0x0074, 0x0045, 0x006e, 0x0067, 0x0069, 0x006e,
0x0065, 0x0020, 0x0064, 0x006f, 0x0065, 0x0073, 0x0020, 0x0061,
0x006c, 0x006c, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0077,
0x006f, 0x0072, 0x006b, 0x0020, 0x006e, 0x0065, 0x0063, 0x0065,
0x0073, 0x0073, 0x0061, 0x0072, 0x0079, 0x0020, 0x0074, 0x006f,
0x0020, 0x0064, 0x0069, 0x0073, 0x0070, 0x006c, 0x0061, 0x0079,
0x0020, 0x0055, 0x006e, 0x0069, 0x0063, 0x006f, 0x0064, 0x0065,
0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x0020, 0x0077, 0x0072,
0x0069, 0x0074, 0x0074, 0x0065, 0x006e, 0x0020, 0x0069, 0x006e,
0x0020, 0x006c, 0x0061, 0x006e, 0x0067, 0x0075, 0x0061, 0x0067,
0x0065, 0x0073, 0x0020, 0x0077, 0x0069, 0x0074, 0x0068, 0x0020,
0x0063, 0x006f, 0x006d, 0x0070, 0x006c, 0x0065, 0x0078, 0x0020,
0x0077, 0x0072, 0x0069, 0x0074, 0x0069, 0x006e, 0x0067, 0x0020,
0x0073, 0x0079, 0x0073, 0x0074, 0x0065, 0x006d, 0x0073, 0x0020,
0x0073, 0x0075, 0x0063, 0x0068, 0x0020, 0x0061, 0x0073, 0x0020,
0x0048, 0x0069, 0x006e, 0x0064, 0x0069, 0x0020, 0x0028, 0x0939,
0x093f, 0x0928, 0x094d, 0x0926, 0x0940, 0x0029, 0x0020, 0x0054,
0x0068, 0x0061, 0x0069, 0x0020, 0x0028, 0x0e44, 0x0e17, 0x0e22,
0x0029, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0041, 0x0072,
0x0061, 0x0062, 0x0069, 0x0063, 0x0020, 0x0028, 0x0627, 0x0644,
0x0639, 0x0631, 0x0628, 0x064a, 0x0629, 0x0029, 0x002e, 0x0020,
0x0048, 0x0065, 0x0072, 0x0065, 0x0027, 0x0073, 0x0020, 0x0061,
0x0020, 0x0073, 0x0061, 0x006d, 0x0070, 0x006c, 0x0065, 0x0020,
0x006f, 0x0066, 0x0020, 0x0073, 0x006f, 0x006d, 0x0065, 0x0020,
0x0074, 0x0065, 0x0078, 0x0074, 0x0020, 0x0077, 0x0072, 0x0069,
0x0074, 0x0074, 0x0065, 0x006e, 0x0020, 0x0069, 0x006e, 0x0020,
0x0053, 0x0061, 0x006e, 0x0073, 0x006b, 0x0072, 0x0069, 0x0074,
0x003a, 0x0020, 0x0936, 0x094d, 0x0930, 0x0940, 0x092e, 0x0926,
0x094d, 0x0020, 0x092d, 0x0917, 0x0935, 0x0926, 0x094d, 0x0917,
0x0940, 0x0924, 0x093e, 0x0020, 0x0905, 0x0927, 0x094d, 0x092f,
0x093e, 0x092f, 0x0020, 0x0905, 0x0930, 0x094d, 0x091c, 0x0941,
0x0928, 0x0020, 0x0935, 0x093f, 0x0937, 0x093e, 0x0926, 0x0020,
0x092f, 0x094b, 0x0917, 0x0020, 0x0927, 0x0943, 0x0924, 0x0930,
0x093e, 0x0937, 0x094d, 0x091f, 0x094d, 0x0930, 0x0020, 0x0909,
0x0935, 0x093e, 0x091a, 0x0964, 0x0020, 0x0927, 0x0930, 0x094d,
0x092e, 0x0915, 0x094d, 0x0937, 0x0947, 0x0924, 0x094d, 0x0930,
0x0947, 0x0020, 0x0915, 0x0941, 0x0930, 0x0941, 0x0915, 0x094d,
0x0937, 0x0947, 0x0924, 0x094d, 0x0930, 0x0947, 0x0020, 0x0938,
0x092e, 0x0935, 0x0947, 0x0924, 0x093e, 0x0020, 0x092f, 0x0941,
0x092f, 0x0941, 0x0924, 0x094d, 0x0938, 0x0935, 0x0903, 0x0020,
0x092e, 0x093e, 0x092e, 0x0915, 0x093e, 0x0903, 0x0020, 0x092a,
0x093e, 0x0923, 0x094d, 0x0921, 0x0935, 0x093e, 0x0936, 0x094d,
0x091a, 0x0948, 0x0935, 0x0020, 0x0915, 0x093f, 0x092e, 0x0915,
0x0941, 0x0930, 0x094d, 0x0935, 0x0924, 0x0020, 0x0938, 0x0902,
0x091c, 0x092f, 0x0020, 0x0048, 0x0065, 0x0072, 0x0065, 0x0027,
0x0073, 0x0020, 0x0061, 0x0020, 0x0073, 0x0061, 0x006d, 0x0070,
0x006c, 0x0065, 0x0020, 0x006f, 0x0066, 0x0020, 0x0073, 0x006f,
0x006d, 0x0065, 0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x0020,
0x0077, 0x0072, 0x0069, 0x0074, 0x0074, 0x0065, 0x006e, 0x0020,
0x0069, 0x006e, 0x0020, 0x0041, 0x0072, 0x0061, 0x0062, 0x0069,
0x0063, 0x003a, 0x0020, 0x0623, 0x0633, 0x0627, 0x0633, 0x064b,
0x0627, 0x060c, 0x0020, 0x062a, 0x062a, 0x0639, 0x0627, 0x0645,
0x0644, 0x0020, 0x0627, 0x0644, 0x062d, 0x0648, 0x0627, 0x0633,
0x064a, 0x0628, 0x0020, 0x0641, 0x0642, 0x0637, 0x0020, 0x0645,
0x0639, 0x0020, 0x0627, 0x0644, 0x0623, 0x0631, 0x0642, 0x0627,
0x0645, 0x060c, 0x0020, 0x0648, 0x062a, 0x0642, 0x0648, 0x0645,
0x0020, 0x0628, 0x062a, 0x062e, 0x0632, 0x064a, 0x0646, 0x0020,
0x0627, 0x0644, 0x0623, 0x062d, 0x0631, 0x0641, 0x0020, 0x0648,
0x0627, 0x0644, 0x0645, 0x062d, 0x0627, 0x0631, 0x0641, 0x0020,
0x0627, 0x0644, 0x0623, 0x062e, 0x0631, 0x0649, 0x0020, 0x0628,
0x0639, 0x062f, 0x0020, 0x0623, 0x0646, 0x0020, 0x062a, 0x064f,
0x0639, 0x0637, 0x064a, 0x0020, 0x0631, 0x0642, 0x0645, 0x0627,
0x0020, 0x0645, 0x0639, 0x064a, 0x0646, 0x0627, 0x0020, 0x0644,
0x0643, 0x0644, 0x0020, 0x0648, 0x0627, 0x062d, 0x062f, 0x0020,
0x0645, 0x0646, 0x0647, 0x0627, 0x002e, 0x0020, 0x0648, 0x0642,
0x0628, 0x0644, 0x0020, 0x0627, 0x062e, 0x062a, 0x0631, 0x0627,
0x0639, 0x0020, 0x0022, 0x064a, 0x0648, 0x0646, 0x0650, 0x0643,
0x0648, 0x062f, 0x0022, 0x060c, 0x0020, 0x0643, 0x0627, 0x0646,
0x0020, 0x0647, 0x0646, 0x0627, 0x0643, 0x0020, 0x0645, 0x0626,
0x0627, 0x062a, 0x0020, 0x0627, 0x0644, 0x0623, 0x0646, 0x0638,
0x0645, 0x0629, 0x0020, 0x0644, 0x0644, 0x062a, 0x0634, 0x0641,
0x064a, 0x0631, 0x0020, 0x0648, 0x062a, 0x062e, 0x0635, 0x064a,
0x0635, 0x0020, 0x0647, 0x0630, 0x0647, 0x0020, 0x0627, 0x0644,
0x0623, 0x0631, 0x0642, 0x0627, 0x0645, 0x0020, 0x0644, 0x0644,
0x0645, 0x062d, 0x0627, 0x0631, 0x0641, 0x060c, 0x0020, 0x0648,
0x0644, 0x0645, 0x0020, 0x064a, 0x0648, 0x062c, 0x062f, 0x0020,
0x0646, 0x0638, 0x0627, 0x0645, 0x0020, 0x062a, 0x0634, 0x0641,
0x064a, 0x0631, 0x0020, 0x0648, 0x0627, 0x062d, 0x062f, 0x0020,
0x064a, 0x062d, 0x062a, 0x0648, 0x064a, 0x0020, 0x0639, 0x0644,
0x0649, 0x0020, 0x062c, 0x0645, 0x064a, 0x0639, 0x0020, 0x0627,
0x0644, 0x0645, 0x062d, 0x0627, 0x0631, 0x0641, 0x0020, 0x0627,
0x0644, 0x0636, 0x0631, 0x0648, 0x0631, 0x064a, 0x0629, 0x0020,
0x0061, 0x006e, 0x0064, 0x0020, 0x0068, 0x0065, 0x0072, 0x0065,
0x0027, 0x0073, 0x0020, 0x0061, 0x0020, 0x0073, 0x0061, 0x006d,
0x0070, 0x006c, 0x0065, 0x0020, 0x006f, 0x0066, 0x0020, 0x0073,
0x006f, 0x006d, 0x0065, 0x0020, 0x0074, 0x0065, 0x0078, 0x0074,
0x0020, 0x0077, 0x0072, 0x0069, 0x0074, 0x0074, 0x0065, 0x006e,
0x0020, 0x0069, 0x006e, 0x0020, 0x0054, 0x0068, 0x0061, 0x0069,
0x003a, 0x0020, 0x0e1a, 0x0e17, 0x0e17, 0x0e35, 0x0e48, 0x0e51,
0x0e1e, 0x0e32, 0x0e22, 0x0e38, 0x0e44, 0x0e0b, 0x0e42, 0x0e04,
0x0e25, 0x0e19, 0x0e42, 0x0e14, 0x0e42, 0x0e23, 0x0e18, 0x0e35,
0x0e2d, 0x0e32, 0x0e28, 0x0e31, 0x0e22, 0x0e2d, 0x0e22, 0x0e39,
0x0e48, 0x0e17, 0x0e48, 0x0e32, 0x0e21, 0x0e01, 0x0e25, 0x0e32,
0x0e07, 0x0e17, 0x0e38, 0x0e48, 0x0e07, 0x0e43, 0x0e2b, 0x0e0d,
0x0e48, 0x0e43, 0x0e19, 0x0e41, 0x0e04, 0x0e19, 0x0e0b, 0x0e31,
0x0e2a, 0x0e01, 0x0e31, 0x0e1a, 0x0e25, 0x0e38, 0x0e07, 0x0e40,
0x0e2e, 0x0e19, 0x0e23, 0x0e35, 0x0e0a, 0x0e32, 0x0e27, 0x0e44,
0x0e23, 0x0e48, 0x0e41, 0x0e25, 0x0e30, 0x0e1b, 0x0e49, 0x0e32,
0x0e40, 0x0e2d, 0x0e47, 0x0e21, 0x0e20, 0x0e23, 0x0e23, 0x0e22,
0x0e32, 0x0e0a, 0x0e32, 0x0e27, 0x0e44, 0x0e23, 0x0e48, 0x0e1a,
0x0e49, 0x0e32, 0x0e19, 0x0e02, 0x0e2d, 0x0e07, 0x0e1e, 0x0e27,
0x0e01, 0x0e40, 0x0e02, 0x0e32, 0x0e2b, 0x0e25, 0x0e31, 0x0e07,
0x0e40, 0x0e25, 0x0e47, 0x0e01, 0x0e40, 0x0e1e, 0x0e23, 0x0e32,
0x0e30, 0x0e44, 0x0e21, 0x0e49, 0x0e2a, 0x0e23, 0x0e49, 0x0e32,
0x0e07, 0x0e1a, 0x0e49, 0x0e32, 0x0e19, 0x0e15, 0x0e49, 0x0e2d,
0x0e07, 0x0e02, 0x0e19, 0x0e21, 0x0e32, 0x0e14, 0x0e49, 0x0e27,
0x0e22, 0x0e40, 0x0e01, 0x0e27, 0x0e35, 0x0e22, 0x0e19, 0x0e40,
0x0e1b, 0x0e47, 0x0e19, 0x0e23, 0x0e30, 0x0e22, 0x0e30, 0x0e17,
0x0e32, 0x0e07, 0x0e2b, 0x0e25, 0x0e32, 0x0e22, 0x0e44, 0x0e21,
0x0e25, 0x0e4c
};
le_int32 charCount = LE_ARRAY_SIZE(chars);
le_int32 charIndex = 0, lineNumber = 1;
le_int32 run, i;
const float lineWidth = 600;
font = le_simpleFontOpen(12, &status);
if (LE_FAILURE(status)) {
log_err("le_simpleFontOpen(12, &status) failed");
goto finish;
}
fontRuns = pl_openEmptyFontRuns(0);
pl_addFontRun(fontRuns, font, charCount);
paragraph = pl_create(chars, charCount, fontRuns, NULL, NULL, NULL, 0, false, &status);
pl_closeFontRuns(fontRuns);
if (LE_FAILURE(status)) {
log_err("pl_create failed.");
goto close_font;
}
pl_reflow(paragraph);
while ((line = pl_nextLine(paragraph, lineWidth)) != NULL) {
le_int32 runCount = pl_countLineRuns(line);
for(run = 0; run < runCount; run += 1) {
const pl_visualRun *visualRun = pl_getLineVisualRun(line, run);
const le_int32 glyphCount = pl_getVisualRunGlyphCount(visualRun);
const le_int32 *glyphToCharMap = pl_getVisualRunGlyphToCharMap(visualRun);
if (pl_getVisualRunDirection(visualRun) == UBIDI_RTL) {
/*
* For a right to left run, make sure that the character indices
* increase from the right most glyph to the left most glyph. If
* there are any one to many glyph substitutions, we might get several
* glyphs in a row with the same character index.
*/
for(i = glyphCount - 1; i >= 0; i -= 1) {
le_int32 ix = glyphToCharMap[i];
if (ix != charIndex) {
if (ix != charIndex - 1) {
log_err("Bad glyph to char index for glyph %d on line %d: expected %d, got %d\n",
i, lineNumber, charIndex, ix);
goto close_paragraph; /* once there's one error, we can't count on anything else... */
}
} else {
charIndex += 1;
}
}
} else {
/*
* We can't just check the order of the character indices
* for left to right runs because Indic text might have been
* reordered. What we can do is find the minimum and maximum
* character indices in the run and make sure that the minimum
* is equal to charIndex and then advance charIndex to the maximum.
*/
le_int32 minIndex = 0x7FFFFFFF, maxIndex = -1;
for(i = 0; i < glyphCount; i += 1) {
le_int32 ix = glyphToCharMap[i];
if (ix > maxIndex) {
maxIndex = ix;
}
if (ix < minIndex) {
minIndex = ix;
}
}
if (minIndex != charIndex) {
log_err("Bad minIndex for run %d on line %d: expected %d, got %d\n",
run, lineNumber, charIndex, minIndex);
goto close_paragraph; /* once there's one error, we can't count on anything else... */
}
charIndex = maxIndex + 1;
}
}
lineNumber += 1;
}
close_paragraph:
pl_close(paragraph);
close_font:
le_fontClose(font);
finish:
return;
#endif
}
U_CFUNC void addCTests(TestNode **root)
{
addTest(root, &ParamTest, "c_api/ParameterTest");
addTest(root, &FactoryTest, "c_api/FactoryTest");
addTest(root, &AccessTest, "c_layout/AccessTest");
addTest(root, &DataDrivenTest, "c_layout/DataDrivenTest");
addTest(root, &GlyphToCharTest, "c_paragraph/GlyphToCharTest");
}
#endif

View file

@ -1,26 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cletest", "cletest.vcxproj", "{798E3AE4-A984-43FF-8928-EACFF43F56AE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{798E3AE4-A984-43FF-8928-EACFF43F56AE}.Debug|Win32.ActiveCfg = Debug|Win32
{798E3AE4-A984-43FF-8928-EACFF43F56AE}.Debug|Win32.Build.0 = Debug|Win32
{798E3AE4-A984-43FF-8928-EACFF43F56AE}.Debug|x64.ActiveCfg = Debug|x64
{798E3AE4-A984-43FF-8928-EACFF43F56AE}.Debug|x64.Build.0 = Debug|x64
{798E3AE4-A984-43FF-8928-EACFF43F56AE}.Release|Win32.ActiveCfg = Release|Win32
{798E3AE4-A984-43FF-8928-EACFF43F56AE}.Release|Win32.Build.0 = Release|Win32
{798E3AE4-A984-43FF-8928-EACFF43F56AE}.Release|x64.ActiveCfg = Release|x64
{798E3AE4-A984-43FF-8928-EACFF43F56AE}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = false
EndGlobalSection
EndGlobal

View file

@ -1,193 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{798E3AE4-A984-43FF-8928-EACFF43F56AE}</ProjectGuid>
<RootNamespace>cletest</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir).\x64\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir).\x64\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\include\layout;..\..\..\include;..\..\common;..\..\tools\ctestfw;..\..\tools\toolutil;..\..\layout;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
<Link>
<AdditionalDependencies>..\..\..\lib\icuucd.lib;..\..\..\lib\icuind.lib;..\..\..\lib\icutestd.lib;..\..\..\lib\icutud.lib;..\..\..\lib\iculed.lib;..\..\..\lib\iculxd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>NotSet</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include\layout;..\..\..\include;..\..\common;..\..\tools\ctestfw;..\..\tools\toolutil;..\..\layout;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>..\..\..\lib\icuuc.lib;..\..\..\lib\icuin.lib;..\..\..\lib\icutest.lib;..\..\..\lib\icutu.lib;..\..\..\lib\icule.lib;..\..\..\lib\iculx.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>NotSet</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\include\layout;..\..\..\include;..\..\common;..\..\tools\ctestfw;..\..\tools\toolutil;..\..\layout;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>..\..\..\lib64\icuucd.lib;..\..\..\lib64\icuind.lib;..\..\..\lib64\icutestd.lib;..\..\..\lib64\icutud.lib;..\..\..\lib64\iculed.lib;..\..\..\lib64\iculxd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include\layout;..\..\..\include;..\..\common;..\..\tools\ctestfw;..\..\tools\toolutil;..\..\layout;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>..\..\..\lib64\icuuc.lib;..\..\..\lib64\icuin.lib;..\..\..\lib64\icutest.lib;..\..\..\lib64\icutu.lib;..\..\..\lib64\icule.lib;..\..\..\lib64\iculx.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="cfonts.cpp" />
<ClCompile Include="cletest.c" />
<ClCompile Include="cmaps.cpp" />
<ClCompile Include="FontObject.cpp" />
<ClCompile Include="FontTableCache.cpp" />
<ClCompile Include="letest.cpp" />
<ClCompile Include="letsutil.cpp" />
<ClCompile Include="PortableFontInstance.cpp" />
<ClCompile Include="SimpleFontInstance.cpp" />
<ClCompile Include="xmlreader.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cfonts.h" />
<ClInclude Include="cmaps.h" />
<ClInclude Include="FontObject.h" />
<ClInclude Include="FontTableCache.h" />
<ClInclude Include="letest.h" />
<ClInclude Include="letsutil.h" />
<ClInclude Include="PortableFontInstance.h" />
<ClInclude Include="sfnt.h" />
<ClInclude Include="SimpleFontInstance.h" />
<ClInclude Include="xmlreader.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="cfonts.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cletest.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cmaps.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FontObject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FontTableCache.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="letsutil.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PortableFontInstance.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SimpleFontInstance.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="xmlreader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="letest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="cfonts.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="cmaps.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FontObject.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FontTableCache.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="letest.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="letsutil.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PortableFontInstance.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sfnt.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SimpleFontInstance.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="xmlreader.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -967,10 +967,6 @@ static void addAllTests(TestNode **root)
addTest(root, &AccessTest, "layout/AccessTest");
addTest(root, &DataDrivenTest, "layout/DataDrivenTest");
addTest(root, &GlyphToCharTest, "paragraph/GlyphToCharTest");
#ifndef USING_ICULEHB
addCTests(root);
#endif
}
/* returns the path to icu/source/data/out */

View file

@ -17,11 +17,7 @@
#define __LETEST_H
#ifdef USING_ICULEHB
#include "layout/LETypes.h"
#else
#include "LETypes.h"
#endif
#include "unicode/ctest.h"
#include <stdlib.h>
@ -51,6 +47,4 @@ struct TestResult
typedef struct TestResult TestResult;
#endif
U_CFUNC void addCTests(TestNode **root);
#endif

View file

@ -220,18 +220,14 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="cfonts.cpp" />
<ClCompile Include="cletest.c" />
<ClCompile Include="cmaps.cpp" />
<ClCompile Include="FontTableCache.cpp" />
<ClCompile Include="letest.cpp" />
<ClCompile Include="letsutil.cpp" />
<ClCompile Include="PortableFontInstance.cpp" />
<ClCompile Include="SimpleFontInstance.cpp" />
<ClCompile Include="xmlreader.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cfonts.h" />
<ClInclude Include="cmaps.h" />
<ClInclude Include="FontTableCache.h" />
<ClInclude Include="letest.h" />
@ -239,7 +235,6 @@
<ClInclude Include="PortableFontInstance.h" />
<ClInclude Include="sfnt.h" />
<ClInclude Include="SimpleFontInstance.h" />
<ClInclude Include="xmlreader.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\layout\layout.vcxproj">

View file

@ -15,12 +15,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="cfonts.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cletest.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cmaps.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -39,14 +33,8 @@
<ClCompile Include="SimpleFontInstance.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="xmlreader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="cfonts.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="cmaps.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -68,8 +56,5 @@
<ClInclude Include="SimpleFontInstance.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="xmlreader.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -22,10 +22,6 @@
#include "layout/LayoutEngine.h"
#include "layout/LELanguages.h"
#ifndef USING_ICULEHB
#include "OpenTypeLayoutEngine.h"
#endif
#include "letest.h"
#include "letsutil.h"
@ -47,17 +43,6 @@ char *getCString(const UnicodeString *uString)
return cString;
}
char *getCString(const LEUnicode16 *uChars)
{
if (uChars == nullptr) {
return nullptr;
}
const UnicodeString ustring(uChars);
return getCString(&ustring);
}
char *getUTF8String(const UnicodeString *uString)
{
if (uString == nullptr) {
@ -104,14 +89,6 @@ le_int32 getLanguageCode(const char *lang)
return -1;
}
#ifndef USING_ICULEHB
LETag langTag = (LETag) ((lang[0] << 24) + (lang[1] << 16) + (lang[2] << 8) + 0x20);
for (le_int32 i = 0; i < languageCodeCount; i += 1) {
if (langTag == OpenTypeLayoutEngine::languageTags[i]) {
return i;
}
}
#else
if (!strcmp(lang, "JAN")) return janLanguageCode;
if (!strcmp(lang, "KOR")) return korLanguageCode;
if (!strcmp(lang, "ZHT")) return zhtLanguageCode;
@ -119,9 +96,6 @@ le_int32 getLanguageCode(const char *lang)
if (!strcmp(lang, "HIN")) return hinLanguageCode;
if (!strcmp(lang, "MAR")) return marLanguageCode;
if (!strcmp(lang, "ROM")) return romLanguageCode;
#endif
return -1;
}

View file

@ -25,14 +25,9 @@
#include "layout/LayoutEngine.h"
#include "layout/LELanguages.h"
#ifndef USING_ICULEHB
#include "OpenTypeLayoutEngine.h"
#endif
#include "letest.h"
char *getCString(const UnicodeString *uString);
char *getCString(const LEUnicode16 *uChars);
char *getUTF8String(const UnicodeString *uString);
void freeCString(char *cString);
le_bool getRTL(const UnicodeString &text);

View file

@ -1,261 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 1999-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#include "unicode/utypes.h"
#include "unicode/uclean.h"
#include "unicode/uchar.h"
#include "unicode/unistr.h"
#include "unicode/uscript.h"
#include "unicode/putil.h"
#include "unicode/ctest.h"
#include "layout/LETypes.h"
#include "layout/LEScripts.h"
#include "letsutil.h"
#include "letest.h"
#include "xmlreader.h"
#include "xmlparser.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
//U_NAMESPACE_USE
#define CH_COMMA 0x002C
static le_uint32 *getHexArray(const UnicodeString &numbers, int32_t &arraySize)
{
int32_t offset = -1;
arraySize = 1;
while((offset = numbers.indexOf(CH_COMMA, offset + 1)) >= 0) {
arraySize += 1;
}
le_uint32 *array = NEW_ARRAY(le_uint32, arraySize);
char number[16];
le_int32 count = 0;
le_int32 start = 0, end = 0;
le_int32 len = 0;
// trim leading whitespace
while(u_isUWhiteSpace(numbers[start])) {
start += 1;
}
while((end = numbers.indexOf(CH_COMMA, start)) >= 0) {
len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
number[len] = '\0';
start = end + 1;
sscanf(number, "%x", &array[count++]);
// trim whitespace following the comma
while(u_isUWhiteSpace(numbers[start])) {
start += 1;
}
}
// trim trailing whitespace
end = numbers.length();
while(u_isUWhiteSpace(numbers[end - 1])) {
end -= 1;
}
len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
number[len] = '\0';
sscanf(number, "%x", &array[count]);
return array;
}
static float *getFloatArray(const UnicodeString &numbers, int32_t &arraySize)
{
int32_t offset = -1;
arraySize = 1;
while((offset = numbers.indexOf(CH_COMMA, offset + 1)) >= 0) {
arraySize += 1;
}
float *array = NEW_ARRAY(float, arraySize);
char number[32];
le_int32 count = 0;
le_int32 start = 0, end = 0;
le_int32 len = 0;
// trim leading whitespace
while(u_isUWhiteSpace(numbers[start])) {
start += 1;
}
while((end = numbers.indexOf(CH_COMMA, start)) >= 0) {
len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
number[len] = '\0';
start = end + 1;
sscanf(number, "%f", &array[count++]);
// trim whiteapce following the comma
while(u_isUWhiteSpace(numbers[start])) {
start += 1;
}
}
while(u_isUWhiteSpace(numbers[start])) {
start += 1;
}
// trim trailing whitespace
end = numbers.length();
while(u_isUWhiteSpace(numbers[end - 1])) {
end -= 1;
}
len = numbers.extract(start, end - start, number, ARRAY_SIZE(number), US_INV);
number[len] = '\0';
sscanf(number, "%f", &array[count]);
return array;
}
U_CDECL_BEGIN
void readTestFile(const char *testFilePath, TestCaseCallback callback)
{
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
UErrorCode status = U_ZERO_ERROR;
UXMLParser *parser = UXMLParser::createParser(status);
UXMLElement *root = parser->parseFile(testFilePath, status);
if (root == nullptr) {
log_err("Could not open the test data file: %s\n", testFilePath);
delete parser;
return;
}
UnicodeString test_case = UNICODE_STRING_SIMPLE("test-case");
UnicodeString test_text = UNICODE_STRING_SIMPLE("test-text");
UnicodeString test_font = UNICODE_STRING_SIMPLE("test-font");
UnicodeString result_glyphs = UNICODE_STRING_SIMPLE("result-glyphs");
UnicodeString result_indices = UNICODE_STRING_SIMPLE("result-indices");
UnicodeString result_positions = UNICODE_STRING_SIMPLE("result-positions");
// test-case attributes
UnicodeString id_attr = UNICODE_STRING_SIMPLE("id");
UnicodeString script_attr = UNICODE_STRING_SIMPLE("script");
UnicodeString lang_attr = UNICODE_STRING_SIMPLE("lang");
// test-font attributes
UnicodeString name_attr = UNICODE_STRING_SIMPLE("name");
UnicodeString ver_attr = UNICODE_STRING_SIMPLE("version");
UnicodeString cksum_attr = UNICODE_STRING_SIMPLE("checksum");
const UXMLElement *testCase;
int32_t tc = 0;
while((testCase = root->nextChildElement(tc)) != nullptr) {
if (testCase->getTagName().compare(test_case) == 0) {
char *id = getCString(testCase->getAttribute(id_attr));
char *script = getCString(testCase->getAttribute(script_attr));
char *lang = getCString(testCase->getAttribute(lang_attr));
char *fontName = nullptr;
char *fontVer = nullptr;
char *fontCksum = nullptr;
const UXMLElement *element;
int32_t ec = 0;
int32_t charCount = 0;
// int32_t typoFlags = 3; // kerning + ligatures...
UScriptCode scriptCode;
le_int32 languageCode = -1;
UnicodeString text, glyphs, indices, positions;
int32_t glyphCount = 0, indexCount = 0, positionCount = 0;
TestResult expected = {0, nullptr, nullptr, nullptr};
uscript_getCode(script, &scriptCode, 1, &status);
if (LE_FAILURE(status)) {
log_err("invalid script name: %s.\n", script);
goto free_c_strings;
}
if (lang != nullptr) {
languageCode = getLanguageCode(lang);
if (languageCode < 0) {
log_err("invalid language name: %s.\n", lang);
goto free_c_strings;
}
}
while((element = testCase->nextChildElement(ec)) != nullptr) {
UnicodeString tag = element->getTagName();
// TODO: make sure that each element is only used once.
if (tag.compare(test_font) == 0) {
fontName = getCString(element->getAttribute(name_attr));
fontVer = getCString(element->getAttribute(ver_attr));
fontCksum = getCString(element->getAttribute(cksum_attr));
} else if (tag.compare(test_text) == 0) {
text = element->getText(true);
charCount = text.length();
} else if (tag.compare(result_glyphs) == 0) {
glyphs = element->getText(true);
} else if (tag.compare(result_indices) == 0) {
indices = element->getText(true);
} else if (tag.compare(result_positions) == 0) {
positions = element->getText(true);
} else {
// an unknown tag...
char *cTag = getCString(&tag);
log_info("Test %s: unknown element with tag \"%s\"\n", id, cTag);
freeCString(cTag);
}
}
expected.glyphs = (LEGlyphID *) getHexArray(glyphs, glyphCount);
expected.indices = (le_int32 *) getHexArray(indices, indexCount);
expected.positions = getFloatArray(positions, positionCount);
expected.glyphCount = glyphCount;
if (glyphCount < charCount || indexCount != glyphCount || positionCount < glyphCount * 2 + 2) {
log_err("Test %s: inconsistent input data: charCount = %d, glyphCount = %d, indexCount = %d, positionCount = %d\n",
id, charCount, glyphCount, indexCount, positionCount);
goto free_expected;
};
(*callback)(id, fontName, fontVer, fontCksum, scriptCode, languageCode, text.getBuffer(), charCount, &expected);
free_expected:
DELETE_ARRAY(expected.positions);
DELETE_ARRAY(expected.indices);
DELETE_ARRAY(expected.glyphs);
free_c_strings:
freeCString(fontCksum);
freeCString(fontVer);
freeCString(fontName);
freeCString(lang);
freeCString(script);
freeCString(id);
}
}
delete root;
delete parser;
#endif
}
U_CDECL_END

View file

@ -1,27 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*
* (C) Copyright IBM Corp. 1998-2014 - All Rights Reserved
*
*/
#ifndef __XMLREADER_H
#define __XMLREADER_H
#include "layout/LETypes.h"
#include "letest.h"
typedef void (*TestCaseCallback) (const char *testID,
const char *fontName,
const char *fontVersion,
const char *fontChecksum,
le_int32 scriptCode,
le_int32 languageCode,
const LEUnicode *text,
le_int32 charCount,
TestResult *expected);
U_CAPI void readTestFile(const char *testFilePath, TestCaseCallback callback);
#endif