fix icu_shaper
This commit is contained in:
parent
f41b15f967
commit
67379d1bba
1 changed files with 15 additions and 14 deletions
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -51,15 +51,15 @@ static void shape_text(text_line & line,
|
|||
{
|
||||
unsigned start = line.first_char();
|
||||
unsigned end = line.last_char();
|
||||
mapnik::value_unicode_string const& text = itemizer.text();
|
||||
size_t length = end - start;
|
||||
if (!length) return;
|
||||
line.reserve(length);
|
||||
std::list<text_item> const& list = itemizer.itemize(start, end);
|
||||
|
||||
mapnik::value_unicode_string const& text = itemizer.text();
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
mapnik::value_unicode_string shaped;
|
||||
mapnik::value_unicode_string reordered;
|
||||
unsigned char_index = 0;
|
||||
|
||||
for (auto const& text_item : list)
|
||||
{
|
||||
|
@ -68,8 +68,9 @@ static void shape_text(text_line & line,
|
|||
face_set->set_unscaled_character_sizes();
|
||||
for (auto const& face : *face_set)
|
||||
{
|
||||
|
||||
UBiDi *bidi = ubidi_openSized(length, 0, &err);
|
||||
ubidi_setPara(bidi, text.getBuffer(), length, UBIDI_DEFAULT_LTR, 0, &err);
|
||||
ubidi_setPara(bidi, text.getBuffer() + start, length, UBIDI_DEFAULT_LTR, 0, &err);
|
||||
ubidi_writeReordered(bidi, reordered.getBuffer(length),
|
||||
length, UBIDI_DO_MIRRORING, &err);
|
||||
ubidi_close(bidi);
|
||||
|
@ -89,26 +90,26 @@ static void shape_text(text_line & line,
|
|||
if (U_SUCCESS(err) && (num_chars == length))
|
||||
{
|
||||
U_NAMESPACE_QUALIFIER StringCharacterIterator iter(shaped);
|
||||
unsigned i = 0;
|
||||
for (iter.setToStart(); iter.hasNext();)
|
||||
{
|
||||
UChar ch = iter.nextPostInc();
|
||||
glyph_info tmp;
|
||||
tmp.offset.clear();
|
||||
tmp.char_index = i;
|
||||
tmp.glyph_index = FT_Get_Char_Index(face->get_face(), ch);
|
||||
tmp.offset.clear();
|
||||
if (tmp.glyph_index == 0)
|
||||
{
|
||||
shaped_status = false;
|
||||
break;
|
||||
}
|
||||
tmp.face = face;
|
||||
tmp.format = text_item.format;
|
||||
face->glyph_dimensions(tmp);
|
||||
tmp.scale_multiplier = size / face->get_face()->units_per_EM;
|
||||
width_map[i] += tmp.advance();
|
||||
line.add_glyph(tmp, scale_factor);
|
||||
++i;
|
||||
if (face->glyph_dimensions(tmp))
|
||||
{
|
||||
tmp.char_index = char_index;
|
||||
tmp.face = face;
|
||||
tmp.format = text_item.format;
|
||||
tmp.scale_multiplier = size / face->get_face()->units_per_EM;
|
||||
width_map[char_index++] += tmp.advance();
|
||||
line.add_glyph(tmp, scale_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!shaped_status) continue;
|
||||
|
|
Loading…
Reference in a new issue