mongol
this library is a collection of flutter widgets for displaying traditional mongolian vertical text.
vertical text
mongoltext
is a vertical text version of flutter’s text
widget. left-to-right line wrapping is supported.
mongoltext('ᠨᠢᠭᠡ ᠬᠣᠶᠠᠷ ᠭᠤᠷᠪᠠ ᠳᠦᠷᠪᠡ ᠲᠠᠪᠤ ᠵᠢᠷᠭᠤᠭᠠ ᠨᠠᠢᠮᠠ ᠶᠢᠰᠦ ᠠᠷᠪᠠ'),
the library supports mobile, web, and desktop.
emoji and cjk characters
the library rotates emoji and cjk (chinese, japanese, and korean) characters for proper orientation.
text styling
you add styling using textspan
and/or textstyle
, just as you would for a text
widget.
mongoltext.rich(
textspan,
textscalefactor: 2.5,
),
where textspan
is defined like so:
const textspan = textspan(
style: textstyle(fontsize: 30, color: colors.black),
children: [
textspan(text: 'ᠨᠢᠭᠡn', style: textstyle(fontsize: 40)),
textspan(text: 'ᠬᠣᠶᠠᠷ', style: textstyle(backgroundcolor: colors.yellow)),
textspan(
text: ' ᠭᠤᠷᠪᠠ ',
style: textstyle(shadows: [
shadow(
blurradius: 3.0,
color: colors.lightgreen,
offset: offset(3.0, -3.0),
),
]),
),
textspan(text: 'ᠳᠦᠷ'),
textspan(text: 'ᠪᠡ ᠲᠠᠪᠤ ᠵᠢᠷᠭᠤ', style: textstyle(color: colors.blue)),
textspan(text: 'ᠭᠠ ᠨᠠᠢᠮᠠ '),
textspan(text: 'ᠶᠢᠰᠦ ', style: textstyle(fontsize: 20)),
textspan(
text: 'ᠠᠷᠪᠠ',
style:
textstyle(fontfamily: 'menksoftamuguleng', color: colors.purple)),
],
);
this all assumes you’ve added one or more mongolian fonts to your app assets.
adding a mongolian font
previous versions of this library included a mongolian font. however, as of version 0.6.0, the font is removed. this allows the library to be smaller and also gives developers the freedom to choose any mongolian font they like.
since it’s likely that some of your users’ devices won’t have a mongolian font installed, you should include at least one mongolian font with your project. here is what you need to do:
1. get a font
you can find a font from the following companies:
this one from menksoft is the one that used to be included in the library.
2. add the font to your project
you can get directions to do that here and here.
basically you just need to create an assets/fonts folder for it and then declare the font in pubspec.yaml like this:
flutter:
fonts:
- family: menksoftqagan
fonts:
- asset: assets/fonts/mqg8f02.ttf
you can call the family name whatever you want, but this string is what you will use in the next step.
3. set the default mongolian font for your app
in your main.dart
file, set the fontfamily
for the app theme.
materialapp(
title: 'my app',
theme: themedata(fontfamily: 'menksoftqagan'),
home: myhomepage(),
);
now you won’t have to manually set the font for every mongolian text widget. if you want to use a different font for some widgets, though, you can still set the fontfamily
as you normally would inside textstyle
.
you may also consider using mongol_code with a menksoft font if your users have devices that don’t support opentype unicode font rendering. mongol_code
converts unicode to menksoft code, which a menksoft font can display without any special rendering requirements.
mongolalertdialog
this alert dialog works mostly the same as the flutter alertdialog
.
keyboard and vertical textfield
these are not part of mongol
library yet, but you can see an example of how to make a custom in-app keyboard and a vertical textfield
in the example app that’s included with this library. here is a screenshot from the demo app:
the text field is just a standard textfield
rotated by 90 degrees. for that reason, it only supports single line input.
todo
- multiline
mongoltextfield
class - improved keyboard
- various other text based widgets
- support
widgetspan
.
Comments are closed.