UNICODE_FONT_FIX_GUIDE.md 3.1 KB

Solving Unicode Character Warning for Crossed Swords Symbol (⚔)

Problem

The character with Unicode value \u2694 (crossed swords ⚔) was not found in the [LiberationSans SDF] font asset, causing it to be replaced with a square placeholder (□).

Solution Options

Option 1: Add Fallback Font (Recommended)

  1. Download a Unicode Symbol Font:

    • Use Noto Color Emoji font from Google Fonts
    • Use Segoe UI Symbol (Windows system font)
    • Use Arial Unicode MS
  2. Import Font into Unity:

    • Place font file in Assets/Fonts/ directory
    • Select the font in Project window
    • In Inspector, set Font Size: 512, Sampling Point Size: Auto, Padding: 5
    • Click "Generate Font Atlas"
  3. Set up Fallback Font:

    • Open Window → TextMeshPro → Font Asset Creator
    • Create a new TMP font asset from your symbol font
    • Include Unicode range: 0x2600-0x26FF (Miscellaneous Symbols)
    • Generate the font atlas
  4. Configure Fallback in TMP Settings:

    • Go to Edit → Project Settings → TextMeshPro → Settings
    • In "Fallback Font Assets" list, add your new symbol font
    • OR directly assign to specific text components

Option 2: Use Alternative Characters

Replace the crossed swords symbol with text alternatives:

  • "⚔" → "X" or "VS" or "v"
  • "⚔" → "[COMBAT]" or "BATTLE"
  • Use TextMeshPro rich text: <sprite name="sword"> if you have sprite assets

Option 3: Create Custom Font Atlas

  1. Use FontForge or similar tool to add the missing character to LiberationSans
  2. Or create a comprehensive font that includes all needed symbols

Option 4: Use Sprite Assets Instead

  1. Create a sprite image of crossed swords
  2. Import as TMP Sprite Asset
  3. Use <sprite="crossed_swords"> in text instead of Unicode character

Implementation Steps for Option 1:

Step 1: Download Noto Emoji Font

# Download from Google Fonts or use system fonts
# Windows: C:\Windows\Fonts\seguisym.ttf (Segoe UI Symbol)

Step 2: Create TMP Font Asset

  1. Window → TextMeshPro → Font Asset Creator
  2. Source Font File: Select your symbol font
  3. Sampling Point Size: Auto Sizing
  4. Character Set: Unicode Range
  5. Character Sequence (Hex): 2600-26FF
  6. Render Mode: SDFAA
  7. Generate Font Atlas

Step 3: Configure Fallback

Add to TMP Settings or assign directly to text components that need symbols.

Quick Fix for Development

If you want a quick temporary fix, you can replace the character in your code:

// Replace crossed swords with alternative
string text = originalText.Replace("⚔", "[X]");
// or
string text = originalText.Replace("\u2694", "VS");

Finding the Source

To find where this character is being used, search your project for:

  • "⚔" (the actual character)
  • "\u2694" (Unicode escape)
  • Any text files or scripts that might be setting this character

The warning indicates it's in a text object named "Title", so check:

  • UI elements named "Title"
  • TextMeshPro components in your scenes
  • Dynamic text setting in scripts

This should resolve the Unicode character warning and properly display symbols in your game.