async fn convert_manifest_v1_to_v2(
        &self,
        manifest_v1: FontsManifest,
    ) -> Result<v2::FontsManifest, Error> {
        let mut manifest_v2 = v2::FontsManifest::try_from(manifest_v1)?;
        let font_info_loader = FontInfoLoaderImpl::new()?;

        for manifest_family in &mut manifest_v2.families {
            for manifest_asset in &mut manifest_family.assets {
                for manifest_typeface in &mut manifest_asset.typefaces {
                    if manifest_typeface.code_points.is_empty() {
                        match &manifest_asset.location {
                            v2::AssetLocation::LocalFile(v2::LocalFileLocator { directory }) => {
                                let asset_path = directory.join(&manifest_asset.file_name);
                                let buffer = AssetCollection::load_asset_to_vmo(&asset_path)?;
                                let font_info = {
                                    trace::duration!("fonts", "FontInfoLoaderImpl:load_font_info");
                                    font_info_loader
                                        .load_font_info(buffer, manifest_typeface.index)?
                                };
                                manifest_typeface.code_points = font_info.char_set;
                            }
                            _ => {
                                return Err(format_err!(
                                    "Impossible asset location: {:?}",
                                    &manifest_asset
                                ));
                            }
                        }
                    }
                }
            }
        }

        Ok(manifest_v2)
    }
/// Converts data format from manifest v1 to v2 and loads character sets for any typefaces that
/// lack them.
Converts data format from manifest v1 to v2 and loads character sets for any typefaces that
lack them.
Converts data format from manifest v1 to v2 and loads character sets for any typefaces that lack them .
async fn convert_manifest_v1_to_v2(
        &self,
        manifest_v1: FontsManifest,
    ) -> Result<v2::FontsManifest, Error> {
        let mut manifest_v2 = v2::FontsManifest::try_from(manifest_v1)?;
        let font_info_loader = FontInfoLoaderImpl::new()?;
        for manifest_family in &mut manifest_v2.families {
            for manifest_asset in &mut manifest_family.assets {
                for manifest_typeface in &mut manifest_asset.typefaces {
                    if manifest_typeface.code_points.is_empty() {
                        match &manifest_asset.location {
                            v2::AssetLocation::LocalFile(v2::LocalFileLocator { directory }) => {
                                let asset_path = directory.join(&manifest_asset.file_name);
                                let buffer = AssetCollection::load_asset_to_vmo(&asset_path)?;
                                let font_info = {
                                    trace::duration!("fonts", "FontInfoLoaderImpl:load_font_info");
                                    font_info_loader
                                        .load_font_info(buffer, manifest_typeface.index)?
                                };
                                manifest_typeface.code_points = font_info.char_set;
                            }
                            _ => {
                                return Err(format_err!(
                                    "Impossible asset location: {:?}",
                                    &manifest_asset
                                ));
                            }
                        }
                    }
                }
            }
        }
        Ok(manifest_v2)
    }
async fn convert_manifest_v1_to_v2 ( & self , manifest_v1 : FontsManifest , ) -> Result < v2 :: FontsManifest , Error > { let mut manifest_v2 = v2 :: FontsManifest :: try_from ( manifest_v1 ) ? ; let font_info_loader = FontInfoLoaderImpl :: new ( ) ? ; for manifest_family in & mut manifest_v2 . families { for manifest_asset in & mut manifest_family . assets { for manifest_typeface in & mut manifest_asset . typefaces { if manifest_typeface . code_points . is_empty ( ) { match & manifest_asset . location { v2 :: AssetLocation :: LocalFile ( v2 :: LocalFileLocator { directory } ) => { let asset_path = directory . join ( & manifest_asset . file_name ) ; let buffer = AssetCollection :: load_asset_to_vmo ( & asset_path ) ? ; let font_info = { trace :: duration ! ( " " " " ) ; font_info_loader . load_font_info ( buffer , manifest_typeface . index ) ? } ; manifest_typeface . code_points = font_info . char_set ; } _ => { return Err ( format_err ! ( " " manifest_asset ) ) ; } } } } } } Ok ( manifest_v2 ) }
Converts data format from manifest v1 to v2 and loads character sets for any typefaces that
lack them.
Converts data format from manifest v1 to v2 and loads character sets for any typefaces that lack them .
&self
manifest_v1
FontsManifest
&self
manifest_v1
FontsManifest