From e376fd206e14391e44e953baf8ed3a8546b3fd36 Mon Sep 17 00:00:00 2001 From: Kostas Chatzikokolakis Date: Tue, 16 Jan 2018 20:27:45 +0100 Subject: [PATCH] Make Font metrics properties writable --- lime/text/Font.hx | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/lime/text/Font.hx b/lime/text/Font.hx index 3cafc3056..3ee772768 100644 --- a/lime/text/Font.hx +++ b/lime/text/Font.hx @@ -40,15 +40,15 @@ import haxe.io.Path; class Font { - public var ascender (get, null):Int; - public var descender (get, null):Int; + @:isVar public var ascender (get, set):Null; // no "= 0", cause asset sub-classes set properties before calling + @:isVar public var descender (get, set):Null; // super(). better indicate a missing value with null anyway. public var height (get, null):Int; public var name (default, null):String; public var numGlyphs (get, null):Int; public var src:Dynamic; public var underlinePosition (get, null):Int; public var underlineThickness (get, null):Int; - public var unitsPerEM (get, null):Int; + @:isVar public var unitsPerEM (get, set):Null; @:noCompletion private var __fontID:String; @:noCompletion private var __fontPath:String; @@ -584,28 +584,42 @@ class Font { - private function get_ascender ():Int { + private function get_ascender ():Null { #if (lime_cffi && !macro) return NativeCFFI.lime_font_get_ascender (src); #else - return 0; + return ascender; #end } - private function get_descender ():Int { + private function set_ascender (value:Null):Null { + + return ascender = value; + + } + + + private function get_descender ():Null { #if (lime_cffi && !macro) return NativeCFFI.lime_font_get_descender (src); #else - return 0; + return descender; #end } + private function set_descender (value:Null):Null { + + return descender = value; + + } + + private function get_height ():Int { #if (lime_cffi && !macro) @@ -650,17 +664,24 @@ class Font { } - private function get_unitsPerEM ():Int { + private function get_unitsPerEM ():Null { #if (lime_cffi && !macro) return NativeCFFI.lime_font_get_units_per_em (src); #else - return 0; + return unitsPerEM; #end } + private function set_unitsPerEM (value:Null):Null { + + return unitsPerEM = value; + + } + + // Native Methods