Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Feb 4, 2023
1 parent 7ba7c46 commit 6856beb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ext/FreeTypeExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function UnicodePlots.get_font_face(font = nothing, fallback = fallback_fonts())
face
end

UnicodePlots.save_png(args...; kw...) = FileIO.save(args...; kw...)
UnicodePlots.save_image(args...; kw...) = FileIO.save(args...; kw...)

"""
Match a font using the user-specified search string. Each part of the search string
Expand Down
9 changes: 6 additions & 3 deletions ext/ImageInTerminalExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ else
end
using ColorTypes

UnicodePlots.sixel_encode(args...; kw...) = ImageInTerminal.sixel_encode(args...; kw...)
UnicodePlots.sixel_encode(args...; kw...) = ImageInTerminal.sixel_encode(args...; kw...) # COV_EXCL_LINE
UnicodePlots.imshow(args...; kw...) = ImageInTerminal.imshow(args...; kw...)

function UnicodePlots.terminal_specs(img)
char_h = char_w = nothing
# COV_EXCL_START
if ImageInTerminal.choose_sixel(img)
ans = ImageInTerminal.Sixel.TerminalTools.query_terminal("\e[16t", stdout)
if ans isa String && (m = match(r"\e\[6;(\d+);(\d+)t", ans)) nothing
char_h, char_w = tryparse.(Int, m.captures)
return char_h nothing && char_w nothing, char_h, char_w
end

end
false, nothing, nothing
# COV_EXCL_STOP
char_h nothing && char_w nothing, char_h, char_w
end

UnicodePlots.imageplot(img::AbstractArray{<:Colorant}; kw...) =
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/imagegraphics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
@inline nrows(c::ImageGraphics) = first(c.encoded_size)
@inline ncols(c::ImageGraphics) = last(c.encoded_size)

# `ImageInTerminalExt` placeholders
# # generic functions for `ImageInTerminalExt`
function terminal_specs end
function sixel_encode end
function imshow end
Expand Down
6 changes: 3 additions & 3 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ function _show(end_io::IO, print_nocol, print_color, p::Plot)
)
end

# `FreeTypeExt` placeholders
# generic functions for `FreeTypeExt`
function get_font_face end
function render_string! end
function save_png end
function save_image end

"""
png_image(p::Plot, font = nothing, pixelsize = 32, transparent = true, foreground = nothing, background = nothing, bounding_box = nothing, bounding_box_glyph = nothing)
Expand Down Expand Up @@ -597,7 +597,7 @@ function savefig(p::Plot, filename::AbstractString; color::Bool = false, kw...)
elseif ext == ".png"
# `png_image` can fail if fonts are not found: a warning has already been
# thrown there, so just bail out at this stage
(img = png_image(p; kw...)) nothing && save_png(filename, img)
(img = png_image(p; kw...)) nothing && save_image(filename, img)
else
"extension \"$ext\" is unsupported: `savefig` only supports writing to `txt` or `png` files" |>
ArgumentError |>
Expand Down

0 comments on commit 6856beb

Please sign in to comment.