pub(crate) unsafe fn sfd_load_record(sfd_name: &str, subfont_id: &str) -> i32 {
    let mut rec_id: i32 = -1;
    if sfd_name.is_empty() || subfont_id.is_empty() {
        return -1;
    }
    let sfd_id = find_sfd_file(sfd_name);
    if sfd_id < 0 {
        return -1;
    }
    let sfd = &mut sfd_files[sfd_id as usize];
    /* Check if we already loaded mapping table. */
    let mut i = 0;
    while i < sfd.sub_id.len() && sfd.sub_id[i] != subfont_id {
        i += 1
    }
    if i == sfd.sub_id.len() {
        warn!(
            "Subfont id=\"{}\" not exist in SFD file \"{}\"...",
            subfont_id, sfd.ident,
        );
        return -1;
    } else {
        if sfd.rec_id[i] >= 0 {
            return sfd.rec_id[i];
        }
    }
    if verbose > 3 {
        info!(
            "\nsubfont>> Loading SFD mapping table for <{},{}>...",
            sfd.ident, subfont_id,
        );
    }
    /* reopen */
    let handle = InFile::open(&sfd.ident, TTInputFormat::SFD, 0);
    if handle.is_none() {
        return -1;
        /* panic!("Could not open SFD file \"{}\"", sfd_name); */
    }
    let mut handle = handle.unwrap();
    loop
    /* Seek to record for 'sub_name'. */
    {
        let mut p = readline(line_buf.as_mut_ptr(), 4096, &mut handle); /* empty line */
        if p.is_null() {
            break;
        }
        while *p as i32 != 0 && libc::isspace(*p as _) != 0 {
            p = p.offset(1)
        }
        if *p as i32 == 0 {
            continue;
        }
        /* q = parse_ident(&p, p + strlen(p)); */
        let q = p;
        while *p as i32 != 0 && libc::isspace(*p as _) == 0 {
            p = p.offset(1)
        }
        *p = '\u{0}' as i32 as i8;
        p = p.offset(1);
        if CStr::from_ptr(q).to_str().unwrap() == subfont_id {
            let mut rec = sfd_rec_::new();
            let error = read_sfd_record(&mut rec, p);
            if error != 0 {
                warn!(
                    "Error occured while reading SFD file: file=\"{}\" subfont_id=\"{}\"",
                    sfd.ident, subfont_id,
                );
            } else {
                rec_id = sfd_record.len() as i32;
                sfd_record.push(rec);
            }
        }
    }
    if rec_id < 0 {
        warn!(
            "Failed to load subfont mapping table for SFD=\"{}\" subfont_id=\"{}\"",
            sfd.ident, subfont_id,
        );
    }
    sfd.rec_id[i] = rec_id;
    if verbose > 3 {
        if rec_id >= 0 {
            info!(" at id=\"{}\"", rec_id);
            info!("\nsubfont>> Content of mapping table:");
            for i in 0..256 {
                if i % 16 == 0 {
                    info!("\nsubfont>>  ");
                }
                info!(" {:04x}", sfd_record[rec_id as usize].vector[i],);
            }
        }
        info!("\n");
    }
    rec_id
}
/* Make sure that sfd_name does not have the extension '.sfd'.
 * Mapping tables are actually read here.
 */
