mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:47:47 +00:00
LibGfx: Implement ByteEncoding mappings for Cmaps
This commit is contained in:
parent
0ff9f2b865
commit
04ee181b21
2 changed files with 15 additions and 1 deletions
|
@ -75,10 +75,12 @@ Optional<Cmap::Subtable> Cmap::subtable(u32 index) const
|
|||
return Subtable(subtable_slice, platform_id, encoding_id);
|
||||
}
|
||||
|
||||
// FIXME: This only handles formats 4 (SegmentToDelta) and 12 (SegmentedCoverage) for now.
|
||||
// FIXME: Implement the missing formats.
|
||||
u32 Cmap::Subtable::glyph_id_for_code_point(u32 code_point) const
|
||||
{
|
||||
switch (format()) {
|
||||
case Format::ByteEncoding:
|
||||
return glyph_id_for_code_point_table_0(code_point);
|
||||
case Format::SegmentToDelta:
|
||||
return glyph_id_for_code_point_table_4(code_point);
|
||||
case Format::SegmentedCoverage:
|
||||
|
@ -88,6 +90,14 @@ u32 Cmap::Subtable::glyph_id_for_code_point(u32 code_point) const
|
|||
}
|
||||
}
|
||||
|
||||
u32 Cmap::Subtable::glyph_id_for_code_point_table_0(u32 code_point) const
|
||||
{
|
||||
if (code_point > 255)
|
||||
return 0;
|
||||
|
||||
return m_slice.at((u32)Table0Offsets::GlyphIdArray + code_point);
|
||||
}
|
||||
|
||||
u32 Cmap::Subtable::glyph_id_for_code_point_table_4(u32 code_point) const
|
||||
{
|
||||
u32 segcount_x2 = be_u16(m_slice.offset_pointer((u32)Table4Offsets::SegCountX2));
|
||||
|
|
|
@ -52,6 +52,9 @@ public:
|
|||
Format format() const;
|
||||
|
||||
private:
|
||||
enum class Table0Offsets {
|
||||
GlyphIdArray = 6
|
||||
};
|
||||
enum class Table4Offsets {
|
||||
SegCountX2 = 6,
|
||||
EndConstBase = 14,
|
||||
|
@ -75,6 +78,7 @@ public:
|
|||
Record = 12,
|
||||
};
|
||||
|
||||
u32 glyph_id_for_code_point_table_0(u32 code_point) const;
|
||||
u32 glyph_id_for_code_point_table_4(u32 code_point) const;
|
||||
u32 glyph_id_for_code_point_table_12(u32 code_point) const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue