-
Notifications
You must be signed in to change notification settings - Fork 21
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
otf is not a valid font file #56
Comments
Hi we will need more details to be able to help you. Please provide a sample of the code you've written to perform ttf to otf conversion with Allsorts. |
use std::borrow::Borrow;
use std::fs::File;
use std::io::Write;
use allsorts::binary::read::ReadScope;
use allsorts::font_data::FontData;
use allsorts::tables::{FontTableProvider, MaxpTable};
use allsorts::{subset, tag};
use std::error::Error;
type BoxError = Box<dyn Error>;
fn subset_all<F: FontTableProvider>(font_provider: &F, output_path: &str) -> Result<(), BoxError> {
let table = font_provider.table_data(tag::MAXP)?.expect("no maxp table");
let scope = ReadScope::new(table.borrow());
let maxp = scope.read::<MaxpTable>()?;
let glyph_ids = (0..maxp.num_glyphs).collect::<Vec<_>>();
let new_font = subset::subset(font_provider, &glyph_ids, None)?;
let mut output = File::create(output_path)?;
output.write_all(&new_font)?;
Ok(())
}
fn main() {
let buffer = std::fs::read("static/ttf/1808.ttf")
.expect("unable to read Klei.otf");
let scope = ReadScope::new(&buffer);
let font_file = scope.read::<FontData<'_>>().expect("unable to parse font");
let provider = font_file
.table_provider(4)
.expect("unable to create table provider");
let out_file = "static/demo1.otf";
let is_ok = subset_all(&provider, out_file).is_ok();
if is_ok {
println!("Font conversion successful.{:?}", out_file);
}
} |
Thanks, that helps a lot. Unfortunately our subsetting functionality is not yet up to doing what you're trying to do. Issue #27 has some more information. From memory the main issue is that we aren't building a proper |
Ok |
Will this feature be implemented in the future? |
We would like to implement it but there's currently no firm plans/schedule for when it will be done. |
I'm going to close this issue as we are tracking this in #27 |
Just letting you know that the 0.9 release (just published) should fix this issue. |
ttf to otf conversion:

The text was updated successfully, but these errors were encountered: