diff --git a/RichStringSandbox/Form1.cs b/RichStringSandbox/Form1.cs index b717d6e..28f307c 100644 --- a/RichStringSandbox/Form1.cs +++ b/RichStringSandbox/Form1.cs @@ -14,6 +14,7 @@ namespace RichStringSandbox ResizeRedraw = true; this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); + /* _richString = new RichString() .FontSize(18).FontFamily("Open Sans") .Alignment(TextAlignment.Center).MarginBottom(20) @@ -22,6 +23,17 @@ namespace RichStringSandbox .Alignment(TextAlignment.Left) .Add("Para2a\nParam2b") ; + */ + var rs = new RichString() + .Alignment(TextAlignment.Center) + .FontFamily("Segoe UI") + .MarginBottom(20) + .Add("Welcome To RichTextKit", fontSize:24, fontWeight: 700, fontItalic: true) + .Paragraph().Alignment(TextAlignment.Left) + .FontSize(18) + .Add("This is a test string"); + + _richString = rs; } private Bitmap _bitmap; diff --git a/Topten.RichTextKit/BidiAlgorithm/Bidi.cs b/Topten.RichTextKit/BidiAlgorithm/Bidi.cs index 9ee3d26..2bc220a 100644 --- a/Topten.RichTextKit/BidiAlgorithm/Bidi.cs +++ b/Topten.RichTextKit/BidiAlgorithm/Bidi.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/BidiAlgorithm/BidiData.cs b/Topten.RichTextKit/BidiAlgorithm/BidiData.cs index f36160d..06f4d27 100644 --- a/Topten.RichTextKit/BidiAlgorithm/BidiData.cs +++ b/Topten.RichTextKit/BidiAlgorithm/BidiData.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/BidiAlgorithm/BidiRun.cs b/Topten.RichTextKit/BidiAlgorithm/BidiRun.cs index b417cfe..3a6837f 100644 --- a/Topten.RichTextKit/BidiAlgorithm/BidiRun.cs +++ b/Topten.RichTextKit/BidiAlgorithm/BidiRun.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/CaretInfo.cs b/Topten.RichTextKit/CaretInfo.cs index 422a104..551dc45 100644 --- a/Topten.RichTextKit/CaretInfo.cs +++ b/Topten.RichTextKit/CaretInfo.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/FontFallback/FontFallback.cs b/Topten.RichTextKit/FontFallback/FontFallback.cs index 06e9888..fe49934 100644 --- a/Topten.RichTextKit/FontFallback/FontFallback.cs +++ b/Topten.RichTextKit/FontFallback/FontFallback.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/FontMapper.cs b/Topten.RichTextKit/FontMapper.cs index ddeac87..d289cff 100644 --- a/Topten.RichTextKit/FontMapper.cs +++ b/Topten.RichTextKit/FontMapper.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/FontRun.cs b/Topten.RichTextKit/FontRun.cs index 69a856a..23e2801 100644 --- a/Topten.RichTextKit/FontRun.cs +++ b/Topten.RichTextKit/FontRun.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/FontRunKind.cs b/Topten.RichTextKit/FontRunKind.cs index ef9a085..a7c7b16 100644 --- a/Topten.RichTextKit/FontRunKind.cs +++ b/Topten.RichTextKit/FontRunKind.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/FontVariant.cs b/Topten.RichTextKit/FontVariant.cs index bac2c37..1933abd 100644 --- a/Topten.RichTextKit/FontVariant.cs +++ b/Topten.RichTextKit/FontVariant.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/HitTestResult.cs b/Topten.RichTextKit/HitTestResult.cs index 1cabafa..79a4ccd 100644 --- a/Topten.RichTextKit/HitTestResult.cs +++ b/Topten.RichTextKit/HitTestResult.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/IStyle.cs b/Topten.RichTextKit/IStyle.cs index 128a726..e6c4929 100644 --- a/Topten.RichTextKit/IStyle.cs +++ b/Topten.RichTextKit/IStyle.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/IStyleExtensions.cs b/Topten.RichTextKit/IStyleExtensions.cs index 6c35088..96c890f 100644 --- a/Topten.RichTextKit/IStyleExtensions.cs +++ b/Topten.RichTextKit/IStyleExtensions.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/LineBreakAlgorithm/LineBreak.cs b/Topten.RichTextKit/LineBreakAlgorithm/LineBreak.cs index da4313b..07686d8 100644 --- a/Topten.RichTextKit/LineBreakAlgorithm/LineBreak.cs +++ b/Topten.RichTextKit/LineBreakAlgorithm/LineBreak.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/LineBreakAlgorithm/LineBreakPairTable.cs b/Topten.RichTextKit/LineBreakAlgorithm/LineBreakPairTable.cs index b85640c..dbb0614 100644 --- a/Topten.RichTextKit/LineBreakAlgorithm/LineBreakPairTable.cs +++ b/Topten.RichTextKit/LineBreakAlgorithm/LineBreakPairTable.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/LineBreakAlgorithm/LineBreaker.cs b/Topten.RichTextKit/LineBreakAlgorithm/LineBreaker.cs index dd10973..ad9a062 100644 --- a/Topten.RichTextKit/LineBreakAlgorithm/LineBreaker.cs +++ b/Topten.RichTextKit/LineBreakAlgorithm/LineBreaker.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/PaintTextContext.cs b/Topten.RichTextKit/PaintTextContext.cs index a0f921f..ea6887b 100644 --- a/Topten.RichTextKit/PaintTextContext.cs +++ b/Topten.RichTextKit/PaintTextContext.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain @@ -14,7 +14,7 @@ // under the License. // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/RichString.cs b/Topten.RichTextKit/RichString.cs index 9dd8725..447f744 100644 --- a/Topten.RichTextKit/RichString.cs +++ b/Topten.RichTextKit/RichString.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain @@ -400,6 +400,17 @@ namespace Topten.RichTextKit } } + /// + /// Paint this text block + /// + /// The Skia canvas to paint to + /// Options controlling the paint operation + public void Paint( + SKCanvas canvas, + TextPaintOptions options = null) + { + Paint(canvas, SKPoint.Empty, options); + } /// /// Paint this text block @@ -408,9 +419,9 @@ namespace Topten.RichTextKit /// The top left position within the canvas to draw at /// Options controlling the paint operation public void Paint( - SKCanvas canvas, - SKPoint position, - TextPaintOptions options = null) + SKCanvas canvas, + SKPoint position, + TextPaintOptions options = null) { Layout(); diff --git a/Topten.RichTextKit/StrikeThroughStyle.cs b/Topten.RichTextKit/StrikeThroughStyle.cs index 0920c3a..e229438 100644 --- a/Topten.RichTextKit/StrikeThroughStyle.cs +++ b/Topten.RichTextKit/StrikeThroughStyle.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Style.cs b/Topten.RichTextKit/Style.cs index e6cc60a..2cc4d36 100644 --- a/Topten.RichTextKit/Style.cs +++ b/Topten.RichTextKit/Style.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/StyleManager.cs b/Topten.RichTextKit/StyleManager.cs index 6f4fe37..5145111 100644 --- a/Topten.RichTextKit/StyleManager.cs +++ b/Topten.RichTextKit/StyleManager.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/StyleRun.cs b/Topten.RichTextKit/StyleRun.cs index 587dc46..3839cc6 100644 --- a/Topten.RichTextKit/StyleRun.cs +++ b/Topten.RichTextKit/StyleRun.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/TextAlignment.cs b/Topten.RichTextKit/TextAlignment.cs index ccf46ec..6f140f2 100644 --- a/Topten.RichTextKit/TextAlignment.cs +++ b/Topten.RichTextKit/TextAlignment.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/TextBlock.cs b/Topten.RichTextKit/TextBlock.cs index 6fd9a01..b800cf5 100644 --- a/Topten.RichTextKit/TextBlock.cs +++ b/Topten.RichTextKit/TextBlock.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/TextDirection.cs b/Topten.RichTextKit/TextDirection.cs index a5a7f89..cbb8ab0 100644 --- a/Topten.RichTextKit/TextDirection.cs +++ b/Topten.RichTextKit/TextDirection.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/TextLine.cs b/Topten.RichTextKit/TextLine.cs index f2c6ef3..2c27ae8 100644 --- a/Topten.RichTextKit/TextLine.cs +++ b/Topten.RichTextKit/TextLine.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/TextPaintOptions.cs b/Topten.RichTextKit/TextPaintOptions.cs index a7f8436..b04f2d5 100644 --- a/Topten.RichTextKit/TextPaintOptions.cs +++ b/Topten.RichTextKit/TextPaintOptions.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/TextShaping/TextShaper.cs b/Topten.RichTextKit/TextShaping/TextShaper.cs index 910fb62..ac28aac 100644 --- a/Topten.RichTextKit/TextShaping/TextShaper.cs +++ b/Topten.RichTextKit/TextShaping/TextShaper.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/UnderlineStyle.cs b/Topten.RichTextKit/UnderlineStyle.cs index c55d2e1..c3d0406 100644 --- a/Topten.RichTextKit/UnderlineStyle.cs +++ b/Topten.RichTextKit/UnderlineStyle.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Unicode/Directionality.cs b/Topten.RichTextKit/Unicode/Directionality.cs index f4be33e..a36a66c 100644 --- a/Topten.RichTextKit/Unicode/Directionality.cs +++ b/Topten.RichTextKit/Unicode/Directionality.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Unicode/LineBreakClass.cs b/Topten.RichTextKit/Unicode/LineBreakClass.cs index d5e72ba..d485b3a 100644 --- a/Topten.RichTextKit/Unicode/LineBreakClass.cs +++ b/Topten.RichTextKit/Unicode/LineBreakClass.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"), you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Unicode/PairedBracketType.cs b/Topten.RichTextKit/Unicode/PairedBracketType.cs index 86fe19d..36c2d11 100644 --- a/Topten.RichTextKit/Unicode/PairedBracketType.cs +++ b/Topten.RichTextKit/Unicode/PairedBracketType.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Unicode/UnicodeClasses.cs b/Topten.RichTextKit/Unicode/UnicodeClasses.cs index 74fd2da..03ded52 100644 --- a/Topten.RichTextKit/Unicode/UnicodeClasses.cs +++ b/Topten.RichTextKit/Unicode/UnicodeClasses.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Unicode/UnicodeTrie.cs b/Topten.RichTextKit/Unicode/UnicodeTrie.cs index 3f57144..540b6fe 100644 --- a/Topten.RichTextKit/Unicode/UnicodeTrie.cs +++ b/Topten.RichTextKit/Unicode/UnicodeTrie.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Unicode/UnicodeTrieBuilder.cs b/Topten.RichTextKit/Unicode/UnicodeTrieBuilder.cs index 2bd0ebe..6ec3dab 100644 --- a/Topten.RichTextKit/Unicode/UnicodeTrieBuilder.cs +++ b/Topten.RichTextKit/Unicode/UnicodeTrieBuilder.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/ArrayEnumerator.cs b/Topten.RichTextKit/Utils/ArrayEnumerator.cs index 41c08f0..bccc5c1 100644 --- a/Topten.RichTextKit/Utils/ArrayEnumerator.cs +++ b/Topten.RichTextKit/Utils/ArrayEnumerator.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/BiDictionary.cs b/Topten.RichTextKit/Utils/BiDictionary.cs index fd66d1d..d230096 100644 --- a/Topten.RichTextKit/Utils/BiDictionary.cs +++ b/Topten.RichTextKit/Utils/BiDictionary.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/BinaryReaderExtensions.cs b/Topten.RichTextKit/Utils/BinaryReaderExtensions.cs index b21b2ca..a71905f 100644 --- a/Topten.RichTextKit/Utils/BinaryReaderExtensions.cs +++ b/Topten.RichTextKit/Utils/BinaryReaderExtensions.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/BinarySearchExtension.cs b/Topten.RichTextKit/Utils/BinarySearchExtension.cs index 571da03..85dd8fc 100644 --- a/Topten.RichTextKit/Utils/BinarySearchExtension.cs +++ b/Topten.RichTextKit/Utils/BinarySearchExtension.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/Buffer.cs b/Topten.RichTextKit/Utils/Buffer.cs index 0c2fabf..65a685e 100644 --- a/Topten.RichTextKit/Utils/Buffer.cs +++ b/Topten.RichTextKit/Utils/Buffer.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/InternalsVisibleTo.cs b/Topten.RichTextKit/Utils/InternalsVisibleTo.cs index 6e47335..afa93d3 100644 --- a/Topten.RichTextKit/Utils/InternalsVisibleTo.cs +++ b/Topten.RichTextKit/Utils/InternalsVisibleTo.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/MappedSlice.cs b/Topten.RichTextKit/Utils/MappedSlice.cs index e990665..d9f63eb 100644 --- a/Topten.RichTextKit/Utils/MappedSlice.cs +++ b/Topten.RichTextKit/Utils/MappedSlice.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/ObjectPool.cs b/Topten.RichTextKit/Utils/ObjectPool.cs index aeb0c58..e35b2cc 100644 --- a/Topten.RichTextKit/Utils/ObjectPool.cs +++ b/Topten.RichTextKit/Utils/ObjectPool.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/Slice.cs b/Topten.RichTextKit/Utils/Slice.cs index 9ee93db..d282002 100644 --- a/Topten.RichTextKit/Utils/Slice.cs +++ b/Topten.RichTextKit/Utils/Slice.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/Utf32Buffer.cs b/Topten.RichTextKit/Utils/Utf32Buffer.cs index 954831d..4e332e5 100644 --- a/Topten.RichTextKit/Utils/Utf32Buffer.cs +++ b/Topten.RichTextKit/Utils/Utf32Buffer.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/Topten.RichTextKit/Utils/Utf32Utils.cs b/Topten.RichTextKit/Utils/Utf32Utils.cs index 8bc8c72..9b85715 100644 --- a/Topten.RichTextKit/Utils/Utf32Utils.cs +++ b/Topten.RichTextKit/Utils/Utf32Utils.cs @@ -1,5 +1,5 @@ // RichTextKit -// Copyright © 2019 Topten Software. All Rights Reserved. +// Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain diff --git a/doc/license.page b/doc/license.page index 232dc38..ec6f89b 100644 --- a/doc/license.page +++ b/doc/license.page @@ -3,7 +3,7 @@ title: "License" isMarkdown: false ---

