1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-20 01:14:20 +00:00

TextLayout whitespace fix.

This commit is contained in:
jules 2013-06-29 12:03:29 +01:00
parent 146155bd34
commit 1a49c7fc5b
3 changed files with 13 additions and 3 deletions

View file

@ -307,7 +307,7 @@ namespace TextLayoutHelpers
Array <int> newGlyphs;
Array <float> xOffsets;
t.font.getGlyphPositions (t.text.trimEnd(), newGlyphs, xOffsets);
t.font.getGlyphPositions (getTrimmedEndIfNotAllWhitespace (t.text), newGlyphs, xOffsets);
if (currentRun == nullptr) currentRun = new TextLayout::Run();
if (currentLine == nullptr) currentLine = new TextLayout::Line();
@ -543,6 +543,15 @@ namespace TextLayoutHelpers
}
}
static String getTrimmedEndIfNotAllWhitespace (const String& s)
{
String trimmed (s.trimEnd());
if (trimmed.isEmpty() && ! s.isEmpty())
trimmed = s;
return trimmed;
}
OwnedArray<Token> tokens;
int totalLines;

View file

@ -619,6 +619,7 @@ bool CoreGraphicsContext::drawTextLayout (const AttributedString& text, const Re
CoreTextTypeLayout::drawToCGContext (text, area, context, flipHeight);
return true;
#else
(void) text; (void) area;
return false;
#endif
}

View file

@ -1008,11 +1008,11 @@ private:
class CharToGlyphMapper
{
public:
CharToGlyphMapper (CGFontRef fontRef)
CharToGlyphMapper (CGFontRef cgFontRef)
: segCount (0), endCode (0), startCode (0), idDelta (0),
idRangeOffset (0), glyphIndexes (0)
{
CFDataRef cmapTable = CGFontCopyTableForTag (fontRef, 'cmap');
CFDataRef cmapTable = CGFontCopyTableForTag (cgFontRef, 'cmap');
if (cmapTable != 0)
{