diff --git a/project/include/TextField.h b/project/include/TextField.h index ea9cedbe9..9d2150c74 100644 --- a/project/include/TextField.h +++ b/project/include/TextField.h @@ -36,6 +36,7 @@ class TextField : public DisplayObject float sharpness; int textColor; float thickness; + float lineSpaceScale; bool useRichTextClipboard; bool wordWrap; bool isInput; @@ -122,6 +123,8 @@ class TextField : public DisplayObject void modifyLocalMatrix(Matrix &ioMatrix); void setAntiAliasType(int inVal); int getAntiAliasType() const { return (int)antiAliasType; } + void setLineSpaceScale(double inVal); + inline float getLineSpaceScale() const { return lineSpaceScale; } int getCaretIndex() { return caretIndex; } diff --git a/project/src/common/ExternalInterface.cpp b/project/src/common/ExternalInterface.cpp index 18096272a..47d12553f 100644 --- a/project/src/common/ExternalInterface.cpp +++ b/project/src/common/ExternalInterface.cpp @@ -4137,6 +4137,7 @@ TEXT_PROP_PRIME(embed_fonts,EmbedFonts,bool); TEXT_PROP_PRIME(auto_size,AutoSize,int); TEXT_PROP_PRIME(caret_index,CaretIndex,int); TEXT_PROP_PRIME(anti_alias_type,AntiAliasType,int); +TEXT_PROP_PRIME(line_space_scale,LineSpaceScale,double); TEXT_PROP_GET_PRIME(text_width,TextWidth,double); TEXT_PROP_GET_PRIME(text_height,TextHeight,double); TEXT_PROP_GET_PRIME(max_scroll_h,MaxScrollH,int); diff --git a/project/src/common/FreeType.cpp b/project/src/common/FreeType.cpp index 09077317b..e53708a18 100644 --- a/project/src/common/FreeType.cpp +++ b/project/src/common/FreeType.cpp @@ -288,7 +288,7 @@ class FreeTypeFont : public FontFace if (!sGammaLUTInit) { for(int i=0;i<256;i++) - sGammaLUT[i] = pow(i/255.0,1.25)*255 + 0.5; + sGammaLUT[i] = pow(i/255.0,1.6)*255 + 0.5; sGammaLUTInit = true; } lut = sGammaLUT; diff --git a/project/src/common/TextField.cpp b/project/src/common/TextField.cpp index fbde427eb..812784c67 100644 --- a/project/src/common/TextField.cpp +++ b/project/src/common/TextField.cpp @@ -45,6 +45,7 @@ TextField::TextField(bool inInitRef) : DisplayObject(inInitRef), sharpness(0), textColor(0x000000), thickness(0), + lineSpaceScale(1.0f), useRichTextClipboard(false), wordWrap(false), isInput(false) @@ -301,6 +302,16 @@ void TextField::setAntiAliasType(int inVal) } +void TextField::setLineSpaceScale(double inScale) +{ + if (lineSpaceScale!=inScale) + { + lineSpaceScale = (float)inScale; + Layout(); + } +} + + void TextField::setTextColor(int inCol) { textColor = inCol; @@ -2233,9 +2244,10 @@ void TextField::Layout(const Matrix &inMatrix, const RenderTarget *inTarget) if (ch=='\n' || ch=='\r') { // New line ... - line.mMetrics.fontToLocal(fontToLocal); + line.mMetrics.fontToLocal(fontToLocal*lineSpaceScale); if (i+1leading; + charY += line.mMetrics.height; mLines.push_back(line); line.Clear(); @@ -2281,7 +2293,7 @@ void TextField::Layout(const Matrix &inMatrix, const RenderTarget *inTarget) line.mChars = last_word_line_chars; line.mMetrics.width = last_word_x; } - line.mMetrics.fontToLocal(fontToLocal); + line.mMetrics.fontToLocal(fontToLocal*lineSpaceScale); if (i+1leading; charY += line.mMetrics.height; @@ -2302,7 +2314,7 @@ void TextField::Layout(const Matrix &inMatrix, const RenderTarget *inTarget) { CharGroup *last=mCharGroups[mCharGroups.size()-1]; last->UpdateMetrics(line.mMetrics); - line.mMetrics.fontToLocal(fontToLocal); + line.mMetrics.fontToLocal(fontToLocal*lineSpaceScale); if (endsWidthNewLine) { line.mY0 = charY; @@ -2430,6 +2442,7 @@ void TextField::decodeStream(ObjectStreamIn &stream) stream.get(sharpness); stream.get(textColor); stream.get(thickness); + stream.get(lineSpaceScale); stream.get(useRichTextClipboard); stream.get(wordWrap); stream.get(isInput); @@ -2489,6 +2502,7 @@ void TextField::encodeStream(ObjectStreamOut &stream) stream.add(sharpness); stream.add(textColor); stream.add(thickness); + stream.add(lineSpaceScale); stream.add(useRichTextClipboard); stream.add(wordWrap); stream.add(isInput); diff --git a/project/src/windows/GDIFont.cpp b/project/src/windows/GDIFont.cpp index 60e48c25f..c678e3a46 100644 --- a/project/src/windows/GDIFont.cpp +++ b/project/src/windows/GDIFont.cpp @@ -63,7 +63,7 @@ class GDIFont : public FontFace if (!sGammaLUTInit) { for(int i=0;i<256;i++) - sGammaLUT[i] = pow(i/255.0,1.25)*255 + 0.5; + sGammaLUT[i] = pow(i/255.0,1.6)*255 + 0.5; sGammaLUTInit = true; } @@ -119,7 +119,7 @@ class GDIFont : public FontFace uint8 *dest = (uint8 *)outTarget.Row(y + outTarget.mRect.y) + outTarget.mRect.x; for(int x=0;xr + src->g*2 + src->b + 2) / 4]; + *dest++= sGammaLUT[ (src->r + src->g + src->b + 1) / 3]; src++; } } diff --git a/src/nme/text/TextField.hx b/src/nme/text/TextField.hx index eb9ea5dc1..42cf2c03f 100644 --- a/src/nme/text/TextField.hx +++ b/src/nme/text/TextField.hx @@ -29,6 +29,7 @@ class TextField extends InteractiveObject public var selectionEndIndex(get, null):Int; public var multiline(get, set):Bool; public var numLines(get, null):Int; + public var lineSpaceScale(get, set):Float; public var scrollH(get, set):Int; public var scrollV(get, set):Int; public var selectable(get, set):Bool; @@ -184,6 +185,8 @@ class TextField extends InteractiveObject private function set_text(inText:String):String { nme_text_field_set_text(nmeHandle, inText); return inText; } private function get_textColor():Int { return nme_text_field_get_text_color(nmeHandle); } private function set_textColor(inCol:Int):Int { nme_text_field_set_text_color(nmeHandle, inCol); return inCol; } + private function get_lineSpaceScale():Float { return nme_text_field_get_line_space_scale(nmeHandle); } + private function set_lineSpaceScale(inValue:Float):Float { nme_text_field_set_line_space_scale(nmeHandle, inValue); return inValue; } private function get_textWidth():Float { return nme_text_field_get_text_width(nmeHandle); } private function get_textHeight():Float { return nme_text_field_get_text_height(nmeHandle); } private function get_type():TextFieldType { return nme_text_field_get_type(nmeHandle) ? TextFieldType.INPUT : TextFieldType.DYNAMIC; } @@ -270,6 +273,8 @@ class TextField extends InteractiveObject private static var nme_text_field_send_key = PrimeLoader.load("nme_text_field_send_key", "oiiiv"); private static var nme_text_field_set_anti_alias_type = PrimeLoader.load("nme_text_field_set_anti_alias_type", "oiv"); private static var nme_text_field_get_anti_alias_type = PrimeLoader.load("nme_text_field_get_anti_alias_type", "oi"); + private static var nme_text_field_set_line_space_scale = PrimeLoader.load("nme_text_field_set_line_space_scale", "odv"); + private static var nme_text_field_get_line_space_scale = PrimeLoader.load("nme_text_field_get_line_space_scale", "od"); } #else