mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +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
4 changed files with 34 additions and 0 deletions
|
@ -703,4 +703,25 @@ bool OS2::use_typographic_metrics() const
|
||||||
return header().fs_selection & 0x80;
|
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 u8 slope() const override;
|
||||||
virtual bool is_fixed_width() 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:
|
private:
|
||||||
enum class Offsets {
|
enum class Offsets {
|
||||||
NumTables = 4,
|
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;
|
*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
|
void Glyf::Glyph::rasterize_impl(Gfx::PathRasterizer& rasterizer, Gfx::AffineTransform const& transform) const
|
||||||
{
|
{
|
||||||
// Get offset for flags, x, and y.
|
// Get offset for flags, x, and y.
|
||||||
|
|
|
@ -69,6 +69,8 @@ public:
|
||||||
int ascender() const { return m_ymax; }
|
int ascender() const { return m_ymax; }
|
||||||
int descender() const { return m_ymin; }
|
int descender() const { return m_ymin; }
|
||||||
|
|
||||||
|
ReadonlyBytes program() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class Type {
|
enum class Type {
|
||||||
Simple,
|
Simple,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue