This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,162 @@
using System;
using System.Linq;
using Unity.CodeEditor.Document;
namespace Unity.CodeEditor.TextMate
{
internal class DocumentSnapshot
{
private LineRange[] _lineRanges;
private TextDocument _document;
private ITextSource _textSource;
private object _lock = new object();
private int _lineCount;
internal int LineCount
{
get { lock (_lock) { return _lineCount; } }
}
internal DocumentSnapshot(TextDocument document)
{
_document = document;
_lineRanges = new LineRange[document.LineCount];
Update(null);
}
internal void RemoveLines(int startLine, int endLine)
{
lock (_lock)
{
var tmpList = _lineRanges.ToList();
tmpList.RemoveRange(startLine, endLine - startLine + 1);
_lineRanges = tmpList.ToArray();
_lineCount = _lineRanges.Length;
}
}
internal string GetLineText(int lineIndex)
{
lock (_lock)
{
var lineRange = _lineRanges[lineIndex];
return _textSource.GetText(lineRange.Offset, lineRange.Length);
}
}
internal string GetLineTextIncludingTerminator(int lineIndex)
{
lock (_lock)
{
var lineRange = _lineRanges[lineIndex];
return _textSource.GetText(lineRange.Offset, lineRange.TotalLength);
}
}
internal ReadOnlyMemory<char> GetLineTextIncludingTerminatorAsMemory(int lineIndex)
{
lock (_lock)
{
var lineRange = _lineRanges[lineIndex];
return _textSource.GetTextAsMemory(lineRange.Offset, lineRange.TotalLength);
}
}
internal string GetLineTerminator(int lineIndex)
{
lock (_lock)
{
var lineRange = _lineRanges[lineIndex];
return _textSource.GetText(lineRange.Offset + lineRange.Length, lineRange.TotalLength - lineRange.Length);
}
}
internal int GetLineLength(int lineIndex)
{
lock (_lock)
{
return _lineRanges[lineIndex].Length;
}
}
internal int GetTotalLineLength(int lineIndex)
{
lock (_lock)
{
return _lineRanges[lineIndex].TotalLength;
}
}
internal string GetText()
{
lock (_lock)
{
return _textSource.Text;
}
}
internal void Update(DocumentChangeEventArgs e)
{
lock (_lock)
{
_lineCount = _document.Lines.Count;
if (e != null && e.OffsetChangeMap != null && _lineRanges != null && _lineCount == _lineRanges.Length)
{
// it's a single-line change
// update the offsets usign the OffsetChangeMap
RecalculateOffsets(e);
}
else
{
// recompute all the line ranges
// based in the document lines
RecomputeAllLineRanges(e);
}
_textSource = _document.CreateSnapshot();
}
}
private void RecalculateOffsets(DocumentChangeEventArgs e)
{
var changedLine = _document.GetLineByOffset(e.Offset);
int lineIndex = changedLine.LineNumber - 1;
_lineRanges[lineIndex].Offset = changedLine.Offset;
_lineRanges[lineIndex].Length = changedLine.Length;
_lineRanges[lineIndex].TotalLength = changedLine.TotalLength;
for (int i = lineIndex + 1; i < _lineCount; i++)
{
_lineRanges[i].Offset = e.OffsetChangeMap.GetNewOffset(_lineRanges[i].Offset);
}
}
private void RecomputeAllLineRanges(DocumentChangeEventArgs e)
{
Array.Resize(ref _lineRanges, _lineCount);
int currentLineIndex = (e != null) ?
_document.GetLineByOffset(e.Offset).LineNumber - 1 : 0;
var currentLine = _document.GetLineByNumber(currentLineIndex + 1);
while (currentLine != null)
{
_lineRanges[currentLineIndex].Offset = currentLine.Offset;
_lineRanges[currentLineIndex].Length = currentLine.Length;
_lineRanges[currentLineIndex].TotalLength = currentLine.TotalLength;
currentLine = currentLine.NextLine;
currentLineIndex++;
}
}
struct LineRange
{
internal int Offset;
internal int Length;
internal int TotalLength;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e7645ffe601f4ca9ac1285112b331d35
timeCreated: 1711014789
@@ -0,0 +1,101 @@
using System;
using Unity.CodeEditor.Document;
using Unity.CodeEditor.Rendering;
using UnityEngine;
namespace Unity.CodeEditor.TextMate
{
internal abstract class GenericLineTransformer : DocumentColorizingTransformer
{
private Action<Exception> _exceptionHandler;
internal GenericLineTransformer(Action<Exception> exceptionHandler)
{
_exceptionHandler = exceptionHandler;
}
protected override void ColorizeLine(DocumentLine line)
{
try
{
TransformLine(line, CurrentContext);
}
catch (Exception ex)
{
_exceptionHandler?.Invoke(ex);
}
}
protected abstract void TransformLine(DocumentLine line, ITextRunConstructionContext context);
internal void SetTextStyle(
DocumentLine line,
int startIndex,
int length,
Color foreground,
Color background,
FontStyle fontStyle,
//FontWeight fontWeigth,
bool isUnderline)
{
int startOffset = 0;
int endOffset = 0;
if (startIndex >= 0 && length > 0)
{
if ((line.Offset + startIndex + length) > line.EndOffset)
{
length = (line.EndOffset - startIndex) - line.Offset - startIndex;
}
startOffset = line.Offset + startIndex;
endOffset = line.Offset + startIndex + length;
}
else
{
startOffset = line.Offset;
endOffset = line.EndOffset;
}
if (startOffset > CurrentContext.Document.TextLength ||
endOffset > CurrentContext.Document.TextLength)
return;
ChangeLinePart(
startOffset,
endOffset,
visualLine => ChangeVisualLine(visualLine, foreground, background, fontStyle/*, fontWeigth*/, isUnderline));
}
void ChangeVisualLine(
VisualLineElement visualLine,
Color foreground,
Color background,
FontStyle fontStyle,
//FontWeight fontWeigth,
bool isUnderline)
{
TextParagraphProperties newProperties = visualLine.TextParagraphProperties.Clone();
if (foreground != null)
newProperties.SetForegroundColor(foreground);
/*if (background != null)
newProperties.SetBackgroundBrush(background);
if (isUnderline)
{
newProperties.SetTextDecorations(TextDecorations.Underline);
}
if (visualLine.TextRunProperties.Typeface.Style != fontStyle ||
newProperties.Typeface.Weight != fontWeigth)
{
newProperties.SetTypeface(new Typeface(
visualLine.TextRunProperties.Typeface.FontFamily, fontStyle, fontWeigth));
}*/
visualLine.SetTextParagraphProperties(newProperties);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 439fd5e50e8547c3980e339ea634214d
timeCreated: 1711014817
@@ -0,0 +1,212 @@
using System;
using TextMateSharp.Grammars;
using TextMateSharp.Model;
using Unity.CodeEditor.Document;
using Unity.CodeEditor.Rendering;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.CodeEditor.TextMate
{
internal class TextEditorModel : AbstractLineList, IDisposable
{
private readonly TextDocument _document;
private readonly TextView _textView;
private DocumentSnapshot _documentSnapshot;
private Action<Exception> _exceptionHandler;
private InvalidLineRange _invalidRange;
internal DocumentSnapshot DocumentSnapshot { get { return _documentSnapshot; } }
internal InvalidLineRange InvalidRange { get { return _invalidRange; } }
internal TextEditorModel(TextView textView, TextDocument document, Action<Exception> exceptionHandler)
{
_textView = textView;
_document = document;
_exceptionHandler = exceptionHandler;
_documentSnapshot = new DocumentSnapshot(_document);
for (int i = 0; i < _document.LineCount; i++)
AddLine(i);
_document.Changing += DocumentOnChanging;
_document.Changed += DocumentOnChanged;
_document.UpdateFinished += DocumentOnUpdateFinished;
_textView.ScrollOffsetChanged += TextView_ScrollOffsetChanged;
}
public override void Dispose()
{
_document.Changing -= DocumentOnChanging;
_document.Changed -= DocumentOnChanged;
_document.UpdateFinished -= DocumentOnUpdateFinished;
_textView.ScrollOffsetChanged -= TextView_ScrollOffsetChanged;
}
public override void UpdateLine(int lineIndex) { }
internal void InvalidateViewPortLines()
{
if (!_textView.VisualLinesValid ||
_textView.VisualLines.Count == 0)
return;
InvalidateLineRange(
_textView.VisualLines[0].FirstDocumentLine.LineNumber - 1,
_textView.VisualLines[_textView.VisualLines.Count - 1].LastDocumentLine.LineNumber - 1);
}
public override int GetNumberOfLines()
{
return _documentSnapshot.LineCount;
}
public override LineText GetLineTextIncludingTerminators(int lineIndex)
{
return _documentSnapshot.GetLineTextIncludingTerminatorAsMemory(lineIndex);
}
public override int GetLineLength(int lineIndex)
{
return _documentSnapshot.GetLineLength(lineIndex);
}
private void TextView_ScrollOffsetChanged(object sender, EventArgs e)
{
try
{
TokenizeViewPort();
}
catch (Exception ex)
{
_exceptionHandler?.Invoke(ex);
}
}
private void DocumentOnChanging(object sender, DocumentChangeEventArgs e)
{
try
{
if (e.RemovalLength > 0)
{
var startLine = _document.GetLineByOffset(e.Offset).LineNumber - 1;
var endLine = _document.GetLineByOffset(e.Offset + e.RemovalLength).LineNumber - 1;
for (int i = endLine; i > startLine; i--)
{
RemoveLine(i);
}
_documentSnapshot.RemoveLines(startLine, endLine);
}
}
catch (Exception ex)
{
_exceptionHandler?.Invoke(ex);
}
}
private void DocumentOnChanged(object sender, DocumentChangeEventArgs e)
{
try
{
int startLine = _document.GetLineByOffset(e.Offset).LineNumber - 1;
int endLine = startLine;
if (e.InsertionLength > 0)
{
endLine = _document.GetLineByOffset(e.Offset + e.InsertionLength).LineNumber - 1;
for (int i = startLine; i < endLine; i++)
{
AddLine(i);
}
}
_documentSnapshot.Update(e);
if (startLine == 0)
{
SetInvalidRange(startLine, endLine);
return;
}
// some grammars (JSON, csharp, ...)
// need to invalidate the previous line too
SetInvalidRange(startLine - 1, endLine);
}
catch (Exception ex)
{
_exceptionHandler?.Invoke(ex);
}
}
private void SetInvalidRange(int startLine, int endLine)
{
if (!_document.IsInUpdate)
{
InvalidateLineRange(startLine, endLine);
return;
}
// we're in a document change, store the max invalid range
if (_invalidRange == null)
{
_invalidRange = new InvalidLineRange(startLine, endLine);
return;
}
_invalidRange.SetInvalidRange(startLine, endLine);
}
void DocumentOnUpdateFinished(object sender, EventArgs e)
{
if (_invalidRange == null)
return;
try
{
InvalidateLineRange(_invalidRange.StartLine, _invalidRange.EndLine);
}
finally
{
_invalidRange = null;
}
}
private void TokenizeViewPort()
{
EditorDispatcher.Dispatch(() =>
{
if (!_textView.VisualLinesValid ||
_textView.VisualLines.Count == 0)
return;
ForceTokenization(
_textView.VisualLines[0].FirstDocumentLine.LineNumber - 1,
_textView.VisualLines[_textView.VisualLines.Count - 1].LastDocumentLine.LineNumber - 1);
});
}
internal class InvalidLineRange
{
internal int StartLine { get; private set; }
internal int EndLine { get; private set; }
internal InvalidLineRange(int startLine, int endLine)
{
StartLine = startLine;
EndLine = endLine;
}
internal void SetInvalidRange(int startLine, int endLine)
{
if (startLine < StartLine)
StartLine = startLine;
if (endLine > EndLine)
EndLine = endLine;
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9bcb62e10f5c4f029b5bc5046ed41d51
timeCreated: 1711014897
@@ -0,0 +1,150 @@
using System;
using System.Linq;
using TextMateSharp.Grammars;
using TextMateSharp.Model;
using TextMateSharp.Registry;
using TextMateSharp.Themes;
namespace Unity.CodeEditor.TextMate
{
internal static class TextMate
{
internal static void RegisterExceptionHandler(Action<Exception> handler)
{
_exceptionHandler = handler;
}
internal static Installation InstallTextMate(
this TextEditor editor,
IRegistryOptions registryOptions,
bool initCurrentDocument = true)
{
return new Installation(editor, registryOptions, initCurrentDocument);
}
internal class Installation
{
private IRegistryOptions _textMateRegistryOptions;
private Registry _textMateRegistry;
private TextEditor _editor;
private TextEditorModel _editorModel;
private IGrammar _grammar;
private TMModel _tmModel;
private TextMateColoringTransformer _transformer;
internal IRegistryOptions RegistryOptions { get { return _textMateRegistryOptions; } }
internal TextEditorModel EditorModel { get { return _editorModel; } }
internal Installation(TextEditor editor, IRegistryOptions registryOptions, bool initCurrentDocument = true)
{
_textMateRegistryOptions = registryOptions;
_textMateRegistry = new Registry(registryOptions);
_editor = editor;
SetTheme(registryOptions.GetDefaultTheme());
editor.DocumentChanged += OnEditorOnDocumentChanged;
if (initCurrentDocument)
{
OnEditorOnDocumentChanged(editor, EventArgs.Empty);
}
}
internal void SetGrammar(string scopeName)
{
_grammar = _textMateRegistry.LoadGrammar(scopeName);
GetOrCreateTransformer().SetGrammar(_grammar);
_editor.TextArea.TextView.Redraw();
}
internal void SetTheme(IRawTheme theme)
{
_textMateRegistry.SetTheme(theme);
GetOrCreateTransformer().SetTheme(_textMateRegistry.GetTheme());
_tmModel?.InvalidateLine(0);
_editorModel?.InvalidateViewPortLines();
}
internal void Dispose()
{
_editor.DocumentChanged -= OnEditorOnDocumentChanged;
DisposeEditorModel(_editorModel);
DisposeTMModel(_tmModel, _transformer);
DisposeTransformer(_transformer);
}
void OnEditorOnDocumentChanged(object sender, EventArgs args)
{
try
{
DisposeEditorModel(_editorModel);
DisposeTMModel(_tmModel, _transformer);
_editorModel = new TextEditorModel(_editor.TextArea.TextView, _editor.Document, _exceptionHandler);
_tmModel = new TMModel(_editorModel);
_tmModel.SetGrammar(_grammar);
_transformer = GetOrCreateTransformer();
_transformer.SetModel(_editor.Document, _tmModel);
_tmModel.AddModelTokensChangedListener(_transformer);
}
catch (Exception ex)
{
_exceptionHandler?.Invoke(ex);
}
}
TextMateColoringTransformer GetOrCreateTransformer()
{
var transformer = _editor.TextArea.TextView.LineTransformers.OfType<TextMateColoringTransformer>().FirstOrDefault();
if (transformer is null)
{
transformer = new TextMateColoringTransformer(
_editor.TextArea.TextView, _exceptionHandler);
_editor.TextArea.TextView.LineTransformers.Add(transformer);
}
return transformer;
}
static void DisposeTransformer(TextMateColoringTransformer transformer)
{
if (transformer == null)
return;
transformer.Dispose();
}
static void DisposeTMModel(TMModel tmModel, TextMateColoringTransformer transformer)
{
if (tmModel == null)
return;
if (transformer != null)
tmModel.RemoveModelTokensChangedListener(transformer);
tmModel.Dispose();
}
static void DisposeEditorModel(TextEditorModel editorModel)
{
if (editorModel == null)
return;
editorModel.Dispose();
}
}
static Action<Exception> _exceptionHandler;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0040383d747f4e9392c3c770bded7f25
timeCreated: 1711014982
@@ -0,0 +1,268 @@
using System;
using System.Buffers;
using System.Collections.Generic;
using TextMateSharp.Grammars;
using TextMateSharp.Model;
using TextMateSharp.Themes;
using Unity.CodeEditor.Document;
using Unity.CodeEditor.Rendering;
using Unity.PlasticSCM.Editor.UI;
using UnityEngine;
using FontStyle = TextMateSharp.Themes.FontStyle;
namespace Unity.CodeEditor.TextMate
{
internal class TextMateColoringTransformer :
GenericLineTransformer,
IModelTokensChangedListener
{
private Theme _theme;
private IGrammar _grammar;
private TMModel _model;
private TextDocument _document;
private TextView _textView;
private Action<Exception> _exceptionHandler;
private volatile bool _areVisualLinesValid = false;
private volatile int _firstVisibleLineIndex = -1;
private volatile int _lastVisibleLineIndex = -1;
private readonly Dictionary<int, Color> _brushes;
internal TextMateColoringTransformer(
TextView textView,
Action<Exception> exceptionHandler)
: base(exceptionHandler)
{
_textView = textView;
_exceptionHandler = exceptionHandler;
_brushes = new Dictionary<int, Color>();
_textView.VisualLinesChanged += TextView_VisualLinesChanged;
}
internal void SetModel(TextDocument document, TMModel model)
{
_areVisualLinesValid = false;
_document = document;
_model = model;
if (_grammar != null)
{
_model.SetGrammar(_grammar);
}
}
private void TextView_VisualLinesChanged(object sender, EventArgs e)
{
try
{
if (!_textView.VisualLinesValid || _textView.VisualLines.Count == 0)
return;
_areVisualLinesValid = true;
_firstVisibleLineIndex = _textView.VisualLines[0].FirstDocumentLine.LineNumber - 1;
_lastVisibleLineIndex = _textView.VisualLines[_textView.VisualLines.Count - 1].LastDocumentLine.LineNumber - 1;
}
catch (Exception ex)
{
_exceptionHandler?.Invoke(ex);
}
}
internal void Dispose()
{
_textView.VisualLinesChanged -= TextView_VisualLinesChanged;
_brushes.Clear();
}
internal void SetTheme(Theme theme)
{
_theme = theme;
_brushes.Clear();
var map = _theme.GetColorMap();
foreach (var color in map)
{
var id = _theme.GetColorId(color);
_brushes[id] = ToRGBColor(NormalizeColor(color));
}
}
internal void SetGrammar(IGrammar grammar)
{
_grammar = grammar;
if (_model != null)
{
_model.SetGrammar(grammar);
}
}
protected override void TransformLine(DocumentLine line, ITextRunConstructionContext context)
{
try
{
if (_model == null)
return;
int lineNumber = line.LineNumber;
var tokens = _model.GetLineTokens(lineNumber - 1);
if (tokens == null)
return;
var transformsInLine = ArrayPool<ForegroundTextTransformation>.Shared.Rent(tokens.Count);
try
{
GetLineTransformations(lineNumber, tokens, transformsInLine);
for (int i = 0; i < tokens.Count; i++)
{
if (transformsInLine[i] == null)
continue;
transformsInLine[i].Transform(this, line);
}
}
finally
{
ArrayPool<ForegroundTextTransformation>.Shared.Return(transformsInLine);
}
}
catch (Exception ex)
{
_exceptionHandler?.Invoke(ex);
}
}
private void GetLineTransformations(int lineNumber, List<TMToken> tokens, ForegroundTextTransformation[] transformations)
{
for (int i = 0; i < tokens.Count; i++)
{
var token = tokens[i];
var nextToken = (i + 1) < tokens.Count ? tokens[i + 1] : null;
var startIndex = token.StartIndex;
var endIndex = nextToken?.StartIndex ?? _model.GetLines().GetLineLength(lineNumber - 1);
if (startIndex >= endIndex || token.Scopes == null || token.Scopes.Count == 0)
{
transformations[i] = null;
continue;
}
var lineOffset = _document.GetLineByNumber(lineNumber).Offset;
int foreground = 0;
int background = 0;
FontStyle fontStyle = 0;
foreach (var themeRule in _theme.Match(token.Scopes))
{
if (foreground == 0 && themeRule.foreground > 0)
foreground = themeRule.foreground;
if (background == 0 && themeRule.background > 0)
background = themeRule.background;
if (fontStyle == 0 && themeRule.fontStyle > 0)
fontStyle = themeRule.fontStyle;
}
if (transformations[i] == null)
transformations[i] = new ForegroundTextTransformation();
transformations[i].ColorMap = _brushes;
transformations[i].ExceptionHandler = _exceptionHandler;
transformations[i].StartOffset = lineOffset + startIndex;
transformations[i].EndOffset = lineOffset + endIndex;
transformations[i].ForegroundColor = foreground;
transformations[i].BackgroundColor = background;
transformations[i].FontStyle = fontStyle;
}
}
public void ModelTokensChanged(ModelTokensChangedEvent e)
{
if (e.Ranges == null)
return;
if (_model == null || _model.IsStopped)
return;
int firstChangedLineIndex = int.MaxValue;
int lastChangedLineIndex = -1;
foreach (var range in e.Ranges)
{
firstChangedLineIndex = Math.Min(range.FromLineNumber - 1, firstChangedLineIndex);
lastChangedLineIndex = Math.Max(range.ToLineNumber - 1, lastChangedLineIndex);
}
if (_areVisualLinesValid)
{
bool changedLinesAreNotVisible =
((firstChangedLineIndex < _firstVisibleLineIndex && lastChangedLineIndex < _firstVisibleLineIndex) ||
(firstChangedLineIndex > _lastVisibleLineIndex && lastChangedLineIndex > _lastVisibleLineIndex));
if (changedLinesAreNotVisible)
return;
}
EditorDispatcher.Dispatch(() =>
{
int firstLineIndexToRedraw = Math.Max(firstChangedLineIndex, _firstVisibleLineIndex);
int lastLineIndexToRedrawLine = Math.Min(lastChangedLineIndex, _lastVisibleLineIndex);
int totalLines = _document.Lines.Count - 1;
firstLineIndexToRedraw = Clamp(firstLineIndexToRedraw, 0, totalLines);
lastLineIndexToRedrawLine = Clamp(lastLineIndexToRedrawLine, 0, totalLines);
DocumentLine firstLineToRedraw = _document.Lines[firstLineIndexToRedraw];
DocumentLine lastLineToRedraw = _document.Lines[lastLineIndexToRedrawLine];
_textView.Redraw(
firstLineToRedraw.Offset,
(lastLineToRedraw.Offset + lastLineToRedraw.TotalLength) - firstLineToRedraw.Offset);
});
}
static int Clamp(int value, int min, int max)
{
if (value < min)
return min;
if (value > max)
return max;
return value;
}
static string NormalizeColor(string color)
{
if (color.Length == 9)
{
Span<char> normalizedColor = stackalloc char[] { '#', color[7], color[8], color[1], color[2], color[3], color[4], color[5], color[6] };
return normalizedColor.ToString();
}
return color;
}
static Color ToRGBColor(string normalizedColor)
{
if (ColorUtility.TryParseHtmlString(normalizedColor, out Color color))
return color;
return Color.red;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: edabbb8e32454a61b831d5b7deed1360
timeCreated: 1711015002
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using Unity.CodeEditor.Document;
using Unity.CodeEditor.TextMate;
using UnityEngine;
using UE = UnityEngine;
using TM = TextMateSharp.Themes;
namespace Unity.CodeEditor.TextMate
{
internal abstract class TextTransformation : TextSegment
{
internal abstract void Transform(GenericLineTransformer transformer, DocumentLine line);
}
internal class ForegroundTextTransformation : TextTransformation
{
internal Dictionary<int, Color> ColorMap { get; set; }
internal Action<Exception> ExceptionHandler { get; set; }
internal int ForegroundColor { get; set; }
internal int BackgroundColor { get; set; }
internal TM.FontStyle FontStyle { get; set; }
internal override void Transform(GenericLineTransformer transformer, DocumentLine line)
{
try
{
if (Length == 0)
{
return;
}
var formattedOffset = 0;
var endOffset = line.EndOffset;
if (StartOffset > line.Offset)
{
formattedOffset = StartOffset - line.Offset;
}
if (EndOffset < line.EndOffset)
{
endOffset = EndOffset;
}
transformer.SetTextStyle(line, formattedOffset, endOffset - line.Offset - formattedOffset,
GetBrush(ForegroundColor),
GetBrush(BackgroundColor),
GetFontStyle(),
//GetFontWeight(),
IsUnderline());
}
catch (Exception ex)
{
ExceptionHandler?.Invoke(ex);
}
}
UE.FontStyle GetFontStyle()
{
if (FontStyle != TM.FontStyle.NotSet &&
(FontStyle & TM.FontStyle.Italic) != 0)
return UE.FontStyle.Italic;
if (FontStyle != TM.FontStyle.NotSet &&
(FontStyle & TM.FontStyle.Bold) != 0)
return UE.FontStyle.Bold;
if (FontStyle != TM.FontStyle.NotSet &&
(FontStyle & TM.FontStyle.Bold) != 0 &&
(FontStyle & TM.FontStyle.Italic) != 0)
return UE.FontStyle.BoldAndItalic;
return UE.FontStyle.Normal;
}
bool IsUnderline()
{
if (FontStyle != TM.FontStyle.NotSet &&
(FontStyle & TM.FontStyle.Underline) != 0)
return true;
return false;
}
UE.Color GetBrush(int colorId)
{
if (ColorMap == null)
return UE.Color.red;
ColorMap.TryGetValue(colorId, out UE.Color result);
return result;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3e10ccf51dd64155bace2cf6aadd2614
timeCreated: 1711015036