mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGfx: Provide accessors to instruction data to OpenType::Font
These probably won't need to stick around forever, but will be helpful for creating some debug utilities.
This commit is contained in:
parent
4e5dc169a6
commit
768dc4cda1
Notes:
sideshowbarker
2024-07-18 00:41:35 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/768dc4cda1 Pull-request: https://github.com/SerenityOS/serenity/pull/16923 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/ldm5180
4 changed files with 34 additions and 0 deletions
|
@ -703,4 +703,25 @@ bool OS2::use_typographic_metrics() const
|
|||
return header().fs_selection & 0x80;
|
||||
}
|
||||
|
||||
Optional<ReadonlyBytes> Font::font_program() const
|
||||
{
|
||||
if (m_fpgm.has_value())
|
||||
return m_fpgm->program_data();
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<ReadonlyBytes> Font::control_value_program() const
|
||||
{
|
||||
if (m_prep.has_value())
|
||||
return m_prep->program_data();
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<ReadonlyBytes> Font::glyph_program(u32 glyph_id) const
|
||||
{
|
||||
auto glyph_offset = m_loca.get_glyph_offset(glyph_id);
|
||||
auto glyph = m_glyf.glyph(glyph_offset);
|
||||
return glyph.program();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ public:
|
|||
virtual u8 slope() const override;
|
||||
virtual bool is_fixed_width() const override;
|
||||
|
||||
Optional<ReadonlyBytes> font_program() const;
|
||||
Optional<ReadonlyBytes> control_value_program() const;
|
||||
Optional<ReadonlyBytes> glyph_program(u32 glyph_id) const;
|
||||
|
||||
private:
|
||||
enum class Offsets {
|
||||
NumTables = 4,
|
||||
|
|
|
@ -250,6 +250,13 @@ static void get_ttglyph_offsets(ReadonlyBytes slice, u32 num_points, u32 flags_o
|
|||
*y_offset = *x_offset + x_size;
|
||||
}
|
||||
|
||||
ReadonlyBytes Glyf::Glyph::program() const
|
||||
{
|
||||
auto instructions_start = m_num_contours * 2;
|
||||
u16 num_instructions = be_u16(m_slice.offset_pointer(instructions_start));
|
||||
return m_slice.slice(instructions_start + 2, num_instructions);
|
||||
}
|
||||
|
||||
void Glyf::Glyph::rasterize_impl(Gfx::PathRasterizer& rasterizer, Gfx::AffineTransform const& transform) const
|
||||
{
|
||||
// Get offset for flags, x, and y.
|
||||
|
|
|
@ -69,6 +69,8 @@ public:
|
|||
int ascender() const { return m_ymax; }
|
||||
int descender() const { return m_ymin; }
|
||||
|
||||
ReadonlyBytes program() const;
|
||||
|
||||
private:
|
||||
enum class Type {
|
||||
Simple,
|
||||
|
|
Loading…
Reference in a new issue