Struct UnicodeRange
Represents a contiguous, inclusive range of Unicode codepoints with an optional human-readable name. Used to specify which character subsets to scan when extracting the set of supported glyphs from a font asset.
Implements
Inherited Members
Namespace: Scylla.Core.Util
Assembly: ScyllaCore.dll
Syntax
[Serializable]
public readonly struct UnicodeRange : IEquatable<UnicodeRange>
Remarks
Immutability: UnicodeRange is a readonly struct. Once created,
its Start, End, and Name fields cannot
be changed. This makes instances safe to store in static fields, pass by value, and
use across multiple threads without copying overhead.
Primary consumer: FontUtil uses arrays of UnicodeRange to drive
font character scanning, determining which codepoints to test for glyph availability
in a given font. Pass a range array to the relevant FontUtil overloads to
control the scan scope.
Preset ranges: A large set of pre-built named ranges is available as static fields (e.g. BasicLatin, Greek, BoxDrawing). Curated preset arrays group common combinations (e.g. Common, Western, FullSet), covering the vast majority of practical font scanning scenarios without any custom code.
Custom ranges: When a preset array does not meet a specific requirement,
instantiate one or more UnicodeRange values directly using the constructors
and combine them into a plain array.
Constructors
UnicodeRange(int, int)
Initialises a new UnicodeRange with the specified start and end codepoints and no descriptive name.
Declaration
public UnicodeRange(int start, int end)
Parameters
| Type | Name | Description |
|---|---|---|
| int | start | The first codepoint of the range (inclusive). Must be non-negative (zero or greater).
For example, pass |
| int | end | The last codepoint of the range (inclusive). Must be greater than or equal to
|
Remarks
The resulting instance has a null Name. Use the three-argument
overload UnicodeRange(int, int, string) when a descriptive label is
needed for debugging or display purposes.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
UnicodeRange(int, int, string)
Initialises a new UnicodeRange with the specified start and end codepoints and a descriptive name.
Declaration
public UnicodeRange(int start, int end, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| int | start | The first codepoint of the range (inclusive). Must be non-negative (zero or greater).
For example, pass |
| int | end | The last codepoint of the range (inclusive). Must be greater than or equal to
|
| string | name | A human-readable label for the range, such as |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
Fields
Arrows
Arrows (0x2190-0x21FF): Various arrow symbols.
Declaration
public static readonly UnicodeRange Arrows
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
BasicLatin
Basic Latin characters (0x0020-0x007E): ASCII printable characters.
Declaration
public static readonly UnicodeRange BasicLatin
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
BlockElements
Block Elements (0x2580-0x259F): Block and shade characters.
Declaration
public static readonly UnicodeRange BlockElements
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
BoxAndBlock
Box drawing and block element character ranges.
Declaration
public static readonly UnicodeRange[] BoxAndBlock
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
BoxDrawing
Box Drawing (0x2500-0x257F): Characters for drawing boxes and lines.
Declaration
public static readonly UnicodeRange BoxDrawing
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
Common
A minimal but broadly sufficient set of character ranges for most Western game UIs. Covers Basic Latin (ASCII printable), Latin-1 Supplement, General Punctuation, and Currency Symbols - approximately 350 codepoints in total.
Declaration
public static readonly UnicodeRange[] Common
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
Remarks
This set is sufficient for English-language UIs that display numbers, common punctuation, and a handful of currency symbols. It is the recommended starting point when minimising font texture atlas size is a priority. For European languages that use accented characters beyond Latin-1, see Western or Diacritics instead.
ControlCodes
Control picture character ranges.
Declaration
public static readonly UnicodeRange[] ControlCodes
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
ControlPictures
Control Pictures (0x2400-0x243F): Symbols representing control codes.
Declaration
public static readonly UnicodeRange ControlPictures
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
CurrencySymbols
Currency Symbols (0x20A0-0x20CF): Various currency symbols.
Declaration
public static readonly UnicodeRange CurrencySymbols
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
Cyrillic
Cyrillic (0x0400-0x04FF): Cyrillic alphabet for Russian and other Slavic languages.
Declaration
public static readonly UnicodeRange Cyrillic
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
CyrillicSet
Cyrillic character ranges including Cyrillic and Cyrillic Supplement.
Declaration
public static readonly UnicodeRange[] CyrillicSet
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
CyrillicSupplement
Cyrillic Supplement (0x0500-0x052F): Additional Cyrillic characters.
Declaration
public static readonly UnicodeRange CyrillicSupplement
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
Diacritics
Diacritics character ranges for accented Latin characters. Includes Latin-1 Supplement, Latin Extended-A/B, and Latin Extended Additional.
Declaration
public static readonly UnicodeRange[] Diacritics
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
Dingbats
Dingbats (0x2700-0x27BF): Decorative symbols and ornaments.
Declaration
public static readonly UnicodeRange Dingbats
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
End
The ending Unicode codepoint of this range (inclusive).
Declaration
public readonly int End
Field Value
| Type | Description |
|---|---|
| int |
Remarks
Combined with Start, this field defines the complete set of codepoints
covered by this range: every integer n satisfying
Start <= n <= End is included. This value is guaranteed to be
greater than or equal to Start on any instance created through the
public constructors.
FullBMP
A single range covering the entire Basic Multilingual Plane (BMP) from codepoint U+0020 to U+FFFF - approximately 65,500 codepoints.
Declaration
public static readonly UnicodeRange[] FullBMP
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
Remarks
Performance warning: Scanning the full BMP tests every codepoint in the plane against the font, which can be significantly slower than using targeted ranges such as FullSet. Avoid this array in runtime font scanning paths or any context where scan time is observable to the player. Use it only in offline tooling or one-time editor asset processing. For comprehensive coverage with a much smaller scan cost, prefer FullSet instead.
FullSet
A comprehensive character set combining all practical common ranges. The recommended starting point for games that require broad font coverage without scanning the entire BMP.
Declaration
public static readonly UnicodeRange[] FullSet
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
Remarks
This array covers Latin (Basic, Extended-A/B, and Additional), Greek, Cyrillic (with Supplement), superscripts and subscripts, number forms, general punctuation, currency symbols, arrows, mathematical operators, miscellaneous technical symbols, control pictures, box drawing, block elements, geometric shapes, miscellaneous symbols, dingbats, miscellaneous symbols and arrows, and a Powerline subset - all in targeted, non-overlapping ranges. This gives comprehensive glyph coverage for most game HUD, UI, and terminal emulation needs at a fraction of the cost of FullBMP. If a character is missing from this set, add a custom UnicodeRange for the required block directly to a new combined array rather than falling back to FullBMP.
GeneralPunctuation
General Punctuation (0x2000-0x206F): Various punctuation marks and special spaces.
Declaration
public static readonly UnicodeRange GeneralPunctuation
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
GeometricShapes
Geometric Shapes (0x25A0-0x25FF): Squares, circles, triangles, and other geometric shapes.
Declaration
public static readonly UnicodeRange GeometricShapes
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
Greek
Greek and Coptic (0x0370-0x03FF): Greek alphabet and Coptic letters.
Declaration
public static readonly UnicodeRange Greek
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
GreekSet
Greek character ranges including Greek and Coptic block.
Declaration
public static readonly UnicodeRange[] GreekSet
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
Latin1Supplement
Latin-1 Supplement (0x00A0-0x00FF): Extended Latin characters including accented letters.
Declaration
public static readonly UnicodeRange Latin1Supplement
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
LatinExtendedA
Latin Extended-A (0x0100-0x017F): Additional Latin characters for European languages.
Declaration
public static readonly UnicodeRange LatinExtendedA
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
LatinExtendedAdditional
Latin Extended Additional (0x1E00-0x1EFF): Additional accented Latin characters for Vietnamese, etc.
Declaration
public static readonly UnicodeRange LatinExtendedAdditional
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
LatinExtendedB
Latin Extended-B (0x0180-0x024F): Additional Latin characters for African and other languages.
Declaration
public static readonly UnicodeRange LatinExtendedB
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
MathematicalOperators
Mathematical Operators (0x2200-0x22FF): Mathematical symbols and operators.
Declaration
public static readonly UnicodeRange MathematicalOperators
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
MiscSymbols
Miscellaneous Symbols (0x2600-0x26FF): Various symbols including weather, chess, and card symbols.
Declaration
public static readonly UnicodeRange MiscSymbols
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
MiscSymbolsAndArrows
Miscellaneous Symbols and Arrows (0x2B00-0x2BFF): Additional arrows and symbols.
Declaration
public static readonly UnicodeRange MiscSymbolsAndArrows
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
MiscTechnical
Miscellaneous Technical (0x2300-0x23FF): Technical symbols including APL characters.
Declaration
public static readonly UnicodeRange MiscTechnical
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
Name
An optional human-readable descriptive name for this range, such as
"Basic Latin" or "Box Drawing".
Declaration
public readonly string Name
Field Value
| Type | Description |
|---|---|
| string |
Remarks
Returns null if no name was provided at construction time (i.e. when the
two-argument constructor UnicodeRange(int, int) was used). The name
is used only for display and debugging purposes - it has no effect on
Contains(int), Length, or equality comparisons.
NumberForms
Number Forms (0x2150-0x218F): Fractions and Roman numerals.
Declaration
public static readonly UnicodeRange NumberForms
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
Numbers
Number-related character ranges. Includes Basic Latin digits, superscripts, subscripts, and number forms (fractions).
Declaration
public static readonly UnicodeRange[] Numbers
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
Powerline
Powerline font symbol ranges (Private Use Area subset commonly used by Powerline fonts).
Declaration
public static readonly UnicodeRange[] Powerline
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
PrivateUseArea
Private Use Area (0xE000-0xF8FF): Private use characters including Powerline symbols.
Declaration
public static readonly UnicodeRange PrivateUseArea
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
Punctuation
Punctuation character ranges. Includes Basic Latin punctuation and General Punctuation block.
Declaration
public static readonly UnicodeRange[] Punctuation
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
Start
The starting Unicode codepoint of this range (inclusive).
Declaration
public readonly int Start
Field Value
| Type | Description |
|---|---|
| int |
Remarks
Codepoints are non-negative integers that map to characters in the Unicode standard.
For example, the codepoint for the ASCII space character is 0x0020 (32 decimal).
This value is guaranteed to be non-negative and less than or equal to End
on any instance created through the public constructors.
SuperscriptsSubscripts
Superscripts and Subscripts (0x2070-0x209F): Superscript and subscript digits and letters.
Declaration
public static readonly UnicodeRange SuperscriptsSubscripts
Field Value
| Type | Description |
|---|---|
| UnicodeRange |
Symbols
Symbol character ranges including math, arrows, geometric shapes, and misc symbols.
Declaration
public static readonly UnicodeRange[] Symbols
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
Western
Extended Western character ranges suitable for European-language UIs. Covers Basic Latin, Latin-1 Supplement, Latin Extended-A, and Latin Extended-B - approximately 600 codepoints in total.
Declaration
public static readonly UnicodeRange[] Western
Field Value
| Type | Description |
|---|---|
| UnicodeRange[] |
Remarks
Latin Extended-A and Extended-B add the accented, ligature, and modified Latin characters used by most Western and Central European languages (French, German, Spanish, Polish, Czech, Turkish, and others). Use this set in place of Common when the game must display localised text in those languages. For Vietnamese and other scripts that require additional diacritical combinations, add LatinExtendedAdditional to the array or use Diacritics.
Properties
IsValid
Returns true if this range has a non-negative start codepoint and the end
codepoint is greater than or equal to the start codepoint.
Declaration
public bool IsValid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Remarks
Any instance created through the public constructors is guaranteed to be valid,
because both constructors throw ArgumentOutOfRangeException if
either condition is violated. This property is primarily useful when deserialising
a UnicodeRange from JSON or other external sources where validation has
not yet been applied.
Length
Gets the total number of codepoints covered by this range.
Declaration
public int Length { get; }
Property Value
| Type | Description |
|---|---|
| int | The count of codepoints from Start to End, inclusive.
Computed as |
Remarks
Because both bounds are inclusive and the constructors enforce
End >= Start, this property always returns a value of at least 1 for
any valid range. A single-codepoint range (where Start equals
End) has a Length of 1.
Methods
Contains(int)
Determines whether the given Unicode codepoint falls within this range.
Declaration
public bool Contains(int codepoint)
Parameters
| Type | Name | Description |
|---|---|---|
| int | codepoint | The Unicode codepoint to test. May be any integer; negative values always return
|
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Equals(UnicodeRange)
Determines whether this UnicodeRange is equal to another UnicodeRange.
Declaration
public bool Equals(UnicodeRange other)
Parameters
| Type | Name | Description |
|---|---|---|
| UnicodeRange | other | The UnicodeRange to compare with. |
Returns
| Type | Description |
|---|---|
| bool | True if both ranges have equal start and end values. |
Equals(object)
Determines whether this UnicodeRange is equal to another object.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with. |
Returns
| Type | Description |
|---|---|
| bool | True if the object is a UnicodeRange with equal values. |
Overrides
GetHashCode()
Returns a hash code for this UnicodeRange.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code based on start and end values. |
Overrides
ToString()
Returns a string representation of this range.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string in the format "Name (U+XXXX-U+XXXX)" or "(U+XXXX-U+XXXX)" if no name. |
Overrides
Operators
operator ==(UnicodeRange, UnicodeRange)
Equality operator for two UnicodeRange values.
Declaration
public static bool operator ==(UnicodeRange left, UnicodeRange right)
Parameters
| Type | Name | Description |
|---|---|---|
| UnicodeRange | left | |
| UnicodeRange | right |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(UnicodeRange, UnicodeRange)
Inequality operator for two UnicodeRange values.
Declaration
public static bool operator !=(UnicodeRange left, UnicodeRange right)
Parameters
| Type | Name | Description |
|---|---|---|
| UnicodeRange | left | |
| UnicodeRange | right |
Returns
| Type | Description |
|---|---|
| bool |