-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
|
||
pub unsafe fn get_glyph_bounds(&self, gid: GlyphID) -> GlyphBBox { | ||
if let Some(font) = &self.fk_font { | ||
if let Ok(rect) = font.typographic_bounds(gid as u32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, this is the only place we're actually querying font information so far. Further down, font-kit is also used to load the FT_Face.
let mut varString = String::new(); | ||
let mut slice = &variant_string[..]; | ||
while !slice.is_empty() { | ||
if slice.starts_with("AAT") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the slash-options intermingling I was talking about.
ttstub_input_read actually translated into read_exact, which means that the provided methods of Read were getting messed up by the errors being returned. So it's been renamed to what it actually means: ttstub_input_read_exact, and supplemented with ttstub_input_read which does the normal Read::read. Importantly, Read::read is implemented with the latter.
e.g. [lmroman12-regular], parsed into something? Not sure. Kept that code.
let mut sl = CStringListBuilder::new(); sl.push_non_null_terminated(&b"ot"[..]); ... let sl = sl.freeze(); hb_shape_plan_create_cached(..., sl.as_ptr());
Note especially the very clean API for layout_text.
…extLayoutEngine calls
Update:
|
Maybe if you split this PR on several and rebase it will be much easier to understand what's going on here. |
@cormacrelf |
retry #188 (part 1 Enum Dispatch)
Closing this as all main changes are already in |
#186 It's a work in progress. Notable semi-related things included:
-1
(error) to u64 and tellingread_to_end to start reading at the other end of the universe.
find_native_font
more manageable as font-kit will hopefully replace some of it.Some things that need work:
name_of_file
and other tex globals are way too involved in font loading. It's painfully unnecessary. set/getReqEngine also.user_data
pointing to a font_kit Font. I'm not sure Font supports all the things harfbuzz is going to need, but you can always keep forcing font-kit to use the freetype loader and use Font.native_font() to access FT_Face.Some notes:
*mut libc::c_void
pointer, but both pointers are stored in thefont_layout_engine
static mut.font_area
's data stored at the same offset is effectively an enum tag of layout engine types.0xffffu32
. So you could think of it as a layout engine, since the resulting API looks similar to using functions (not methods) from xetex_layout_engine.createLayoutEngine
. No other code usescreateLayoutEngine
.font: XeTeXFontInst
fromcreateFont
, andfontRef: PlatformFontRef
, which is the font loaded withfindFontByName
.measure_native_node
, which doesn't handle AAT fonts but is called during, among other places, line_break.Here's the big plan:
font_area
/0xffffu32
/0xfffeu32
impl LayoutEngine
for a newtypestruct AATLayoutEngine { attributes: CFDictionaryRef }
impl LayoutEngine for XeTeXLayoutEngine
Box<dyn LayoutEngine>
in font_layout_engine, and delete font_area. (Hooray!)impl LayoutEngine
similar toXeTeXLayoutEngine