diff --git a/icu4c/source/layout/LEFontInstance.h b/icu4c/source/layout/LEFontInstance.h index 6747acbd0a9..d84a652625f 100644 --- a/icu4c/source/layout/LEFontInstance.h +++ b/icu4c/source/layout/LEFontInstance.h @@ -1,7 +1,7 @@ /* * - * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * (C) Copyright IBM Corp. 1998-2012 - All Rights Reserved * */ @@ -165,6 +165,25 @@ public: */ virtual const void *getFontTable(LETag tableTag) const = 0; + /** + * This method reads a table from the font. Note that in general, + * it only makes sense to call this method on an LEFontInstance + * which represents a physical font - i.e. one which has been returned by + * getSubFont(). This is because each subfont in a composite font + * will have different tables, and there's no way to know which subfont to access. + * + * Subclasses which represent composite fonts should always return NULL. + * + * This version sets a length, for range checking. + * + * @param tableTag - the four byte table tag. (e.g. 'cmap') + * @param length - ignored on entry, on exit will be the length of the table if known, or -1 if unknown. + * @return the address of the table in memory, or NULL + * if the table doesn't exist. + * @internal + */ + virtual const void* getFontTable(LETag tableTag, size_t &length) const { length=-1; return getFontTable(tableTag); } /* -1 = unknown length */ + /** * This method is used to determine if the font can * render the given character. This can usually be done diff --git a/icu4c/source/layout/LETypes.h b/icu4c/source/layout/LETypes.h index 0540493bd26..56c8d21f39f 100644 --- a/icu4c/source/layout/LETypes.h +++ b/icu4c/source/layout/LETypes.h @@ -1,6 +1,6 @@ /* * - * (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved + * (C) Copyright IBM Corp. 1998-2012 - All Rights Reserved * */ @@ -309,6 +309,51 @@ typedef struct LEPoint LEPoint; * @internal */ #define LE_DELETE_ARRAY(array) uprv_free((void *) (array)) +#else + +/* Not using ICU memory - use C std lib versions */ + +#include +#include + +/** + * A convenience macro to get the length of an array. + * + * @internal + */ +#define LE_ARRAY_SIZE(array) (sizeof array / sizeof array[0]) + +/** + * A convenience macro for copying an array. + * + * @internal + */ +#define LE_ARRAY_COPY(dst, src, count) memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0]) + +/** + * Allocate an array of basic types. This is used to isolate the rest of + * the LayoutEngine code from cmemory.h. + * + * @internal + */ +#define LE_NEW_ARRAY(type, count) (type *) malloc((count) * sizeof(type)) + +/** + * Re-allocate an array of basic types. This is used to isolate the rest of + * the LayoutEngine code from cmemory.h. + * + * @internal + */ +#define LE_GROW_ARRAY(array, newSize) realloc((void *) (array), (newSize) * sizeof (array)[0]) + + /** + * Free an array of basic types. This is used to isolate the rest of + * the LayoutEngine code from cmemory.h. + * + * @internal + */ +#define LE_DELETE_ARRAY(array) free((void *) (array)) + #endif #endif /* U_HIDE_INTERNAL_API */