Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Bagian ini menjelaskan cara menggunakan duplikat font untuk menerapkan sejumlah perubahan pada rentang teks, sekaligus.
Apa yang perlu Anda ketahui
Teknologi
Prasyarat
- C/C++
- Pemrograman Antarmuka Pengguna Windows
Peraturan
Menggunakan Font Duplikat
Contoh berikut menunjukkan bagaimana duplikat font dapat digunakan untuk menerapkan sejumlah perubahan pada rentang sekaligus.
void ChangeFontNameSizeBold(ITextSelection *pSel)
{
ITextFont *pFontSel = NULL
ITextFont *FontDuplicate = NULL;
// Get ITextFont version of non-duplicated font.
if (FAILED(pSel->GetFont( &pFontSel))
return;
// Duplicate the font.
pFontSel->GetValue(&pFontDuplicate);
pFontSel->Release();
if(!pFontDuplicate)
return;
// Changes here happen only to the underlying data structure,
// such as a CHARFORMAT, in the duplicate - NOT to the actual story text.
BSTR bstrTemp = UnicodeBstrFromAnsi("Times New Roman"); // Font name
pFontDuplicate->SetName(bstrTemp);
SysFreeString(bstrTemp);
pFontDuplicate->SetBold(tomTrue); // Bold
pFontDuplicate->SetSize(10.5); // 10.5 point font.
pFontDuplicate->SetAnimation(tomBlackMarchingAnts);
// Apply the change to text as one change: one screen update, one undo.
// You can also apply the font object to different ranges before you free it.
pSel->SetFont(pFontDuplicate);
pFontDuplicate->Release();
}
Topik terkait