Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use font-kit to implement XeTeXFontInst #188

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1054902
Revert "Use freetype APIs from dependency crates as much as possible."
cormacrelf Nov 18, 2019
fc3f63e
Clean up c2rust font manager/info
cormacrelf Nov 18, 2019
42c3505
XeTexFont -> PlatformFontRef; xetex_layout_interface moved into xetex…
cormacrelf Nov 18, 2019
878e36e
Fiddle with the translated C++ constructors
cormacrelf Nov 13, 2019
a993157
Begin using font-kit, first for replacing freetype-rs (fixes #141)
cormacrelf Nov 18, 2019
a148fbc
Attempt to get some glygh bbox using font-kit
cormacrelf Nov 18, 2019
d2836ef
be explicit about read vs read_exact on InputHandle and ttstub_*
cormacrelf Nov 14, 2019
8b7216a
check errors in the Read implementation !!!
cormacrelf Nov 18, 2019
3fa8831
XeTeXFontInst backing with Vecs & read_to_end
cormacrelf Nov 14, 2019
1070c1c
Replace a lot of freetype imports
cormacrelf Nov 18, 2019
d479de8
make it build on linux again
cormacrelf Nov 14, 2019
a4a7464
No need to check ttstub's result in Seek
cormacrelf Nov 14, 2019
2851bfb
Remove more freetype, core text, definitions; remove extern "C" from …
cormacrelf Nov 18, 2019
c59e792
Remove extern "C" from the bridge API, because of ffi-safety warnings
cormacrelf Nov 14, 2019
b67014b
Misc added documentation notes & some renaming of french variable names
cormacrelf Nov 14, 2019
f1932b3
replace FT_MAKE_TAG macro expansions with a const fn
cormacrelf Nov 14, 2019
82ece06
refactor packed font name splitting
cormacrelf Nov 14, 2019
50e1a89
Change some font pathnames to use CStr
cormacrelf Nov 14, 2019
37b02e2
remove all FreeType definitions from xetex_layout_engine.rs
cormacrelf Nov 14, 2019
ef95793
Fix overloading of PlatformFontRef as *mut XeTeXFontInst
cormacrelf Nov 16, 2019
f948e4d
Remove useless get/setReqEngine static
cormacrelf Nov 16, 2019
e1d8884
'reqEngine' turned into an enum ShaperRequest
cormacrelf Nov 16, 2019
601fba1
Handle shaper list creation in its own struct
cormacrelf Nov 16, 2019
a4dd4b7
Fix a missing AAt/0xffffu32 match in xetex_ext
cormacrelf Nov 16, 2019
abad6ea
Allocate XeTeXLayoutEngine_rec with Box
cormacrelf Nov 16, 2019
0910dc8
TextLayoutEngine trait + impl for XetexLayoutEngine
cormacrelf Nov 16, 2019
be9be65
Remove last bits of freetype importing
cormacrelf Nov 18, 2019
a9fbc99
Implement TextLayoutEngine for aat as well
cormacrelf Nov 18, 2019
9dd0297
rename font_area and font_layout_engine for refactoring
cormacrelf Nov 18, 2019
a823c83
Use enum_dispatch for TextLayoutEngine
cormacrelf Nov 18, 2019
19d5721
WIP: converted a lot of FONT_AREA shenanigans into enum-dispatched- T…
cormacrelf Nov 18, 2019
0a48579
Down to 77 errors
cormacrelf Nov 18, 2019
021577f
.. 59 errors
cormacrelf Nov 18, 2019
c89962b
Down to 5
cormacrelf Nov 18, 2019
cf9ad2c
And now borrowck
cormacrelf Nov 18, 2019
f9bf7cf
Compiles
cormacrelf Nov 23, 2019
0e16656
Fix remaining font_area linking
cormacrelf Nov 23, 2019
02b0a42
Revert dump change
cormacrelf Nov 23, 2019
28443eb
Prevent recursive borrowing with measure_native_node
cormacrelf Nov 23, 2019
c065e17
Correct the isOpenTypeMathFont translations
cormacrelf Nov 23, 2019
e3f3dd7
Fix linux build
cormacrelf Nov 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
915 changes: 561 additions & 354 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ cc = "^1.0"

[dependencies]
libc = "0.2"
anyhow = "1.0.19"
88 changes: 67 additions & 21 deletions bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
unused_mut
)]