Make sure that sfd_name does not have the extension '.sfd'.
Mapping tables are actually read here.
Make sure that sfd_name does not have the extension ' . sfd ' . Mapping tables are actually read here .
pub(crate) unsafe fn sfd_load_record(sfd_name: &str, subfont_id: &str) -> i32 {
    let mut rec_id: i32 = -1;
    if sfd_name.is_empty() || subfont_id.is_empty() {
        return -1;
    }
    let sfd_id = find_sfd_file(sfd_name);
    if sfd_id < 0 {
        return -1;
    }
    let sfd = &mut sfd_files[sfd_id as usize];
    /* Check if we already loaded mapping table. */
    let mut i = 0;
    while i < sfd.sub_id.len() && sfd.sub_id[i] != subfont_id {
        i += 1
    }
    if i == sfd.sub_id.len() {
        warn!(
            "Subfont id=\"{}\" not exist in SFD file \"{}\"...",
            subfont_id, sfd.ident,
        );
        return -1;
    } else {
        if sfd.rec_id[i] >= 0 {
            return sfd.rec_id[i];
        }
    }
    if verbose > 3 {
        info!(
            "\nsubfont>> Loading SFD mapping table for <{},{}>...",
            sfd.ident, subfont_id,
        );
    }
    /* reopen */
    let handle = InFile::open(&sfd.ident, TTInputFormat::SFD, 0);
    if handle.is_none() {
        return -1;
        /* panic!("Could not open SFD file \"{}\"", sfd_name); */
    }
    let mut handle = handle.unwrap();
    loop
    /* Seek to record for 'sub_name'. */
    {
        let mut p = readline(line_buf.as_mut_ptr(), 4096, &mut handle); /* empty line */
        if p.is_null() {
            break;
        }
        while *p as i32 != 0 && libc::isspace(*p as _) != 0 {
            p = p.offset(1)
        }
        if *p as i32 == 0 {
            continue;
        }
        /* q = parse_ident(&p, p + strlen(p)); */
        let q = p;
        while *p as i32 != 0 && libc::isspace(*p as _) == 0 {
            p = p.offset(1)
        }
        *p = '\u{0}' as i32 as i8;
        p = p.offset(1);
        if CStr::from_ptr(q).to_str().unwrap() == subfont_id {
            let mut rec = sfd_rec_::new();
            let error = read_sfd_record(&mut rec, p);
            if error != 0 {
                warn!(
                    "Error occured while reading SFD file: file=\"{}\" subfont_id=\"{}\"",
                    sfd.ident, subfont_id,
                );
            } else {
                rec_id = sfd_record.len() as i32;
                sfd_record.push(rec);
            }
        }
    }
    if rec_id < 0 {
        warn!(
            "Failed to load subfont mapping table for SFD=\"{}\" subfont_id=\"{}\"",
            sfd.ident, subfont_id,
        );
    }
    sfd.rec_id[i] = rec_id;
    if verbose > 3 {
        if rec_id >= 0 {
            info!(" at id=\"{}\"", rec_id);
            info!("\nsubfont>> Content of mapping table:");
            for i in 0..256 {
                if i % 16 == 0 {
                    info!("\nsubfont>>  ");
                }
                info!(" {:04x}", sfd_record[rec_id as usize].vector[i],);
            }
        }
        info!("\n");
    }
    rec_id
}
pub ( crate ) unsafe fn sfd_load_record ( sfd_name : & str , subfont_id : & str ) -> i32 { let mut rec_id : i32 = - 1 ; if sfd_name . is_empty ( ) || subfont_id . is_empty ( ) { return - 1 ; } let sfd_id = find_sfd_file ( sfd_name ) ; if sfd_id < 0 { return - 1 ; } let sfd = & mut sfd_files [ sfd_id as usize ] ; /* Check if we already loaded mapping table. */ let mut i = 0 ; while i < sfd . sub_id . len ( ) && sfd . sub_id [ i ] != subfont_id { i += 1 } if i == sfd . sub_id . len ( ) { warn ! ( " \" \" \" \" " subfont_id sfd ident ) ; return - 1 ; } else { if sfd . rec_id [ i ] >= 0 { return sfd . rec_id [ i ] ; } } if verbose > 3 { info ! ( " \n " sfd ident subfont_id ) ; } /* reopen */ let handle = InFile :: open ( & sfd . ident , TTInputFormat :: SFD , 0 ) ; if handle . is_none ( ) { return - 1 ; /* panic!("Could not open SFD file \"{}\"", sfd_name); */ } let mut handle = handle . unwrap ( ) ; loop /* Seek to record for 'sub_name'. */ { let mut p = readline ( line_buf . as_mut_ptr ( ) , 4096 , & mut handle ) ; /* empty line */ if p . is_null ( ) { break ; } while * p as i32 != 0 && libc :: isspace ( * p as _ ) != 0 { p = p . offset ( 1 ) } if * p as i32 == 0 { continue ; } /* q = parse_ident(&p, p + strlen(p)); */ let q = p ; while * p as i32 != 0 && libc :: isspace ( * p as _ ) == 0 { p = p . offset ( 1 ) } * p = '\u{0}' as i32 as i8 ; p = p . offset ( 1 ) ; if CStr :: from_ptr ( q ) . to_str ( ) . unwrap ( ) == subfont_id { let mut rec = sfd_rec_ :: new ( ) ; let error = read_sfd_record ( & mut rec , p ) ; if error != 0 { warn ! ( " \" \" \" \" " sfd ident subfont_id ) ; } else { rec_id = sfd_record . len ( ) as i32 ; sfd_record . push ( rec ) ; } } } if rec_id < 0 { warn ! ( " \" \" \" \" " sfd ident subfont_id ) ; } sfd . rec_id [ i ] = rec_id ; if verbose > 3 { if rec_id >= 0 { info ! ( " \" \" " rec_id ) ; info ! ( " \n " ) ; for i in 0 .. 256 { if i % 16 == 0 { info ! ( " \n " ) ; } info ! ( " " sfd_record [ rec_id as usize ] vector [ i ] ) ; } } info ! ( " \n " ) ; } rec_id }
Make sure that sfd_name does not have the extension '.sfd'.
Make sure that sfd_name does not have the extension ' . sfd ' .
sfd_name
&str
subfont_id
&str