License

-

Copyright © 2019 Topten Software. All Rights Reserved.

+

Copyright © 2019-2020 Topten Software. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this product except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

diff --git a/docsrc/basics.md b/docsrc/basics.md index 678df4c..898969b 100644 --- a/docsrc/basics.md +++ b/docsrc/basics.md @@ -7,19 +7,50 @@ title: Basic Concepts The page describes some basic concepts that are important to understand when working with RichTextKit. +## Rich Strings + +The easiest way to work with RichTextKit is with the `RichString` class which +provides a convenient set of methods for constructing richly decorated text. + +~~~ +// Create a RichString +var rs = new RichString() + .Alignment(TextAlignment.Center) + .FontFamily("Segoe UI") + .MarginBottom(20) + .Add("Welcome To RichTextKit", fontSize:24, fontWeight: 700, fontItalic: true) + .Paragraph().Alignment(TextAlignment.Left) + .FontSize(18) + .Add("This is a test string"); +~~~ + +If you want to wrap and/or crop it, set the Max properties: + +~~~ +rs.MaxWidth = 640; +rs.MaxHeight = 480; +~~~ + +And then you can paint it: + +~~~ +// Paint it +rs.Paint(skia_canvas, new SKPoint(50, 50)); +~~~ + +You can also get it's measured size: + +~~~ +Console.WriteLine($"Size: {rs.MeasuredWidth} x {rs.MeasuredHeight}); +~~~ + +and lots more. See the [T:Topten.RichTextKit.RichString] class for details. + ## Text Blocks -RichTextKit primarily works with individual blocks of text where each is -essentially a paragraph. - -RichTextKit doesn't provide document level constructs like list items, -block quotes, tables, table cells, divs etc... This project is strictly -about laying out a single block of text with rich (aka attributed) text -and then providing various functions for working with that text block. - -RichTextKit doesn't have a concept of a DOM - that's a higher level concept -that RichTextKit is not attempting to solve. +Text blocks are a lower level concept that describes a single block of +text. Internally RichString builds a single text block for each paragraph. Text blocks can contain forced line breaks with a newline character (`\n`). These should be considered as in-paragraph "soft returns", as opposed to @@ -38,6 +69,9 @@ single style and these text runs are referred to a "style runs". Style runs are represented by the [T:Topten.RichTextKit.StyleRun] class. +Styles are only used if dealing with TextBlocks directly and generally don't +need to be used if you're using the higher-level RichString interface. + ## Font Fallback Font fallback is the process of switching to a different font when the specified diff --git a/docsrc/caret.md b/docsrc/caret.md index 4a065bf..98e97ac 100644 --- a/docsrc/caret.md +++ b/docsrc/caret.md @@ -10,7 +10,8 @@ any editing capabilities, it does include the ability to calculate where the caret should be displayed. To determine where the caret should be displayed, call the -[GetCaretInfo](./ref/Topten.RichTextKit.TextBlock.GetCaretInfo) +[RichString.GetCaretInfo](./ref/Topten.RichTextKit.RichString.GetCaretInfo) or +[TextBlock.GetCaretInfo](./ref/Topten.RichTextKit.TextBlock.GetCaretInfo) method which will return a [T:Topten.RichTextKit.CaretInfo] structure describing where the caret should be drawn, the shape of the caret (sloped for italic) and other useful details about the current caret position. diff --git a/docsrc/hittesting.md b/docsrc/hittesting.md index e9176eb..1338a8e 100644 --- a/docsrc/hittesting.md +++ b/docsrc/hittesting.md @@ -4,7 +4,7 @@ title: Hit Testing # Hit Testing -Hit testing lets you find the line and character cluster that a coordinate +Hit testing lets you find the character cluster that a co-ordinate is either directly over and/or closest to. This can be used to be build a range selection feature and/or as part of a more comprehensive editor. @@ -13,8 +13,8 @@ selection feature and/or as part of a more comprehensive editor. var htr = tb.HitTest(x, y); ``` -The co-ordinates passed to the [HitTest](./ref/Topten.RichTextKit.TextBlock.HitTest) -method must be relative to the top-left corner of the text block. (ie: you'll probably +The co-ordinates passed to the [RichString.HitTest](./ref/Topten.RichTextKit.RichString.HitTest) and [TextBlock.HitTest](./ref/Topten.RichTextKit.TextBlock.HitTest) +methods must be relative to the top-left corner of the object. (ie: you'll probably need to adjust the co-ordinates by subtracting the top-left position of where you're displaying the text block). diff --git a/docsrc/layout.md b/docsrc/layout.md index ce03da7..23c08a7 100644 --- a/docsrc/layout.md +++ b/docsrc/layout.md @@ -4,7 +4,28 @@ title: Controlling Layout # Controlling Layout -The following properties can be used to control the layout of a text block: +The following properties can be used to control the layout of a RichString: + +* [P:Topten.RichTextKit.RichString.MaxWidth] +* [P:Topten.RichTextKit.RichString.MaxHeight] +* [P:Topten.RichTextKit.RichString.MaxLines] +* [P:Topten.RichTextKit.RichString.DefaultAlignment] +* [P:Topten.RichTextKit.RichString.DefaultDirection] + +Per-paragraph control of layout is available through the following +fluent methods: + +* [P:Topten.RichTextKit.RichString.MarginLeft] +* [P:Topten.RichTextKit.RichString.MarginTop] +* [P:Topten.RichTextKit.RichString.MarginRight] +* [P:Topten.RichTextKit.RichString.MarginBottom] +* [P:Topten.RichTextKit.RichString.Alignment] +* [P:Topten.RichTextKit.RichString.TextDirection] + + +# TextBlocks + +The following properties can be used to control the layout of a TextBlock: * [P:Topten.RichTextKit.TextBlock.MaxWidth] * [P:Topten.RichTextKit.TextBlock.MaxHeight] diff --git a/docsrc/license.md b/docsrc/license.md index 3a3e045..4e8fcd3 100644 --- a/docsrc/license.md +++ b/docsrc/license.md @@ -4,7 +4,7 @@ title: License # License -Copyright © 2019 Topten Software. All Rights Reserved. +Copyright © 2020 Topten Software. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this product except in compliance with the License. You may obtain a copy of the License at diff --git a/docsrc/measuring.md b/docsrc/measuring.md index 5279ff7..019d211 100644 --- a/docsrc/measuring.md +++ b/docsrc/measuring.md @@ -2,12 +2,23 @@ title: Measuring Text --- -# Measuring Text +# Measuring RichString + +The `RichString` class provides various measurements of its contained text. + +* [P:Topten.RichTextKit.RichString.MeasuredWidth] +* [P:Topten.RichTextKit.RichString.MeasuredHeight] +* [P:Topten.RichTextKit.RichString.MeasuredLength] +* [P:Topten.RichTextKit.RichString.LineCount] + + +# Measuring TextBlock The `TextBlock` class provides various measurements of its contained text. * [P:Topten.RichTextKit.TextBlock.MeasuredWidth] * [P:Topten.RichTextKit.TextBlock.MeasuredHeight] +* [P:Topten.RichTextKit.TextBlock.MeasuredLength] * [P:Topten.RichTextKit.TextBlock.MeasuredPadding] * [P:Topten.RichTextKit.TextBlock.MeasuredOverhang] diff --git a/docsrc/rendering.md b/docsrc/rendering.md index 7304705..a7d5955 100644 --- a/docsrc/rendering.md +++ b/docsrc/rendering.md @@ -4,12 +4,11 @@ title: Rendering Text # Rendering Text -Once you've created and initialized a text block, you can render it to a SkiaSharp canvas -using its [Paint()]((./ref/Topten.RichTextKit.TextBlock.Paint)) method: +Text can be rendered using [RichString.Paint()]((./ref/Topten.RichTextKit.RichString.Paint)) or [TextBlock.Paint()]((./ref/Topten.RichTextKit.TextBlock.Paint)) methods: ~~~csharp // Paint at (0,0) -tb.Paint(canvas); +textBlockOrRichString.Paint(canvas); ~~~ By default the text will be rendered at the position (0,0). `Use SKCanvas.Translate()` to set @@ -17,13 +16,13 @@ the paint position or pass the position as a second parameter: ~~~csharp // Paint at (100,100) -tb.Paint(canvas, new SKPoint(100,100)); +textBlockOrRichString.Paint(canvas, new SKPoint(100,100)); ~~~ ## Rendering with a Selection Highlight -A text block can also be rendered with part of the text highlighted. +Text can also be rendered with part of the text highlighted. ~~~csharp // Highlight code points 10 through 19... @@ -35,7 +34,7 @@ var options = new TextPaintOptions() } // Paint with options -tb.Paint(canvas, new SKPaint(100,100), options); +textBlockOrRichString.Paint(canvas, new SKPaint(100,100), options); ~~~ diff --git a/docsrc/textBlock.md b/docsrc/textBlock.md index 7c0f835..662a05d 100644 --- a/docsrc/textBlock.md +++ b/docsrc/textBlock.md @@ -4,7 +4,11 @@ title: Creating a TextBlock # Creating a TextBlock -The primary class you work with when using RichTextKit is the [T:Topten.RichTextKit.TextBlock] class. This section describes how to create a text block and add text to it. +The TextBlock class is a low-level class for working with a single block of text. In +general you probably don't need to use this class as the higher level RichString class +is easier to work with and provides most of the same capabilities. + +Never-the-less, this section describes how to work with the TextBlock class. ## Create a Text block