mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
LibPDF: Handle the gs graphical operator
This commit is contained in:
parent
006f5498de
commit
47531619e3
3 changed files with 60 additions and 3 deletions
|
@ -9,25 +9,33 @@
|
||||||
#include <AK/FlyString.h>
|
#include <AK/FlyString.h>
|
||||||
|
|
||||||
#define ENUMERATE_COMMON_NAMES(V) \
|
#define ENUMERATE_COMMON_NAMES(V) \
|
||||||
|
V(AIS) \
|
||||||
V(ASCII85Decode) \
|
V(ASCII85Decode) \
|
||||||
V(ASCIIHexDecode) \
|
V(ASCIIHexDecode) \
|
||||||
|
V(BG) \
|
||||||
|
V(BG2) \
|
||||||
|
V(BM) \
|
||||||
V(BaseFont) \
|
V(BaseFont) \
|
||||||
V(BlackPoint) \
|
V(BlackPoint) \
|
||||||
V(C) \
|
V(C) \
|
||||||
V(CalRGB) \
|
V(CA) \
|
||||||
V(CCITTFaxDecode) \
|
V(CCITTFaxDecode) \
|
||||||
|
V(CalRGB) \
|
||||||
V(ColorSpace) \
|
V(ColorSpace) \
|
||||||
V(Contents) \
|
V(Contents) \
|
||||||
V(Count) \
|
V(Count) \
|
||||||
V(CropBox) \
|
V(CropBox) \
|
||||||
V(Crypt) \
|
V(Crypt) \
|
||||||
|
V(D) \
|
||||||
V(DCTDecode) \
|
V(DCTDecode) \
|
||||||
V(Dest) \
|
V(Dest) \
|
||||||
V(DeviceCMYK) \
|
V(DeviceCMYK) \
|
||||||
V(DeviceGray) \
|
V(DeviceGray) \
|
||||||
V(DeviceRGB) \
|
V(DeviceRGB) \
|
||||||
V(E) \
|
V(E) \
|
||||||
|
V(ExtGState) \
|
||||||
V(F) \
|
V(F) \
|
||||||
|
V(FL) \
|
||||||
V(Filter) \
|
V(Filter) \
|
||||||
V(First) \
|
V(First) \
|
||||||
V(Fit) \
|
V(Fit) \
|
||||||
|
@ -41,35 +49,54 @@
|
||||||
V(Font) \
|
V(Font) \
|
||||||
V(Gamma) \
|
V(Gamma) \
|
||||||
V(H) \
|
V(H) \
|
||||||
|
V(HT) \
|
||||||
|
V(HTO) \
|
||||||
V(JBIG2Decode) \
|
V(JBIG2Decode) \
|
||||||
V(JPXDecode) \
|
V(JPXDecode) \
|
||||||
V(Kids) \
|
V(Kids) \
|
||||||
V(L) \
|
V(L) \
|
||||||
|
V(LC) \
|
||||||
|
V(LJ) \
|
||||||
|
V(LW) \
|
||||||
V(LZWDecode) \
|
V(LZWDecode) \
|
||||||
V(Last) \
|
V(Last) \
|
||||||
V(Length) \
|
V(Length) \
|
||||||
V(Linearized) \
|
V(Linearized) \
|
||||||
|
V(ML) \
|
||||||
V(Matrix) \
|
V(Matrix) \
|
||||||
V(MediaBox) \
|
V(MediaBox) \
|
||||||
V(N) \
|
V(N) \
|
||||||
V(Next) \
|
V(Next) \
|
||||||
V(O) \
|
V(O) \
|
||||||
|
V(OP) \
|
||||||
|
V(OPM) \
|
||||||
V(Outlines) \
|
V(Outlines) \
|
||||||
V(P) \
|
V(P) \
|
||||||
V(Pages) \
|
V(Pages) \
|
||||||
V(Parent) \
|
V(Parent) \
|
||||||
V(Pattern) \
|
V(Pattern) \
|
||||||
V(Prev) \
|
V(Prev) \
|
||||||
|
V(RI) \
|
||||||
V(Resources) \
|
V(Resources) \
|
||||||
V(Root) \
|
V(Root) \
|
||||||
V(Rotate) \
|
V(Rotate) \
|
||||||
V(RunLengthDecode) \
|
V(RunLengthDecode) \
|
||||||
|
V(SA) \
|
||||||
|
V(SM) \
|
||||||
|
V(SMask) \
|
||||||
V(T) \
|
V(T) \
|
||||||
|
V(TK) \
|
||||||
|
V(TR) \
|
||||||
|
V(TR2) \
|
||||||
V(Title) \
|
V(Title) \
|
||||||
V(Type) \
|
V(Type) \
|
||||||
|
V(UCR) \
|
||||||
|
V(UseBlackPTComp) \
|
||||||
V(UserUnit) \
|
V(UserUnit) \
|
||||||
V(WhitePoint) \
|
V(WhitePoint) \
|
||||||
V(XYZ)
|
V(XYZ) \
|
||||||
|
V(ca) \
|
||||||
|
V(op)
|
||||||
|
|
||||||
namespace PDF {
|
namespace PDF {
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,15 @@ RENDERER_HANDLER(set_dash_pattern)
|
||||||
|
|
||||||
RENDERER_TODO(set_color_rendering_intent);
|
RENDERER_TODO(set_color_rendering_intent);
|
||||||
RENDERER_TODO(set_flatness_tolerance);
|
RENDERER_TODO(set_flatness_tolerance);
|
||||||
RENDERER_TODO(set_graphics_state_from_dict);
|
|
||||||
|
RENDERER_HANDLER(set_graphics_state_from_dict)
|
||||||
|
{
|
||||||
|
VERIFY(m_page.resources->contains(CommonNames::ExtGState));
|
||||||
|
auto dict_name = m_document->resolve_to<NameObject>(args[0])->name();
|
||||||
|
auto ext_gstate_dict = m_page.resources->get_dict(m_document, CommonNames::ExtGState);
|
||||||
|
auto target_dict = ext_gstate_dict->get_dict(m_document, dict_name);
|
||||||
|
set_graphics_state_from_dict(target_dict);
|
||||||
|
}
|
||||||
|
|
||||||
RENDERER_HANDLER(path_move)
|
RENDERER_HANDLER(path_move)
|
||||||
{
|
{
|
||||||
|
@ -475,6 +483,27 @@ Gfx::Rect<T> Renderer::map(Gfx::Rect<T> rect) const
|
||||||
return state().ctm.map(rect);
|
return state().ctm.map(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::set_graphics_state_from_dict(NonnullRefPtr<DictObject> dict)
|
||||||
|
{
|
||||||
|
if (dict->contains(CommonNames::LW))
|
||||||
|
handle_set_line_width({ dict->get_value(CommonNames::LW) });
|
||||||
|
|
||||||
|
if (dict->contains(CommonNames::LC))
|
||||||
|
handle_set_line_cap({ dict->get_value(CommonNames::LC) });
|
||||||
|
|
||||||
|
if (dict->contains(CommonNames::LJ))
|
||||||
|
handle_set_line_join({ dict->get_value(CommonNames::LJ) });
|
||||||
|
|
||||||
|
if (dict->contains(CommonNames::ML))
|
||||||
|
handle_set_miter_limit({ dict->get_value(CommonNames::ML) });
|
||||||
|
|
||||||
|
if (dict->contains(CommonNames::D))
|
||||||
|
handle_set_dash_pattern(dict->get_array(m_document, CommonNames::D)->elements());
|
||||||
|
|
||||||
|
if (dict->contains(CommonNames::FL))
|
||||||
|
handle_set_flatness_tolerance({ dict->get_value(CommonNames::FL) });
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::show_text(const String& string, int shift)
|
void Renderer::show_text(const String& string, int shift)
|
||||||
{
|
{
|
||||||
auto utf = Utf8View(string);
|
auto utf = Utf8View(string);
|
||||||
|
|
|
@ -92,6 +92,7 @@ private:
|
||||||
void handle_text_next_line_show_string(const Vector<Value>& args);
|
void handle_text_next_line_show_string(const Vector<Value>& args);
|
||||||
void handle_text_next_line_show_string_set_spacing(const Vector<Value>& args);
|
void handle_text_next_line_show_string_set_spacing(const Vector<Value>& args);
|
||||||
|
|
||||||
|
void set_graphics_state_from_dict(NonnullRefPtr<DictObject>);
|
||||||
// shift is the manual advance given in the TJ command array
|
// shift is the manual advance given in the TJ command array
|
||||||
void show_text(const String&, int shift = 0);
|
void show_text(const String&, int shift = 0);
|
||||||
RefPtr<ColorSpace> get_color_space(const Value&);
|
RefPtr<ColorSpace> get_color_space(const Value&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue