diff --git a/app/assets/sample_data.json b/app/assets/sample_data.json index e637ff09..979801f4 100644 --- a/app/assets/sample_data.json +++ b/app/assets/sample_data.json @@ -451,7 +451,7 @@ }, { "attributes": { - "size": 12.0 + "size": "small" }, "insert": "Small" }, @@ -460,7 +460,7 @@ }, { "attributes": { - "size": 35.0 + "size": "large" }, "insert": "Large" }, @@ -469,10 +469,34 @@ }, { "attributes": { - "size": 60.0 + "size": "huge" }, "insert": "Huge" }, + { + "attributes": { + "size": "15.0" + }, + "insert": "font size 15" + }, + { + "insert": " " + }, + { + "attributes": { + "size": "35" + }, + "insert": "font size 35" + }, + { + "insert": " " + }, + { + "attributes": { + "size": "50" + }, + "insert": "font size 50" + }, { "insert": "\n" } diff --git a/app/lib/pages/home_page.dart b/app/lib/pages/home_page.dart index ecabcd4b..46caa40e 100644 --- a/app/lib/pages/home_page.dart +++ b/app/lib/pages/home_page.dart @@ -71,7 +71,7 @@ class _HomePageState extends State { onPressed: (){ int option = Random().nextInt(30); print(option); - _controller.formatSelection(SizeAttribute(option.toDouble())); + _controller.formatSelection(SizeAttribute("${option.toDouble()}")); }, ), body: RawKeyboardListener( diff --git a/lib/models/documents/attribute.dart b/lib/models/documents/attribute.dart index ec9ca9d8..1e2cb97b 100644 --- a/lib/models/documents/attribute.dart +++ b/lib/models/documents/attribute.dart @@ -206,8 +206,8 @@ class FontAttribute extends Attribute { FontAttribute(double val) : super('font', AttributeScope.INLINE, val); } -class SizeAttribute extends Attribute { - SizeAttribute(double val) : super('size', AttributeScope.INLINE, val); +class SizeAttribute extends Attribute { + SizeAttribute(String val) : super('size', AttributeScope.INLINE, val); } class LinkAttribute extends Attribute { diff --git a/lib/widgets/text_line.dart b/lib/widgets/text_line.dart index 53bb07f8..7f784d2b 100644 --- a/lib/widgets/text_line.dart +++ b/lib/widgets/text_line.dart @@ -137,6 +137,7 @@ class TextLine extends StatelessWidget { Attribute size = textNode.style.attributes[Attribute.size.key]; if (size != null && size.value != null) { + switch (size.value) { case 'small': res = res.merge(defaultStyles.sizeSmall); @@ -148,6 +149,11 @@ class TextLine extends StatelessWidget { res = res.merge(defaultStyles.sizeHuge); break; default: + double fontSize = double.tryParse(size.value); + if(fontSize!=null){ + res = res.merge(TextStyle(fontSize: fontSize)); + } + else throw "Invalid size ${size.value}"; } }