use std::io::{prelude::*, Result};
use std::io::{self, prelude::*, Result, ErrorKind};
use std::io::SeekFrom;
use std::ptr::NonNull;

Expand Down Expand Up @@ -52,12 +52,29 @@ impl Write for OutputHandleWrapper {
}

#[derive(Clone, PartialEq)]
#[repr(transparent)]
pub struct InputHandleWrapper(pub NonNull<libc::c_void>);

impl Read for InputHandleWrapper {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
unsafe {
Ok(ttstub_input_read(self.0.as_ptr(), buf.as_mut_ptr() as *mut i8, buf.len() as u64) as usize)
let read_isize = ttstub_input_read(self.0.as_ptr(), buf.as_mut_ptr() as *mut i8, buf.len() as u64);
if read_isize < 0 {
Err(io::Error::new(ErrorKind::Other, anyhow::anyhow!("Unknown -1 error code from across the bridge while reading input handle")))
} else {
Ok(read_isize as usize)
}
}
}

fn read_exact(&mut self, buf: &mut [u8]) -> Result<()> {
unsafe {
let read_isize = ttstub_input_read_exact(self.0.as_ptr(), buf.as_mut_ptr() as *mut i8, buf.len() as u64);
if read_isize < 0 {
Err(io::Error::new(ErrorKind::Other, anyhow::anyhow!("Unknown -1 error code from across the bridge while reading input handle (with read_exact)")))
} else {
Ok(())
}
}
}
}
Expand All @@ -71,7 +88,8 @@ impl Seek for InputHandleWrapper {
SeekFrom::End(o) => (o as ssize_t, SEEK_END),
};
unsafe {
Ok(ttstub_input_seek(self.0.as_ptr(), offset, whence) as u64)
let sought = ttstub_input_seek(self.0.as_ptr(), offset, whence);
Ok(sought as u64)
}
}
}
Expand All @@ -86,46 +104,46 @@ impl InputHandleWrapper {
#[repr(C)]
pub struct tt_bridge_api_t {
pub context: *mut libc::c_void,
pub issue_warning: Option<unsafe extern "C" fn(_: *mut libc::c_void, _: *const i8) -> ()>,
pub issue_error: Option<unsafe extern "C" fn(_: *mut libc::c_void, _: *const i8) -> ()>,
pub issue_warning: Option<unsafe fn(_: *mut libc::c_void, _: *const i8) -> ()>,
pub issue_error: Option<unsafe fn(_: *mut libc::c_void, _: *const i8) -> ()>,
pub get_file_md5:
Option<unsafe extern "C" fn(_: *mut libc::c_void, _: *const i8, _: *mut i8) -> i32>,
Option<unsafe fn(_: *mut libc::c_void, _: *const i8, _: *mut i8) -> i32>,
pub get_data_md5: Option<
unsafe extern "C" fn(_: *mut libc::c_void, _: *const i8, _: size_t, _: *mut i8) -> i32,
unsafe fn(_: *mut libc::c_void, _: *const i8, _: size_t, _: *mut i8) -> i32,
>,
pub output_open: Option<
unsafe extern "C" fn(_: *mut libc::c_void, _: *const i8, _: i32) -> rust_output_handle_t,
unsafe fn(_: *mut libc::c_void, _: *const i8, _: i32) -> rust_output_handle_t,
>,
pub output_open_stdout:
Option<unsafe extern "C" fn(_: *mut libc::c_void) -> rust_output_handle_t>,
Option<unsafe fn(_: *mut libc::c_void) -> rust_output_handle_t>,
pub output_putc:
Option<unsafe extern "C" fn(_: *mut libc::c_void, _: rust_output_handle_t, _: i32) -> i32>,
Option<unsafe fn(_: *mut libc::c_void, _: rust_output_handle_t, _: i32) -> i32>,
pub output_write: Option<
unsafe extern "C" fn(
unsafe fn(
_: *mut libc::c_void,
_: rust_output_handle_t,
_: *const i8,
_: size_t,
) -> size_t,
>,
pub output_flush:
Option<unsafe extern "C" fn(_: *mut libc::c_void, _: rust_output_handle_t) -> i32>,
Option<unsafe fn(_: *mut libc::c_void, _: rust_output_handle_t) -> i32>,
pub output_close:
Option<unsafe extern "C" fn(_: *mut libc::c_void, _: rust_output_handle_t) -> i32>,
Option<unsafe fn(_: *mut libc::c_void, _: rust_output_handle_t) -> i32>,
pub input_open: Option<
unsafe extern "C" fn(
unsafe fn(
_: *mut libc::c_void,
_: *const i8,
_: TTInputFormat,
_: i32,
) -> rust_input_handle_t,
>,
pub input_open_primary:
Option<unsafe extern "C" fn(_: *mut libc::c_void) -> rust_input_handle_t>,
Option<unsafe fn(_: *mut libc::c_void) -> rust_input_handle_t>,
pub input_get_size:
Option<unsafe extern "C" fn(_: *mut libc::c_void, _: rust_input_handle_t) -> size_t>,
Option<unsafe fn(_: *mut libc::c_void, _: rust_input_handle_t) -> size_t>,
pub input_seek: Option<
unsafe extern "C" fn(
unsafe fn(
_: *mut libc::c_void,
_: rust_input_handle_t,
_: ssize_t,
Expand All @@ -134,19 +152,27 @@ pub struct tt_bridge_api_t {
) -> size_t,
>,
pub input_read: Option<
unsafe extern "C" fn(
unsafe fn(
_: *mut libc::c_void,
_: rust_input_handle_t,
_: *mut i8,
_: size_t,
) -> ssize_t,
>,
pub input_read_exact: Option<
unsafe fn(
_: *mut libc::c_void,
_: rust_input_handle_t,
_: *mut i8,
_: size_t,
) -> ssize_t,
>,
pub input_getc:
Option<unsafe extern "C" fn(_: *mut libc::c_void, _: rust_input_handle_t) -> i32>,
Option<unsafe fn(_: *mut libc::c_void, _: rust_input_handle_t) -> i32>,
pub input_ungetc:
Option<unsafe extern "C" fn(_: *mut libc::c_void, _: rust_input_handle_t, _: i32) -> i32>,
Option<unsafe fn(_: *mut libc::c_void, _: rust_input_handle_t, _: i32) -> i32>,
pub input_close:
Option<unsafe extern "C" fn(_: *mut libc::c_void, _: rust_input_handle_t) -> i32>,
Option<unsafe fn(_: *mut libc::c_void, _: rust_input_handle_t) -> i32>,
}

#[repr(C)]
Expand All @@ -161,8 +187,11 @@ pub enum TTHistory {
#[repr(C)]
#[derive(Clone, Copy, PartialEq)]
pub enum TTInputFormat {
/// TeX Font Metric
TFM = 3,
/// Adobe Font Metric
AFM = 4,
/// BibTeX
BIB = 6,
BST = 7,
CNF = 8,
Expand Down Expand Up @@ -371,6 +400,7 @@ pub unsafe extern "C" fn ttstub_input_seek(
}
rv
}

#[no_mangle]
pub unsafe extern "C" fn ttstub_input_read(
mut handle: rust_input_handle_t,
Expand All @@ -383,18 +413,34 @@ pub unsafe extern "C" fn ttstub_input_read(
(*tectonic_global_bridge).context, handle, data, len
)
}

#[no_mangle]
pub unsafe extern "C" fn ttstub_input_read_exact(
mut handle: rust_input_handle_t,
mut data: *mut i8,
mut len: size_t,
) -> ssize_t {
(*tectonic_global_bridge)
.input_read_exact
.expect("non-null function pointer")(
(*tectonic_global_bridge).context, handle, data, len
)
}

#[no_mangle]
pub unsafe extern "C" fn ttstub_input_getc(handle: &mut InputHandleWrapper) -> i32 {
(*tectonic_global_bridge)
.input_getc
.expect("non-null function pointer")((*tectonic_global_bridge).context, handle.0.as_ptr())
}

#[no_mangle]
pub unsafe extern "C" fn ttstub_input_ungetc(handle: &mut InputHandleWrapper, mut ch: i32) -> i32 {
(*tectonic_global_bridge)
.input_ungetc
.expect("non-null function pointer")((*tectonic_global_bridge).context, handle.0.as_ptr(), ch)
}

#[no_mangle]
pub unsafe extern "C" fn ttstub_input_close(mut handle: InputHandleWrapper) -> i32 {
if (*tectonic_global_bridge)
Expand Down
16 changes: 8 additions & 8 deletions dpx/src/dpx_bmpimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::dpx_pdfobj::{
pdf_stream_set_predictor, STREAM_COMPRESS,
};
use crate::warn;
use crate::{ttstub_input_read};
use crate::{ttstub_input_read_exact};
use libc::{free, memset};

use std::io::{Seek, SeekFrom};
Expand All @@ -63,7 +63,7 @@ pub struct hdr_info {
pub unsafe extern "C" fn check_for_bmp(handle: &mut InputHandleWrapper) -> i32 {
let mut sigbytes: [u8; 2] = [0; 2];
handle.seek(SeekFrom::Start(0)).unwrap();
if ttstub_input_read(
if ttstub_input_read_exact(
handle.0.as_ptr(),
sigbytes.as_mut_ptr() as *mut i8,
::std::mem::size_of::<[u8; 2]>() as u64,
Expand Down Expand Up @@ -192,7 +192,7 @@ pub unsafe extern "C" fn bmp_include_image(
let palette = new(((num_palette * 3i32 + 1i32) as u32 as u64)
.wrapping_mul(::std::mem::size_of::<u8>() as u64) as u32) as *mut u8;
for i in 0..num_palette {
if ttstub_input_read(handle.0.as_ptr(), bgrq.as_mut_ptr() as *mut i8, hdr.psize as size_t)
if ttstub_input_read_exact(handle.0.as_ptr(), bgrq.as_mut_ptr() as *mut i8, hdr.psize as size_t)
!= hdr.psize as i64
{
warn!("Reading file failed...");
Expand Down Expand Up @@ -235,7 +235,7 @@ pub unsafe extern "C" fn bmp_include_image(
let mut n = 0i32;
while n < info.height {
let p = stream_data_ptr.offset((n * rowbytes) as isize);
if ttstub_input_read(handle.0.as_ptr(), p as *mut i8, dib_rowbytes as size_t)
if ttstub_input_read_exact(handle.0.as_ptr(), p as *mut i8, dib_rowbytes as size_t)
!= dib_rowbytes as i64
{
warn!("Reading BMP raster data failed...");
Expand Down Expand Up @@ -316,7 +316,7 @@ use crate::FromLEByteSlice;
unsafe fn read_header(handle: &mut InputHandleWrapper, hdr: &mut hdr_info) -> i32 {
let mut buf: [u8; 142] = [0; 142];
let p = &mut buf;
if ttstub_input_read(handle.0.as_ptr(), p.as_mut_ptr() as *mut i8, (14i32 + 4i32) as size_t)
if ttstub_input_read_exact(handle.0.as_ptr(), p.as_mut_ptr() as *mut i8, (14i32 + 4i32) as size_t)
!= (14i32 + 4i32) as i64
{
warn!("Could not read BMP file header...");
Expand All @@ -339,7 +339,7 @@ unsafe fn read_header(handle: &mut InputHandleWrapper, hdr: &mut hdr_info) -> i3
/* info header */
hdr.hsize = u32::from_le_byte_slice(&p[..4]); /* undefined. FIXME */
let p = &mut p[4..]; /* undefined. FIXME */
if ttstub_input_read(
if ttstub_input_read_exact(
handle.0.as_ptr(),
p.as_mut_ptr() as *mut i8,
hdr.hsize.wrapping_sub(4_u32) as size_t,
Expand Down Expand Up @@ -439,7 +439,7 @@ unsafe fn read_raster_rle8(
warn!("RLE decode failed...");
return -1i32;
}
if ttstub_input_read(handle.0.as_ptr(), p as *mut i8, b1 as size_t) != b1 as i64 {
if ttstub_input_read_exact(handle.0.as_ptr(), p as *mut i8, b1 as size_t) != b1 as i64 {
return -1i32;
}
count += b1 as i32;
Expand Down Expand Up @@ -534,7 +534,7 @@ unsafe fn read_raster_rle4(
*fresh0 = (*fresh0 as i32 | b as i32 >> 4i32 & 0xfi32) as u8;
*p = ((b as i32) << 4i32 & 0xf0i32) as u8;
}
} else if ttstub_input_read(handle.0.as_ptr(), p as *mut i8, nbytes as size_t)
} else if ttstub_input_read_exact(handle.0.as_ptr(), p as *mut i8, nbytes as size_t)
!= nbytes as i64
{
return -1i32;
Expand Down
8 changes: 4 additions & 4 deletions dpx/src/dpx_cff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::warn;
use super::dpx_cff_dict::{cff_dict_get, cff_dict_known, cff_dict_unpack, cff_release_dict};
use super::dpx_mem::{new, renew};
use super::dpx_numbers::{tt_get_unsigned_byte, tt_get_unsigned_pair};
use crate::{ttstub_input_read};
use crate::{ttstub_input_read_exact};
use libc::{free, memcmp, memcpy, memmove, memset, strlen};

use std::io::{Seek, SeekFrom};
Expand Down Expand Up @@ -1041,7 +1041,7 @@ pub unsafe extern "C" fn cff_get_index(cff: &mut cff_font) -> *mut cff_index {
as *mut u8;
let mut offset = 0;
while length > 0i32 {
let nb_read = ttstub_input_read(
let nb_read = ttstub_input_read_exact(
handle.0.as_ptr(),
((*idx).data as *mut i8).offset(offset as isize),
length as size_t,
Expand Down Expand Up @@ -2277,7 +2277,7 @@ pub unsafe extern "C" fn cff_read_private(cff: &mut cff_font) -> i32 {
let data = new(
(size as u32 as u64).wrapping_mul(::std::mem::size_of::<u8>() as u64) as u32,
) as *mut u8;
if ttstub_input_read(handle.0.as_ptr(), data as *mut i8, size as size_t) != size as i64 {
if ttstub_input_read_exact(handle.0.as_ptr(), data as *mut i8, size as size_t) != size as i64 {
panic!("reading file failed");
}
let ref mut fresh53 = *cff.private.offset(i as isize);
Expand Down Expand Up @@ -2305,7 +2305,7 @@ pub unsafe extern "C" fn cff_read_private(cff: &mut cff_font) -> i32 {
let data =
new((size as u32 as u64).wrapping_mul(::std::mem::size_of::<u8>() as u64) as u32)
as *mut u8;
if ttstub_input_read(handle.0.as_ptr(), data as *mut i8, size as size_t) != size as i64 {
if ttstub_input_read_exact(handle.0.as_ptr(), data as *mut i8, size as size_t) != size as i64 {
panic!("reading file failed");
}
let ref mut fresh55 = *cff.private.offset(0);
Expand Down
6 changes: 3 additions & 3 deletions dpx/src/dpx_cidtype0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ use crate::dpx_pdfobj::{
};
use crate::dpx_truetype::sfnt_table_info;
use crate::shims::sprintf;
use crate::{ttstub_input_read};
use crate::{ttstub_input_read_exact};
use libc::{free, memmove, memset, strcat, strcmp, strcpy, strlen, strstr};

use std::io::{Seek, SeekFrom};
Expand Down Expand Up @@ -849,7 +849,7 @@ pub unsafe extern "C" fn CIDFont_type0_dofont(mut font: *mut CIDFont) {
*(*charstrings).offset.offset(gid as isize) = (charstring_len + 1i32) as l_offset;
let handle = cffont.handle.as_mut().unwrap();
handle.seek(SeekFrom::Start(offset as u64 + *(*idx).offset.offset(gid_org as isize) as u64 - 1)).unwrap();
ttstub_input_read(handle.0.as_ptr(), data as *mut i8, size as size_t);
ttstub_input_read_exact(handle.0.as_ptr(), data as *mut i8, size as size_t);
let fd = cff_fdselect_lookup(cffont, gid_org) as i32;
charstring_len += cs_copy_charstring(
(*charstrings).data.offset(charstring_len as isize),
Expand Down Expand Up @@ -1395,7 +1395,7 @@ pub unsafe extern "C" fn CIDFont_type0_t1cdofont(mut font: *mut CIDFont) {
*(*charstrings).offset.offset(gid as isize) = (charstring_len + 1i32) as l_offset;
let handle = cffont.handle.as_mut().unwrap();
handle.seek(SeekFrom::Start(offset as u64 + *(*idx).offset.offset(cid as isize) as u64 - 1 )).unwrap();
ttstub_input_read(handle.0.as_ptr(), data as *mut i8, size as size_t);
ttstub_input_read_exact(handle.0.as_ptr(), data as *mut i8, size as size_t);
charstring_len += cs_copy_charstring(
(*charstrings).data.offset(charstring_len as isize),
max_len - charstring_len,
Expand Down
6 changes: 3 additions & 3 deletions dpx/src/dpx_cmap_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use super::dpx_pst_obj::pst_obj;
use super::dpx_pst_obj::{
pst_data_ptr, pst_getIV, pst_getSV, pst_length_of, pst_release_obj, pst_type_of,
};
use crate::{ttstub_input_get_size, ttstub_input_read};
use crate::{ttstub_input_get_size, ttstub_input_read_exact};
use libc::{free, memcmp, memcpy, memmove, strcmp, strlen, strstr};

pub type __ssize_t = i64;
Expand Down Expand Up @@ -122,7 +122,7 @@ unsafe fn ifreader_read(mut reader: *mut ifreader, mut size: size_t) -> size_t {
);
(*reader).cursor = (*reader).buf;
(*reader).endptr = (*reader).buf.offset(bytesrem as isize);
if ttstub_input_read((*reader).handle.0.as_ptr(), (*reader).endptr as *mut i8, bytesread) as u64
if ttstub_input_read_exact((*reader).handle.0.as_ptr(), (*reader).endptr as *mut i8, bytesread) as u64
!= bytesread
{
panic!("Reading file failed.");
Expand Down Expand Up @@ -680,7 +680,7 @@ pub unsafe extern "C" fn CMap_parse_check_sig(handle: Option<&mut InputHandleWra
}
let mut handle = handle.unwrap();
handle.seek(SeekFrom::Start(0)).unwrap();
if ttstub_input_read(handle.0.as_ptr(), sig.as_mut_ptr(), 64i32 as size_t) != 64i32 as i64 {
if ttstub_input_read_exact(handle.0.as_ptr(), sig.as_mut_ptr(), 64i32 as size_t) != 64i32 as i64 {
result = -1i32
} else {
sig[64] = 0_i8;
Expand Down
8 changes: 4 additions & 4 deletions dpx/src/dpx_dvi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ use crate::specials::{
};
use crate::{
ttstub_input_close, ttstub_input_get_size, ttstub_input_getc, ttstub_input_open,
ttstub_input_read, ttstub_input_ungetc,
ttstub_input_read_exact, ttstub_input_ungetc,
};
use crate::dpx_dvicodes::*;

Expand Down Expand Up @@ -537,14 +537,14 @@ unsafe fn read_font_record(mut tex_id: u32) {
let directory = new(
((dir_length + 1i32) as u32 as u64).wrapping_mul(::std::mem::size_of::<i8>() as u64) as u32
) as *mut i8;
if ttstub_input_read(handle.0.as_ptr(), directory, dir_length as size_t) != dir_length as i64 {
if ttstub_input_read_exact(handle.0.as_ptr(), directory, dir_length as size_t) != dir_length as i64 {
panic!(invalid_signature);
}
*directory.offset(dir_length as isize) = '\u{0}' as i32 as i8;
free(directory as *mut libc::c_void);
let font_name = new(((name_length + 1i32) as u32 as u64)
.wrapping_mul(::std::mem::size_of::<i8>() as u64) as u32) as *mut i8;
if ttstub_input_read(handle.0.as_ptr(), font_name, name_length as size_t) != name_length as i64 {
if ttstub_input_read_exact(handle.0.as_ptr(), font_name, name_length as size_t) != name_length as i64 {
panic!(invalid_signature);
}
*font_name.offset(name_length as isize) = '\u{0}' as i32 as i8;
Expand Down Expand Up @@ -582,7 +582,7 @@ unsafe fn read_native_font_record(mut tex_id: u32) {
let font_name =
new(((len + 1i32) as u32 as u64).wrapping_mul(::std::mem::size_of::<i8>() as u64) as u32)
as *mut i8;
if ttstub_input_read(handle.0.as_ptr(), font_name, len as size_t) != len as i64 {
if ttstub_input_read_exact(handle.0.as_ptr(), font_name, len as size_t) != len as i64 {
panic!(invalid_signature);
}
*font_name.offset(len as isize) = '\u{0}' as i32 as i8;
Expand Down
Loading