mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
LibGfx/OpenType: Move Glyf composite flag enum to header file
This will allow us to use it for WOFF2 decompression.
This commit is contained in:
parent
bb52d76be3
commit
8ac30aa318
2 changed files with 24 additions and 24 deletions
|
@ -36,21 +36,6 @@ enum class SimpleGlyfFlags {
|
||||||
YPositiveShortVector = 0x24,
|
YPositiveShortVector = 0x24,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class CompositeGlyfFlags {
|
|
||||||
Arg1AndArg2AreWords = 0x0001,
|
|
||||||
ArgsAreXYValues = 0x0002,
|
|
||||||
RoundXYToGrid = 0x0004,
|
|
||||||
WeHaveAScale = 0x0008,
|
|
||||||
MoreComponents = 0x0020,
|
|
||||||
WeHaveAnXAndYScale = 0x0040,
|
|
||||||
WeHaveATwoByTwo = 0x0080,
|
|
||||||
WeHaveInstructions = 0x0100,
|
|
||||||
UseMyMetrics = 0x0200,
|
|
||||||
OverlapCompound = 0x0400, // Not relevant - can overlap without this set
|
|
||||||
ScaledComponentOffset = 0x0800,
|
|
||||||
UnscaledComponentOffset = 0x1000,
|
|
||||||
};
|
|
||||||
|
|
||||||
class PointIterator {
|
class PointIterator {
|
||||||
public:
|
public:
|
||||||
struct Item {
|
struct Item {
|
||||||
|
@ -139,7 +124,7 @@ Optional<Glyf::Glyph::ComponentIterator::Item> Glyf::Glyph::ComponentIterator::n
|
||||||
u16 glyph_id = be_u16(m_slice.offset_pointer(m_offset));
|
u16 glyph_id = be_u16(m_slice.offset_pointer(m_offset));
|
||||||
m_offset += 2;
|
m_offset += 2;
|
||||||
i16 arg1 = 0, arg2 = 0;
|
i16 arg1 = 0, arg2 = 0;
|
||||||
if (flags & (u16)CompositeGlyfFlags::Arg1AndArg2AreWords) {
|
if (flags & (u16)CompositeFlags::Arg1AndArg2AreWords) {
|
||||||
arg1 = be_i16(m_slice.offset_pointer(m_offset));
|
arg1 = be_i16(m_slice.offset_pointer(m_offset));
|
||||||
m_offset += 2;
|
m_offset += 2;
|
||||||
arg2 = be_i16(m_slice.offset_pointer(m_offset));
|
arg2 = be_i16(m_slice.offset_pointer(m_offset));
|
||||||
|
@ -149,7 +134,7 @@ Optional<Glyf::Glyph::ComponentIterator::Item> Glyf::Glyph::ComponentIterator::n
|
||||||
arg2 = (i8)m_slice[m_offset++];
|
arg2 = (i8)m_slice[m_offset++];
|
||||||
}
|
}
|
||||||
float a = 1.0, b = 0.0, c = 0.0, d = 1.0, e = 0.0, f = 0.0;
|
float a = 1.0, b = 0.0, c = 0.0, d = 1.0, e = 0.0, f = 0.0;
|
||||||
if (flags & (u16)CompositeGlyfFlags::WeHaveATwoByTwo) {
|
if (flags & (u16)CompositeFlags::WeHaveATwoByTwo) {
|
||||||
a = be_fword(m_slice.offset_pointer(m_offset));
|
a = be_fword(m_slice.offset_pointer(m_offset));
|
||||||
m_offset += 2;
|
m_offset += 2;
|
||||||
b = be_fword(m_slice.offset_pointer(m_offset));
|
b = be_fword(m_slice.offset_pointer(m_offset));
|
||||||
|
@ -158,33 +143,33 @@ Optional<Glyf::Glyph::ComponentIterator::Item> Glyf::Glyph::ComponentIterator::n
|
||||||
m_offset += 2;
|
m_offset += 2;
|
||||||
d = be_fword(m_slice.offset_pointer(m_offset));
|
d = be_fword(m_slice.offset_pointer(m_offset));
|
||||||
m_offset += 2;
|
m_offset += 2;
|
||||||
} else if (flags & (u16)CompositeGlyfFlags::WeHaveAnXAndYScale) {
|
} else if (flags & (u16)CompositeFlags::WeHaveAnXAndYScale) {
|
||||||
a = be_fword(m_slice.offset_pointer(m_offset));
|
a = be_fword(m_slice.offset_pointer(m_offset));
|
||||||
m_offset += 2;
|
m_offset += 2;
|
||||||
d = be_fword(m_slice.offset_pointer(m_offset));
|
d = be_fword(m_slice.offset_pointer(m_offset));
|
||||||
m_offset += 2;
|
m_offset += 2;
|
||||||
} else if (flags & (u16)CompositeGlyfFlags::WeHaveAScale) {
|
} else if (flags & (u16)CompositeFlags::WeHaveAScale) {
|
||||||
a = be_fword(m_slice.offset_pointer(m_offset));
|
a = be_fword(m_slice.offset_pointer(m_offset));
|
||||||
m_offset += 2;
|
m_offset += 2;
|
||||||
d = a;
|
d = a;
|
||||||
}
|
}
|
||||||
// FIXME: Handle UseMyMetrics, ScaledComponentOffset, UnscaledComponentOffset, non-ArgsAreXYValues
|
// FIXME: Handle UseMyMetrics, ScaledComponentOffset, UnscaledComponentOffset, non-ArgsAreXYValues
|
||||||
if (flags & (u16)CompositeGlyfFlags::ArgsAreXYValues) {
|
if (flags & (u16)CompositeFlags::ArgsAreXYValues) {
|
||||||
e = arg1;
|
e = arg1;
|
||||||
f = arg2;
|
f = arg2;
|
||||||
} else {
|
} else {
|
||||||
// FIXME: Implement this. There's no TODO() here since many fonts work just fine without this.
|
// FIXME: Implement this. There's no TODO() here since many fonts work just fine without this.
|
||||||
}
|
}
|
||||||
if (flags & (u16)CompositeGlyfFlags::UseMyMetrics) {
|
if (flags & (u16)CompositeFlags::UseMyMetrics) {
|
||||||
// FIXME: Implement this. There's no TODO() here since many fonts work just fine without this.
|
// FIXME: Implement this. There's no TODO() here since many fonts work just fine without this.
|
||||||
}
|
}
|
||||||
if (flags & (u16)CompositeGlyfFlags::ScaledComponentOffset) {
|
if (flags & (u16)CompositeFlags::ScaledComponentOffset) {
|
||||||
// FIXME: Implement this. There's no TODO() here since many fonts work just fine without this.
|
// FIXME: Implement this. There's no TODO() here since many fonts work just fine without this.
|
||||||
}
|
}
|
||||||
if (flags & (u16)CompositeGlyfFlags::UnscaledComponentOffset) {
|
if (flags & (u16)CompositeFlags::UnscaledComponentOffset) {
|
||||||
// FIXME: Implement this. There's no TODO() here since many fonts work just fine without this.
|
// FIXME: Implement this. There's no TODO() here since many fonts work just fine without this.
|
||||||
}
|
}
|
||||||
m_has_more = (flags & (u16)CompositeGlyfFlags::MoreComponents);
|
m_has_more = (flags & (u16)CompositeFlags::MoreComponents);
|
||||||
return Item {
|
return Item {
|
||||||
.glyph_id = glyph_id,
|
.glyph_id = glyph_id,
|
||||||
.affine = Gfx::AffineTransform(a, b, c, d, e, f),
|
.affine = Gfx::AffineTransform(a, b, c, d, e, f),
|
||||||
|
|
|
@ -42,6 +42,21 @@ private:
|
||||||
// glyf: Glyph Data
|
// glyf: Glyph Data
|
||||||
class Glyf {
|
class Glyf {
|
||||||
public:
|
public:
|
||||||
|
enum class CompositeFlags {
|
||||||
|
Arg1AndArg2AreWords = 0x0001,
|
||||||
|
ArgsAreXYValues = 0x0002,
|
||||||
|
RoundXYToGrid = 0x0004,
|
||||||
|
WeHaveAScale = 0x0008,
|
||||||
|
MoreComponents = 0x0020,
|
||||||
|
WeHaveAnXAndYScale = 0x0040,
|
||||||
|
WeHaveATwoByTwo = 0x0080,
|
||||||
|
WeHaveInstructions = 0x0100,
|
||||||
|
UseMyMetrics = 0x0200,
|
||||||
|
OverlapCompound = 0x0400, // Not relevant - can overlap without this set
|
||||||
|
ScaledComponentOffset = 0x0800,
|
||||||
|
UnscaledComponentOffset = 0x1000,
|
||||||
|
};
|
||||||
|
|
||||||
class Glyph {
|
class Glyph {
|
||||||
public:
|
public:
|
||||||
Glyph(ReadonlyBytes slice, i16 xmin, i16 ymin, i16 xmax, i16 ymax, i16 num_contours = -1)
|
Glyph(ReadonlyBytes slice, i16 xmin, i16 ymin, i16 xmax, i16 ymax, i16 num_contours = -1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue