Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:Text movie bug



Now i have a question about text track movie. I make a slideshow
include text media, but if the text described in Japanese,it will not show
rightly. I want to know how make a movie that can show text in Japanese
correctly. I use quicktime api TextMediaAddSample to add text sample into
the media .In that api ,there is a parameter to set font.Under Japan
language environment ,I set Japanese text font into the api, as well as the
Osaka font, but the movie show mess code when played with Quicktime Player.
I sincerely wish someone can give me some suggestion about how to
show Japanese in a movie.

There are 2 ways to do it. If you have the text in UTF-16 format, and you're using QT 6.4 or later you can do this:


// if we're in QT 6.4 or higher, let it know that the upcoming text sample is
// encoded in UTF-16 with a byte order mark
if ((err == noErr) && (mQTVersion >= kVers_QT6_4)) {
SInt32* data = (SInt32*)NewPtrClear (sizeof (SInt32));
if (data != NULL) {
*data = 256L;
err = TextMediaSetTextSampleData (textMediaHandler, data, 'encd');

DisposePtr ((Ptr)data);
}
}


// Add the text to the text track!
err = TextMediaAddTextSample (textMediaHandler, (char*)theText, ... other params here...);


The above assumes that theText is a pointer to a buffer of UTF-16 encoded characters.

You can also set the language of the text track to the proper setting to get the correct results like this:

// Get the preferred language from the QT Prefs. You can also set it to a specific value
// if you need it to be something specific.
LangCode code = langEnglish;
QTAtomContainer prefs = NULL;
OSErr err = ::GetQuickTimePreference (FOUR_CHAR_CODE ('lang'), &prefs);
ThrowIfOSErr_ (err);


QTAtom	prefsAtom	= NULL;
prefsAtom = ::QTFindChildByID (prefs, kParentAtomIsContainer,
	FOUR_CHAR_CODE ('lang'), 1, nil);
ThrowIfNULL_ (prefsAtom);

err = ::QTCopyAtomDataToPtr (prefs, prefsAtom, false, sizeof (LangCode),
	(void*)&code, nil);
ThrowIfOSErr_ (err);

// Set the language of the text track's media to the desired value
::SetMediaLanguage (textMedia, code);

Darrin

_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.