mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibPDF+MacPDF: Clip text, and add a debug option for disabling it
This commit is contained in:
parent
90fdf738a1
commit
a0462f495c
Notes:
sideshowbarker
2024-07-17 05:05:51 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/a0462f495c Pull-request: https://github.com/SerenityOS/serenity/pull/22871 Reviewed-by: https://github.com/ADKaster ✅
7 changed files with 30 additions and 0 deletions
|
@ -29,5 +29,6 @@
|
|||
- (IBAction)toggleShowClippingPaths:(id)sender;
|
||||
- (IBAction)toggleClipImages:(id)sender;
|
||||
- (IBAction)toggleClipPaths:(id)sender;
|
||||
- (IBAction)toggleClipText:(id)sender;
|
||||
|
||||
@end
|
||||
|
|
|
@ -177,6 +177,10 @@ static NSBitmapImageRep* ns_from_gfx(NonnullRefPtr<Gfx::Bitmap> bitmap_p)
|
|||
[item setState:_preferences.clip_paths ? NSControlStateValueOn : NSControlStateValueOff];
|
||||
return _doc ? YES : NO;
|
||||
}
|
||||
if ([item action] == @selector(toggleClipText:)) {
|
||||
[item setState:_preferences.clip_text ? NSControlStateValueOn : NSControlStateValueOff];
|
||||
return _doc ? YES : NO;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -204,6 +208,14 @@ static NSBitmapImageRep* ns_from_gfx(NonnullRefPtr<Gfx::Bitmap> bitmap_p)
|
|||
}
|
||||
}
|
||||
|
||||
- (IBAction)toggleClipText:(id)sender
|
||||
{
|
||||
if (_doc) {
|
||||
_preferences.clip_text = !_preferences.clip_text;
|
||||
[self invalidateCachedBitmap];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyDown:(NSEvent*)event
|
||||
{
|
||||
// Calls moveLeft: or moveRight: below.
|
||||
|
|
|
@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (IBAction)toggleShowClippingPaths:(id)sender;
|
||||
- (IBAction)toggleClipImages:(id)sender;
|
||||
- (IBAction)toggleClipPaths:(id)sender;
|
||||
- (IBAction)toggleClipText:(id)sender;
|
||||
- (IBAction)showGoToPageDialog:(id)sender;
|
||||
|
||||
- (void)pdfDidInitialize;
|
||||
|
|
|
@ -154,6 +154,11 @@
|
|||
[_pdfView toggleClipPaths:sender];
|
||||
}
|
||||
|
||||
- (IBAction)toggleClipText:(id)sender
|
||||
{
|
||||
[_pdfView toggleClipText:sender];
|
||||
}
|
||||
|
||||
- (IBAction)showGoToPageDialog:(id)sender
|
||||
{
|
||||
auto alert = [[NSAlert alloc] init];
|
||||
|
|
|
@ -682,6 +682,12 @@
|
|||
<action selector="toggleClipPaths:" target="-1" id="pZu-tJ-RFh"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Clip Text" state="on" id="u58-eB-op8">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleClipText:" target="-1" id="qxg-tH-KXd"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
|
|
|
@ -1011,6 +1011,10 @@ PDFErrorOr<void> Renderer::show_text(ByteString const& string)
|
|||
if (!text_state().font)
|
||||
return Error::rendering_unsupported_error("Can't draw text because an invalid font was in use");
|
||||
|
||||
OwnPtr<ClipRAII> clip_raii;
|
||||
if (m_rendering_preferences.clip_text)
|
||||
clip_raii = make<ClipRAII>(*this);
|
||||
|
||||
auto start_position = Gfx::FloatPoint { 0.0f, 0.0f };
|
||||
auto end_position = TRY(text_state().font->draw_string(m_painter, start_position, string, *this));
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ struct RenderingPreferences {
|
|||
|
||||
bool clip_images { true };
|
||||
bool clip_paths { true };
|
||||
bool clip_text { true };
|
||||
|
||||
unsigned hash() const
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue