Bug 1279069 - Replace &nbsp; with <space> for Graphite shaping purposes if &nbsp; is not supported by the font. r=jrmuizel

This commit is contained in:
Jonathan Kew 2016-06-09 23:53:22 +01:00
Родитель 5c875edd39
Коммит d5c49863d0
1 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -159,6 +159,21 @@ gfxGraphiteShaper::ShapeText(DrawTarget *aDrawTarget,
AddFeature,
&f);
// Graphite shaping doesn't map U+00a0 (nbsp) to space if it is missing
// from the font, so check for that possibility. (Most fonts double-map
// the space glyph to both 0x20 and 0xA0, so this won't often be needed;
// so we don't copy the text until we know it's required.)
nsAutoString transformed;
const char16_t NO_BREAK_SPACE = 0x00a0;
if (!entry->HasCharacter(NO_BREAK_SPACE)) {
nsDependentSubstring src(aText, aLength);
if (src.FindChar(NO_BREAK_SPACE) != kNotFound) {
transformed = src;
transformed.ReplaceChar(NO_BREAK_SPACE, ' ');
aText = transformed.BeginReading();
}
}
size_t numChars = gr_count_unicode_characters(gr_utf16,
aText, aText + aLength,
nullptr);