Easy Sinhala Text

A Flutter package for easy Sinhala text rendering with multiple font options. This package provides a simple way to display Sinhala text with proper Unicode conversion and font support.

Features

  • Easy rendering of Sinhala text with built-in fonts
  • Multiple Sinhala font options included
  • No additional configuration needed - fonts are bundled with the package
  • Simple API for text display and styling
  • Automatic Unicode conversion support

Getting Started

Add this to your package's pubspec.yaml file:

dependencies:
  easy_sinhala_text: ^0.0.1

Then run:

flutter pub get

Usage

Basic Usage

import 'package:easy_sinhala_text/easy_sinhala_text.dart';

// Basic usage with Iskoola Pota font
SinhalaText(
  'ආයුබෝවන්',
  font: SinhalaFont.iskoolaPota,
  style: TextStyle(fontSize: 24),
)

Custom Styling

// Custom style with FM Abhaya font
SinhalaText(
  'ආයුබෝවන්',
  font: SinhalaFont.fmAbhaya,
  style: TextStyle(
    fontSize: 24,
    color: Colors.blue,
    fontWeight: FontWeight.bold,
  ),
)

Paragraph Text

// Paragraph with Noto Sans Sinhala font
SinhalaText(
  'මෙය උදාහරණ පාඨයකි. මෙය තවත් පාඨයකි.',
  font: SinhalaFont.fmBindumathi,
  style: TextStyle(fontSize: 18),
)

Available Fonts

The package includes the following Sinhala fonts:

  • Iskoola Pota (SinhalaFont.iskoolaPota)
  • FM Abhaya (SinhalaFont.fmAbhaya)
  • FM Bindumathi (SinhalaFont.fmBindumathi)
  • Bhashitha Unicode (SinhalaFont.bhashithaUnicode)

Unicode Conversion

The package includes built-in Unicode conversion support:

// Convert ASCII to Sinhala Unicode
String unicodeText = SinhalaUnicodeConverter.asciiToSinhala('ayubowan');

// Convert Sinhala Unicode to ASCII
String asciiText = SinhalaUnicodeConverter.sinhalaToUnicode('ආයුබෝවන්');

Example

Here's a complete example showing different font styles and text sizes:

import 'package:easy_sinhala_text/easy_sinhala_text.dart';

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        // Example 1: Basic usage
        SinhalaText(
          'ආයුබෝවන්',
          font: SinhalaFont.iskoolaPota,
          style: TextStyle(fontSize: 24),
        ),
        
        // Example 2: Custom style
        SinhalaText(
          'ආයුබෝවන්',
          font: SinhalaFont.fmAbhaya,
          style: TextStyle(
            fontSize: 24,
            color: Colors.blue,
            fontWeight: FontWeight.bold,
          ),
        ),
        
        // Example 3: Paragraph
        SinhalaText(
          'මෙය උදාහරණ පාඨයකි. මෙය තවත් පාඨයකි.',
          font: SinhalaFont.fmBindumathi,
          style: TextStyle(fontSize: 18),
        ),
        
        // Example 4: Different sizes
        SinhalaText(
          'ආයුබෝවන්',
          font: SinhalaFont.bhashithaUnicode,
          style: TextStyle(fontSize: 32),
        ),
      ],
    );
  }
}

Additional Information

  • The package automatically handles font loading and management
  • No additional configuration is needed in your app's pubspec.yaml
  • All fonts are bundled with the package
  • The package supports both light and dark themes

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Libraries

easy_sinhala_text