Hỏi về hiển thị tiếng Việt sử dụng TrueType font (freetype.dll)

Thảo luận trong 'LẬP TRÌNH CHO DI ĐỘNG' bắt đầu bởi caoth, 20 Tháng ba 2005.

  1. caoth Thành viên

    Kính chào các bác!
    Vì em cần gấp nên mạn phép khai trương câu hỏi cho box lập trình...
    Em đã đọc và chỉnh đoạn code Editor Example ViewContainer4 để hiển thị font arial như sau:

    void CAknExEditorContainer4::SetFontL( TInt aResourceID )
    {
    // Create font
    TInt FontSize=150;
    _LIT(FontName,"arial");
    TFontSpec* fontSpec=new TFontSpec(FontName,FontSize);
    CleanupStack: PushL(fontSpec);

    TCharFormat charFormat;
    TCharFormatMask charFormatMask;
    CFont* editorFont = iCoeEnv->CreateScreenFontL(*fontSpec);
    CleanupStack: PushL(editorFont);
    charFormat.iFontSpec = editorFont->FontSpecInTwips();
    charFormatMask.SetAttrib(EAttFontTypeface);
    charFormatMask.SetAttrib(EAttFontHeight);
    // Set font to GlobalTextEditor
    iGTextEd->SelectAllL();
    iGTextEd->ApplyCharFormatL( charFormat, charFormatMask );
    iGTextEd->SetCursorPosL(0,0);
    iGTextEd->SetBackgroundColorL(KRgbSymbianOrange);
    iCoeEnv->ReleaseScreenFont( editorFont ); // Release editorFont
    CleanupStack: Pop(); // editorFont
    // Change label text.
    TBuf<KBufLength> sizeText;
    TBuf<KBufLength> formatText;
    iCoeEnv->ReadResource( formatText, R_AKNEXEDITOR_CONTAINER4_LABEL_FORMAT_PT );
    sizeText.Format( formatText, fontSpec->iHeight / KTwipsPerPoint );
    TBuf<KBufLength> labelText = fontSpec->iTypeface.iName;
    labelText.Append( sizeText );
    iLabel->SetTextL( labelText );
    iLabel->SetExtent( GTEXTED_LABEL_POS, iLabel->MinimumSize() );
    CleanupStack: Pop(); // fontSpec
    delete fontSpec; // Delete Font
    }

    em cũng chép 2 files "freetype.dll" và "arial.ttf" vào thư mục "C:\Symbian\8.0a\S60_2nd_FP2\epoc32\release\wins\udeb\z\system\Fonts\"
    tuy nhiên khi em chạy chương trình ở chế độ debug (debug WINS) khi gọi hàm font arial không được sử dụng.

    Rất mong quí anh em gần xa chỉ dẫn để sử dụng được font arial (unicode) này cho các control...
    Em xin chân thành cảm ơn!
  2. Star

    Star Thành viên

    Bài viết:
    74
    Được Like:
    19
    Bạn chép font nhầm thư mục:
    Đường dẫn phải là "C:\Symbian\8.0a\S60_2nd_FP2\epoc32\WINSCW\C\system\Fonts\"
  3. caoth

    caoth Thành viên

    Bài viết:
    22
    Được Like:
    6
    Bạn ơi, thư mục WINSCW là thư mục debug cho SYmbian UIQ, còn tôi đang làm trên Symbian s60. (Hic hic tôi xin lỗi vì không nói rõ...)
    Dù sao rất cảm ơn bạn đã trả lời!!!
    Có 1 điều thú vị là đoạn code trên khi chạy trên máy thật (N7610) thì ĐÚNG. Như vậy vấn đề trở nên đơn giản là việc cài font TrueType vào emulator. Tôi đã chép 2 files "freetype.dll" and "arial.ttf" vào "C:\Symbian\8.0a\S60_2nd_FP2\epoc32\release\wins\udeb\z\system\Fonts\" lẫn "C:\Symbian\8.0a\S60_2nd_FP2\epoc32\wins\c\System\Fonts\". Nhưng hoàn toàn không có tác dụng.

    Bạn nào quan tâm có thề dùng đoạn mã sau để kiểm tra những font hiện có trong máy:
    void CMy_ListboxContainer::ListMyFontsL()

    {

    // Find out the number of typefaces

    TInt iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();

    // Show name of each available font

    TBuf<64> myFontName;

    TBuf<128> text;

    for(TInt t = 0; t < iNumTypefaces; t++)

    {

    // Get font name

    TTypefaceSupport myTypefaceSupport;

    iCoeEnv->ScreenDevice()->TypefaceSupport(myTypefaceSupport, t);

    myFontName = myTypefaceSupport.iTypeface.iName.Des();

    _LIT(KMyText, "Font %d/%d:");

    text.Format(KMyText, t, iNumTypefaces);

    iEikonEnv->InfoWinL(text, myFontName);

    }


    }

    Có ai có ý kiến gì không ạ???