-module(starprnt). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/starprnt.gleam"). -export([print_speed/1, image_raster/2, text_raster/5]). -export_type([speed/0, wrap/0]). -type speed() :: slow | normal | fast. -type wrap() :: no_wrap | wrap_anywhere | {wrap_words, boolean()}. -file("src/starprnt.gleam", 15). -spec print_speed(speed()) -> bitstring(). print_speed(Speed) -> Num = case Speed of slow -> 2; normal -> 1; fast -> 0 end, <<16#1b, 16#1e, "r"/utf8, Num>>. -file("src/starprnt.gleam", 53). -spec raster_line(bitstring(), integer()) -> bitstring(). raster_line(Bits, Byte_size) -> <<"b"/utf8, Byte_size:16/little, Bits/bitstring>>. -file("src/starprnt.gleam", 57). -spec padded_raster_line(bitstring()) -> bitstring(). padded_raster_line(Bits) -> Bits@1 = gleam_stdlib:bit_array_pad_to_bytes(Bits), raster_line(Bits@1, erlang:byte_size(Bits@1)). -file("src/starprnt.gleam", 138). -spec do_process_codepoints( list(integer()), bitstring(), fun((binary()) -> {ok, bitstring()} | {error, nil}), list({binary(), bitstring()}) ) -> list({binary(), bitstring()}). do_process_codepoints(Codepoints, Default_glyph, Render_glyph, Acc) -> case Codepoints of [] -> Acc; [Codepoint | Codepoints@1] -> Char = gleam_stdlib:utf_codepoint_list_to_string([Codepoint]), Acc@1 = case Render_glyph(Char) of {ok, Bits} -> [{Char, Bits} | Acc]; {error, nil} -> [{Char, Default_glyph} | Acc] end, do_process_codepoints( Codepoints@1, Default_glyph, Render_glyph, Acc@1 ) end. -file("src/starprnt.gleam", 108). -spec do_process_graphemes( list(binary()), bitstring(), fun((binary()) -> {ok, bitstring()} | {error, nil}), list({binary(), bitstring()}) ) -> list({binary(), bitstring()}). do_process_graphemes(Graphemes, Default_glyph, Render_glyph, Acc) -> case Graphemes of [] -> lists:reverse(Acc); [<<"\r"/utf8>> | Graphemes@1] -> do_process_graphemes(Graphemes@1, Default_glyph, Render_glyph, Acc); [<<"\t"/utf8>> | Graphemes@2] -> Graphemes@3 = [<<" "/utf8>>, <<" "/utf8>> | Graphemes@2], do_process_graphemes(Graphemes@3, Default_glyph, Render_glyph, Acc); [<<"\f"/utf8>> | Graphemes@4] -> Graphemes@5 = [<<"\n"/utf8>>, <<"\n"/utf8>> | Graphemes@4], do_process_graphemes(Graphemes@5, Default_glyph, Render_glyph, Acc); [Grapheme | Graphemes@6] -> Acc@1 = case Render_glyph(Grapheme) of {ok, Bits} -> [{Grapheme, Bits} | Acc]; {error, nil} -> _pipe = gleam@string:to_utf_codepoints(Grapheme), do_process_codepoints( _pipe, Default_glyph, Render_glyph, Acc ) end, do_process_graphemes( Graphemes@6, Default_glyph, Render_glyph, Acc@1 ) end. -file("src/starprnt.gleam", 166). -spec do_no_wrap( list({binary(), bitstring()}), integer(), integer(), list(bitstring()), list(list(bitstring())) ) -> list(list(bitstring())). do_no_wrap(Chars, Line_limit, Line_len, Line, Lines) -> case Chars of [] -> lists:reverse([lists:reverse(Line) | Lines]); [{<<"\n"/utf8>>, _} | Chars@1] -> do_no_wrap( Chars@1, Line_limit, 0, [], [lists:reverse(Line) | Lines] ); [{_, Bits} | Chars@2] when Line_len < Line_limit -> do_no_wrap(Chars@2, Line_limit, Line_len + 1, [Bits | Line], Lines); [_ | Chars@3] -> do_no_wrap(Chars@3, Line_limit, Line_len, Line, Lines) end. -file("src/starprnt.gleam", 183). -spec do_wrap_anywhere( list({binary(), bitstring()}), integer(), integer(), list(bitstring()), list(list(bitstring())) ) -> list(list(bitstring())). do_wrap_anywhere(Chars, Line_limit, Line_len, Line, Lines) -> case Chars of [] -> lists:reverse([lists:reverse(Line) | Lines]); [{<<"\n"/utf8>>, _} | Chars@1] -> Acc = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@1, Line_limit, 0, [], Acc); [{_, Bits} | Chars@2] when Line_len < Line_limit -> Line@1 = [Bits | Line], do_wrap_anywhere(Chars@2, Line_limit, Line_len + 1, Line@1, Lines); [{<<" "/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{1680}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{2000}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{2001}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{2002}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{2003}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{2004}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{2005}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{2006}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{2008}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{2009}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{200a}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{205f}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{<<"\x{3000}"/utf8>>, _} | Chars@3] -> Lines@1 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@3, Line_limit, 0, [], Lines@1); [{_, Bits@1} | Chars@4] -> Lines@2 = [lists:reverse(Line) | Lines], do_wrap_anywhere(Chars@4, Line_limit, 1, [Bits@1], Lines@2) end. -file("src/starprnt.gleam", 224). -spec do_wrap_words( list({binary(), bitstring()}), boolean(), integer(), gleam@option:option(bitstring()), integer(), list(bitstring()), integer(), list(bitstring()), list(list(bitstring())) ) -> list(list(bitstring())). do_wrap_words( Chars, Wrap, Line_limit, Break, Word_len, Word, Line_len, Line, Lines ) -> case Chars of [] when (Line_len + Word_len) < Line_limit -> Line@1 = case Break of {some, Break@1} -> lists:reverse(Line, [Break@1 | lists:reverse(Word)]); none -> lists:reverse(Word) end, lists:reverse([Line@1 | Lines]); [] -> lists:reverse([lists:reverse(Word), lists:reverse(Line) | Lines]); [{<<"\n"/utf8>>, _} | Chars@1] when (Line_len + Word_len) < Line_limit -> Line@2 = case Break of {some, Break@2} -> lists:reverse(Line, [Break@2 | lists:reverse(Word)]); none -> lists:reverse(Word) end, Lines@1 = [Line@2 | Lines], do_wrap_words( Chars@1, Wrap, Line_limit, none, 0, [], 0, [], Lines@1 ); [{<<"\n"/utf8>>, _} | Chars@2] -> Lines@2 = [lists:reverse(Word), lists:reverse(Line) | Lines], do_wrap_words( Chars@2, Wrap, Line_limit, none, 0, [], 0, [], Lines@2 ); [{<<" "/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{1680}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{2000}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{2001}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{2002}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{2003}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{2004}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{2005}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{2006}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{2008}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{2009}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{200a}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{205f}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<"\x{3000}"/utf8>>, New_break} | Chars@3] when (Line_len + Word_len) < Line_limit -> {Line@3, Line_len@1} = case Break of {some, Break@3} -> {lists:reverse([Break@3 | lists:reverse(Word)], Line), (Line_len + Word_len) + 1}; none -> {lists:reverse(lists:reverse(Word), Line), Line_len + Word_len} end, do_wrap_words( Chars@3, Wrap, Line_limit, {some, New_break}, 0, [], Line_len@1, Line@3, Lines ); [{<<" "/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{1680}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{2000}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{2001}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{2002}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{2003}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{2004}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{2005}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{2006}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{2008}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{2009}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{200a}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{205f}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{<<"\x{3000}"/utf8>>, Break@4} | Chars@4] -> do_wrap_words( Chars@4, Wrap, Line_limit, {some, Break@4}, 0, [], Word_len, Word, [lists:reverse(Line) | Lines] ); [{_, Bits} | Chars@5] when Word_len < Line_limit -> do_wrap_words( Chars@5, Wrap, Line_limit, Break, Word_len + 1, [Bits | Word], Line_len, Line, Lines ); [{_, Bits@1} | Chars@6] when Wrap -> Lines@3 = case Line of [] -> [lists:reverse(Word) | Lines]; _ -> [lists:reverse(Word), lists:reverse(Line) | Lines] end, do_wrap_words( Chars@6, Wrap, Line_limit, none, 1, [Bits@1], 0, [], Lines@3 ); [_ | Chars@7] -> do_wrap_words( Chars@7, Wrap, Line_limit, Break, Word_len, Word, Line_len, Line, Lines ) end. -file("src/starprnt.gleam", 157). -spec layout_chars(list({binary(), bitstring()}), wrap(), integer()) -> list(list(bitstring())). layout_chars(Chars, Wrap, Line_limit) -> case Wrap of no_wrap -> do_no_wrap(Chars, Line_limit, 0, [], []); wrap_anywhere -> do_wrap_anywhere(Chars, Line_limit, 0, [], []); {wrap_words, Wrap_overflow} -> do_wrap_words( Chars, Wrap_overflow, Line_limit, none, 0, [], 0, [], [] ) end. -file("src/starprnt.gleam", 431). -spec do_scale_bits(bitstring(), integer(), bitstring()) -> bitstring(). do_scale_bits(Bits, Scale, Acc) -> case Bits of <<0:1, Bits@1/bitstring>> -> do_scale_bits( Bits@1, Scale, <> ); <<1:1, Bits@2/bitstring>> -> do_scale_bits( Bits@2, Scale, <> ); _ -> Acc end. -file("src/starprnt.gleam", 423). -spec scale_bits(bitstring(), integer()) -> bitstring(). scale_bits(Bits, Scale) -> case Scale of 0 -> <<>>; 1 -> Bits; -1 -> Bits; _ -> do_scale_bits(Bits, gleam@int:absolute_value(Scale), <<>>) end. -file("src/starprnt.gleam", 449). -spec do_repeat_bits(bitstring(), integer(), bitstring()) -> bitstring(). do_repeat_bits(Bits, Times, Acc) -> case Times of 0 -> Acc; _ -> do_repeat_bits(Bits, Times - 1, <>) end. -file("src/starprnt.gleam", 441). -spec repeat_bits(bitstring(), integer()) -> bitstring(). repeat_bits(Bits, Times) -> case Times of 0 -> <<>>; 1 -> Bits; -1 -> Bits; _ -> do_repeat_bits(Bits, gleam@int:absolute_value(Times) - 1, Bits) end. -file("src/starprnt.gleam", 71). -spec do_image_raster(bitstring(), bitstring()) -> bitstring(). do_image_raster(Image_data, Acc) -> case Image_data of <<>> -> Acc; <> -> Line = raster_line(Data, 72), do_image_raster(Image_data@1, <>); <> -> <> end. -file("src/starprnt.gleam", 387). -spec do_render_char_line( list(bitstring()), integer(), integer(), integer(), bitstring(), list(bitstring()) ) -> {bitstring(), list(bitstring())}. do_render_char_line(Chars, Padding, Width, Scale, Acc, Leftover_chars) -> case Chars of [] -> {begin _pipe = case Acc of <> -> raster_line(Data, 72); _ -> padded_raster_line(Acc) end, repeat_bits(_pipe, Scale) end, lists:reverse(Leftover_chars)}; [Char | Chars@1] -> case Char of <> -> Acc@1 = <>, Leftover_chars@1 = [Leftover_char | Leftover_chars], do_render_char_line( Chars@1, Padding, Width, Scale, Acc@1, Leftover_chars@1 ); _ -> Acc@2 = <>, Leftover_chars@2 = [Char | Leftover_chars], do_render_char_line( Chars@1, Padding, Width, Scale, Acc@2, Leftover_chars@2 ) end end. -file("src/starprnt.gleam", 361). -spec do_render_lines( list(list(bitstring())), integer(), integer(), integer(), integer(), integer(), bitstring() ) -> bitstring(). do_render_lines(Lines, Padding, Width, Height, Rem_height, Scale, Acc) -> case Lines of [] -> Acc; [Chars | Lines@1] -> case Rem_height of 0 -> do_render_lines( Lines@1, Padding, Width, Height, Height, Scale, Acc ); _ -> {Line_data, Chars@1} = do_render_char_line( Chars, Padding, Width, Scale, <<>>, [] ), Acc@1 = <>, Lines@2 = [Chars@1 | Lines@1], Rem_height@1 = Rem_height - 1, do_render_lines( Lines@2, Padding, Width, Height, Rem_height@1, Scale, Acc@1 ) end end. -file("src/starprnt.gleam", 62). -spec image_raster(bitstring(), boolean()) -> bitstring(). image_raster(Image_data, Cut) -> Start_bits = case Cut of true -> <<(<<(<<(16#1b), "*r"/utf8>>)/bitstring, "A"/utf8>>)/bitstring, (<<(<<(16#1b), "*r"/utf8>>)/bitstring, "P0"/utf8, 0>>)/bitstring>>; false -> <<(<<(<<(<<(16#1b), "*r"/utf8>>)/bitstring, "A"/utf8>>)/bitstring, (<<(<<(16#1b), "*r"/utf8>>)/bitstring, "P0"/utf8, 0>>)/bitstring>>)/bitstring, (<<(<<(16#1b), "*r"/utf8>>)/bitstring, "E1"/utf8, 0>>)/bitstring>> end, _pipe = do_image_raster(Image_data, Start_bits), gleam@bit_array:append( _pipe, <<(<<(16#1b), "*r"/utf8>>)/bitstring, "B"/utf8>> ). -file("src/starprnt.gleam", 82). -spec text_raster(binary(), starprnt@font:font(), integer(), wrap(), boolean()) -> bitstring(). text_raster(Text, Font, Scale, Wrap, Cut) -> gleam@bool:guard( Scale =:= 0, <<>>, fun() -> {font, Width, Height, Default_glyph, Render_glyph} = Font, Line_limit = case (Width * gleam@int:absolute_value(Scale)) of 0 -> 0; Gleam@denominator -> 8 * 72 div Gleam@denominator end, Padding = case Width rem 8 of 0 -> 0; Rem -> 8 - Rem end, Start_bits = case Cut of true -> <<(<<(<<(16#1b), "*r"/utf8>>)/bitstring, "A"/utf8>>)/bitstring, (<<(<<(16#1b), "*r"/utf8>>)/bitstring, "P0"/utf8, 0>>)/bitstring>>; false -> <<(<<(<<(<<(16#1b), "*r"/utf8>>)/bitstring, "A"/utf8>>)/bitstring, (<<(<<(16#1b), "*r"/utf8>>)/bitstring, "P0"/utf8, 0>>)/bitstring>>)/bitstring, (<<(<<(16#1b), "*r"/utf8>>)/bitstring, "E1"/utf8, 0>>)/bitstring>> end, _pipe = gleam@string:to_graphemes(Text), _pipe@1 = do_process_graphemes( _pipe, Default_glyph, Render_glyph, [] ), _pipe@2 = layout_chars(_pipe@1, Wrap, Line_limit), _pipe@3 = do_render_lines( _pipe@2, Padding, Width, Height, Height, Scale, Start_bits ), gleam@bit_array:append( _pipe@3, <<(<<(16#1b), "*r"/utf8>>)/bitstring, "B"/utf8>> ) end ).