CRichText and Custom Font
| Fri, 2006-10-06 19:22 | |
|
Hi,,
i have my custom (gdr) font, i want to set it with CRichText Editor. my font is unicode. I found 2 - 3 links but they r not much informative.... can any budy share his/her idea or code sample. Code: TInt aFileId; TFileName fileName=_L("c:\\MBSindhiWeb.gdr"); iCoeEnv->ScreenDevice()->AddFile(fileName,aFileId); CFont *iFont; CGraphicsDevice* ScreenDevice=iCoeEnv->ScreenDevice(); TFontSpec aFontSpec(fileName,100); ScreenDevice->GetNearestFontInTwips(iFont,aFontSpec); TCharFormat charFormat(aFontSpec.iTypeface.iName, aFontSpec.iHeight); now i want to use *iFont with CRichText control. regards kmsoomro |
|






Forum posts: 1156
If you use Forum Search, e.g. for "TCharFormat", you will find a lot of older threads with all kinds of useful information about fonts, characters formats and RichText.
René Brunner
Forum posts: 85
Hi
My font is like Arabic font, but has some additional character set. Editor only displays Unicode value in Arabic format which is by default supported by the emulator and it skips (not display) additional characters of my language: the conclusion that I got is: editor may not load my custom .GDR font.
Code example:
Font path:
z\system\fonts\MBSania.gdr
_LIT(KFontFileName,"MBSania.gdr");
CRichText* text = RichText();
TInt textSize = text->DocumentLength();
TCharFormatMask charFormatMask; // the attribute mask
charFormatMask.SetAttrib(EAttFontTypeface );
TFontSpec aFontSpec(KFontFileName,2);
TCharFormat charFormat(aFontSpec.iTypeface.iName, aFontSpec.iHeight);
text->ApplyCharFormatL(charFormat, charFormatMask,textSize,aText.Length());
Is there any code mistake plz guide me?
Forum posts: 1156
One way to do this: Copy the font to the device and check whether the FontViewer tool shows the font as installed:
http://newlc.com/FontViewer.html
If not then there is probably something wrong with the font itself.
Btw, I don't think your font will be a "custom" font. As far as I know Symbian treats all the .gdr font files that it finds in the font directories on the available drives in the same way. So if the font file is valid there should be no problem to use it.
I once tried to build a .gdr font file myself and found Symbian to be less than helpful: It just silently ignored the file without giving the smallest hint about what it did not like about it.
Did you consider working with TrueType fonts and a font that supports your script?
René Brunner
Forum posts: 85
Forum posts: 85
TTypefaceSupport *typeface;
TInt iFontCount = iCoeEnv->ScreenDevice()->NumTypefaces();
for( TInt i=0;i<iFontCount;i++)
{
typeface = new TTypefaceSupport;
//User::LeaveIfNull(typeface);
iCoeEnv->ScreenDevice()->TypefaceSupport(*typeface,i);
//TBuf<100> a(typeface->iTypeface.iName.Des());
RDebug::Print(_L("type face name(): %S"), &typeface->iTypeface.iName.Des());
//User::LeaveIfError(iFont.Append(typeface));
}
and i got out like this
type face name(): LatinBold17
type face name(): LatinBold19
type face name(): LatinPlain12
type face name(): Acb14
type face name(): Acb30
type face name(): Acp5
type face name(): MBSania
it shows that my MBSania font is insalled, but to display it.......
Forum posts: 1156
http://www.symbian.com/developer/downloads/syslibs.html
However, there seem to be some limits. The UIQ 2.1 emulator that I use has Freetype installed, but a version that does not work with font collections (.ttc files), only fonts (.ttf files), and it does not accept Code2000, a font with a phantastic number of scripts, as I said without telling what's the problem.
René Brunner
Forum posts: 1156
René Brunner