Changeset 323

Show
Ignore:
Timestamp:
02/02/07 00:39:58 (2 years ago)
Author:
dconrad
Message:

Use attached fonts in Matroska

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/MatroskaImport.h

    r265 r323  
    3636#include <matroska/KaxChapters.h> 
    3737#include <matroska/KaxBlock.h> 
     38#include <matroska/KaxAttachments.h> 
    3839 
    3940using namespace libmatroska; 
     
    156157        void ReadChapters(KaxChapters &chapterEntries); 
    157158         
     159        // Activates any attached fonts, ignores other attachment types for now 
     160        void ReadAttachments(KaxAttachments &attachments); 
     161         
    158162        // These three are called from ReadTracks to set up a track of the specific type,  
    159163        // modifying the MatroskaTrack structure to reflect the newly create track.  
  • trunk/MatroskaImportPrivate.cpp

    r316 r323  
    3939#include <matroska/KaxCluster.h> 
    4040#include <matroska/KaxBlock.h> 
     41#include <matroska/KaxAttachments.h> 
     42#include <matroska/KaxAttached.h> 
    4143 
    4244#include "MatroskaImport.h" 
     
    114116                        el_l1->Read(*aStream, KaxChapters::ClassInfos.Context, upperLevel, dummyElt, true); 
    115117                        ReadChapters(*static_cast<KaxChapters *>(el_l1)); 
     118                         
     119                } else if (EbmlId(*el_l1) == KaxAttachments::ClassInfos.GlobalId) { 
     120                        el_l1->Read(*aStream, KaxAttachments::ClassInfos.Context, upperLevel, dummyElt, true); 
     121                        ReadAttachments(*static_cast<KaxAttachments *>(el_l1)); 
    116122                         
    117123                } else if (EbmlId(*el_l1) == KaxCluster::ClassInfos.GlobalId) { 
     
    568574} 
    569575 
     576void MatroskaImport::ReadAttachments(KaxAttachments &attachments) 
     577{ 
     578        KaxAttached *attachedFile = FindChild<KaxAttached>(attachments); 
     579         
     580        while (attachedFile && attachedFile->GetSize() > 0) { 
     581                string fileMimeType = GetChild<KaxMimeType>(*attachedFile); 
     582                 
     583                if (fileMimeType == "application/x-truetype-font") { 
     584                        KaxFileData & fontData = GetChild<KaxFileData>(*attachedFile); 
     585                         
     586                        if (fontData.GetSize()) { 
     587                                ATSFontContainerRef container; 
     588                                ATSFontActivateFromMemory(fontData.GetBuffer(), fontData.GetSize(), kATSFontContextLocal,  
     589                                                          kATSFontFormatUnspecified, NULL, kATSOptionFlagsDefault, &container); 
     590                        } 
     591                } 
     592                 
     593                attachedFile = &GetNextChild<KaxAttached>(attachments, *attachedFile); 
     594        } 
     595} 
     596 
    570597void MatroskaImport::ImportCluster(KaxCluster &cluster, bool addToTrack) 
    571598{