2003-03-03 23:28:15 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
2004-04-12 18:51:31 +00:00
|
|
|
* Copyright (C) 1999-2004, International Business Machines
|
2003-03-03 23:28:15 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: LEFontInstance.cpp
|
|
|
|
*
|
|
|
|
* created on: 02/06/2003
|
|
|
|
* created by: Eric R. Mader
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
2003-05-13 23:02:45 +00:00
|
|
|
#include "LEScripts.h"
|
2003-03-03 23:28:15 +00:00
|
|
|
#include "LEFontInstance.h"
|
2004-04-12 18:51:31 +00:00
|
|
|
#include "LEGlyphStorage.h"
|
2003-03-03 23:28:15 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2004-10-19 06:25:41 +00:00
|
|
|
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LEFontInstance)
|
2003-05-13 23:02:45 +00:00
|
|
|
|
2003-05-16 17:43:44 +00:00
|
|
|
const LEFontInstance *LEFontInstance::getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit,
|
2003-05-13 23:02:45 +00:00
|
|
|
le_int32 script, LEErrorCode &success) const
|
|
|
|
{
|
2003-05-16 17:43:44 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-05-13 23:02:45 +00:00
|
|
|
|
2003-05-16 17:43:44 +00:00
|
|
|
if (chars == NULL || *offset < 0 || limit < 0 || *offset >= limit || script < 0 || script >= scriptCodeCount) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-05-13 23:02:45 +00:00
|
|
|
|
2003-05-16 17:43:44 +00:00
|
|
|
*offset = limit;
|
2003-05-13 23:02:45 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2003-03-03 23:28:15 +00:00
|
|
|
void LEFontInstance::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count,
|
2004-04-12 18:51:31 +00:00
|
|
|
le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const
|
2003-03-03 23:28:15 +00:00
|
|
|
{
|
|
|
|
le_int32 i, out = 0, dir = 1;
|
|
|
|
|
|
|
|
if (reverse) {
|
|
|
|
out = count - 1;
|
|
|
|
dir = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = offset; i < offset + count; i += 1, out += dir) {
|
|
|
|
LEUnicode16 high = chars[i];
|
|
|
|
LEUnicode32 code = high;
|
|
|
|
|
|
|
|
if (i < offset + count - 1 && high >= 0xD800 && high <= 0xDBFF) {
|
|
|
|
LEUnicode16 low = chars[i + 1];
|
|
|
|
|
|
|
|
if (low >= 0xDC00 && low <= 0xDFFF) {
|
|
|
|
code = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-07 23:29:16 +00:00
|
|
|
glyphStorage[out] = mapCharToGlyph(code, mapper);
|
2003-03-03 23:28:15 +00:00
|
|
|
|
|
|
|
if (code >= 0x10000) {
|
|
|
|
i += 1;
|
2004-05-07 23:29:16 +00:00
|
|
|
glyphStorage[out += dir] = 0xFFFF;
|
2003-03-03 23:28:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LEGlyphID LEFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
|
|
|
|
{
|
|
|
|
LEUnicode32 mappedChar = mapper->mapChar(ch);
|
|
|
|
|
|
|
|
if (mappedChar == 0xFFFE || mappedChar == 0xFFFF) {
|
|
|
|
return 0xFFFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mappedChar == 0x200C || mappedChar == 0x200D) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mapCharToGlyph(mappedChar);
|
|
|
|
}
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|