Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal font list on Windows still uses "\" path sep #21

Closed
arteme opened this issue Jan 14, 2022 · 2 comments
Closed

Internal font list on Windows still uses "\" path sep #21

arteme opened this issue Jan 14, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@arteme
Copy link

arteme commented Jan 14, 2022

Thank you so much for fixing #20. Internal font loading works correctly when using "/" path separator (i.e. "c64/platoon2"), however the internal font list still returns paths with the windows path separator (\).

Configuration

OS type and version: Windows 10 21H1
JVM type and version: 11.0.13
Scala version: 2.12.13
Figlet4s version: 0.3.1

Steps

>   println(Figlet4s.internalFonts)
Vector(1row, 3-d, 3x5, 4max, 5lineoblique, B1FF, acrobatic, alligator, alligator2, alligator3, alpha, alphabet, amc3line, amc3liv1, amcaaa01, amcneko, amcrazo2, amcrazor, amcslash, amcslder, amcthin, amctubes, amcun1, arrows, avatar, banner, banner3-D, banner3, banner4, barbwire, basic, bell, benjamin, big, bigchief, bigfig, binary, block, bolger, bright, broadway, bubble, bulbhead, c64\1943____, c64\4x4_offr, c64\64f1____, c64\a_zooloo, c64\advenger, c64\aquaplan, c64\asc_____, c64\ascii___, c64\assalt_m, c64\asslt__m, c64\atc_____, c64\atc_gran, c64\b_m__200, c64\battle_s, c64\battlesh, c64\baz__bil, c64\beer_pub, c64\bubble__, c64\bubble_b, c64\c1______, c64\c2______, c64\c_ascii_, c64\c_consen, c64\caus_in_, c64\char1___, c64\char2___, c64\char3___, c64\char4___, c64\charact1, c64\charact2, c64\charact3, c64\charact4, c64\charact5, c64\charact6, c64\characte, c64\charset_, c64\coil_cop, c64\com_sen_, c64\computer, c64\convoy__, c64\d_dragon, c64\dcs_bfmo, c64\deep_str, c64\demo_1__, c64\demo_2__, c64\demo_m__, c64\devilish, c64\druid___, c64\e__fist_, c64\ebbs_1__, c64\ebbs_2__, c64\eca_____, c64\etcrvs__, c64\f15_____, c64\faces_of, c64\fair_mea, c64\fairligh, c64\fantasy_, c64\fbr12___, c64\fbr1____, c64\fbr2____, c64\fbr_stri, c64\fbr_tilt, c64\finalass, c64\fireing_, c64\flyn_sh, c64\fp1_____, c64\fp2_____, c64\funky_dr, c64\future_1, c64\future_2, c64\future_3, c64\future_4, c64\future_5, c64\future_6, c64\future_7, c64\future_8, c64\gauntlet, c64\ghost_bo, c64\gothic, c64\gothic__, c64\grand_pr, c64\green_be, c64\hades___, c64\heavy_me, c64\heroboti, c64\high_noo, c64\hills___, c64\home_pak, c64\house_of, c64\hypa_bal, c64\hyper___, c64\inc_raw_, c64\italics_, c64\joust___, c64\kgames_i, c64\kik_star, c64\krak_out, c64\lazy_jon, c64\letter_w, c64\letterw3, c64\lexible_, c64\mad_nurs, c64\magic_ma, c64\master_o, c64\mayhem_d, c64\mcg_____, c64\mig_ally, c64\modern__, c64\new_asci, c64\nfi1____, c64\notie_ca, c64\npn_____, c64\odel_lak, c64\ok_beer_, c64\out
run__, c64\p_s_h_m_, c64\p_skateb, c64\pacos_pe, c64\panther_, c64\pawn_ins, c64\phonix__, c64\platoon2, c64\platoon_, c64\pod_____, c64\r2-d2___, c64\rad_____, c64\rad_phan, c64\radical_, c64\rainbow_, c64\rally_s2, c64\rally_sp, c64\rampage_, c64\rastan__, c64\raw_recu, c64\rci_____, c64\ripper!_, c64\road_rai, c64\rockbox_, c64\rok_____, c64\roman, c64\roman___, c64\script__, c64\skate_ro, c64\skateord, c64\skateroc, c64\sketch_s, c64\sm______, c64\space_op, c64\spc_demo, c64\star_war, c64\stealth_, c64\stencil1, c64\stencil2, c64\street_s, c64\subteran, c64\super_te, c64\t__of_ap, c64\tav1____, c64\taxi____, c64\tec1____, c64\tec_7000, c64\tecrvs__, c64\ti_pan__, c64\timesofl, c64\tomahawk, c64\top_duck, c64\trashman, c64\triad_st, c64\ts1_____, c64\tsm_____, c64\tsn_base, c64\twin_cob, c64\type_set, c64\ucf_fan_, c64\ugalympi, c64\unarmed_, c64\usa_____, c64\usa_pq__, c64\vortron_, c64\war_of_w, c64\yie-ar__, c64\yie_ar_k, c64\z-pilot_, c64\zig_zag_, c64\zone7___, calgphy2, caligraphy, catwalk, chunky, coinstak, colossal, computer, contessa, contrast, cosmic, cosmike, crawford, cricket, cyberlarge, cybermedium, cybersmall, decimal, diamond, digital, doh, doom, dosrebel, dotmatrix, double, drpepper, eftichess, eftifont, eftipiti, eftirobot, eftitalic, eftiwall, eftiwater, epic, fender, fourtops, fraktur, fuzzy, goofy, gothic, gradient, graffiti, greek, henry3d, hex, hollywood, invita, isometric1, isometric2, isometric3, isometric4, italic, ivrit, jacky, jazmine, jerusalem, katakana, kban, keyboard, larry3d, lcd, lean, letters, linux, lockergnome, madrid, marquee, maxfour, mike, mini, mirror, mnemonic, morse, moscow, nancyj-fancy, nancyj-improved, nancyj-underlined, nancyj, nipples, nscript, ntgreek, o8, octal, ogre, oldbanner, os2, pawp, peaks, peaksslant, pebbles, pepper, poison, puffy, rectangles, redphoenix, relief, relief2, reverse, roman, rot13, rounded, rowancap, rozzo, runic, s-relief, santaclara, sblood, script, serifcap, shadow, shimrod, short, slant, slide, slscript, small, smisome1, smkeyboard, smpoison, smscript, smshadow, smslant, smtengwar, speed, stacey, stampate, stampatello, standard, starwars, stellar, stop, straight, sub-zero, tanja, tengwar, term, thick, thin, threepoint, ticks, ticksslant, tiles, tinker-toy, tombstone, trek, tsalagi, tubular, twopoint, univers, usaflag, weird, whimsy)

Problem

Needless to say, using C64 fonts from the internal lists as-is fails:

  val text = "hello, world!"
  val font = Figlet4s.internalFonts.find(_.startsWith("c64")).get
  println(font)
  val banner = Figlet4s.builder(text).withInternalFont(font).render().asString()

This fails witth:

[info] running Test
c64\1943____
[error] (run-main-d) com.colofabrix.scala.figlet4s.errors$FigletLoadingError
[error] com.colofabrix.scala.figlet4s.errors$FigletLoadingError
[error]         at com.colofabrix.scala.figlet4s.errors$FigletLoadingError$.apply(errors.scala:69)
[error]         at com.colofabrix.scala.figlet4s.core.Braket$.withResource(Braket.scala:28)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.readInternal(FontFileReader.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$2(Figlet4sClient.scala:48)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$1(Figlet4sClient.scala:47)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.loadFontInternal(Figlet4sClient.scala:46)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$$anonfun$compileFonts$1.applyOrElse(OptionsBuilder.scala:245)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$$anonfun$compileFonts$1.applyOrElse(OptionsBuilder.scala:225)
[error]         at scala.PartialFunction$OrElse.apply(PartialFunction.scala:172)
[error]         at scala.Function$.$anonfun$untupled$1(Function.scala:110)
[error]         at cats.instances.ListInstances$$anon$1.step$1(list.scala:153)
[error]         at cats.instances.ListInstances$$anon$1.$anonfun$foldM$2(list.scala:158)
[error]         at cats.package$$anon$1.tailRecM(package.scala:76)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.tailRecM(package.scala:72)
[error]         at cats.instances.ListInstances$$anon$1.foldM(list.scala:158)
[error]         at cats.instances.ListInstances$$anon$1.foldM(list.scala:17)
[error]         at cats.Foldable$Ops.foldM(Foldable.scala:975)
[error]         at cats.Foldable$Ops.foldM$(Foldable.scala:974)
[error]         at cats.Foldable$ToFoldableOps$$anon$6.foldM(Foldable.scala:1008)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$.compile(OptionsBuilder.scala:206)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder.compile(OptionsBuilder.scala:163)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.buildOptions$lzycompute(OptionsBuilderMixin.scala:15)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.buildOptions(OptionsBuilderMixin.scala:15)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.render(OptionsBuilderMixin.scala:32)
[error]         at Test$.delayedEndpoint$Test$1(Test.scala:27)
[error]         at Test$delayedInit$body.apply(Test.scala:8)
[error]         at scala.Function0.apply$mcV$sp(Function0.scala:39)
[error]         at scala.Function0.apply$mcV$sp$(Function0.scala:39)
[error]         at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
[error]         at scala.App.$anonfun$main$1$adapted(App.scala:80)
[error]         at scala.collection.immutable.List.foreach(List.scala:431)
[error]         at scala.App.main(App.scala:80)
[error]         at scala.App.main$(App.scala:78)
[error]         at Test$.main(Test.scala:8)
[error]         at Test.main(Test.scala)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] Caused by: java.lang.NullPointerException
[error]         at java.base/java.io.Reader.<init>(Reader.java:167)
[error]         at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:125)
[error]         at scala.io.BufferedSource.reader(BufferedSource.scala:26)
[error]         at scala.io.BufferedSource.bufferedReader(BufferedSource.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.tapSource(FontFileReader.scala:43)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.$anonfun$readInternal$1(FontFileReader.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.Braket$.withResource(Braket.scala:24)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.readInternal(FontFileReader.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$2(Figlet4sClient.scala:48)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$1(Figlet4sClient.scala:47)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.loadFontInternal(Figlet4sClient.scala:46)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$$anonfun$compileFonts$1.applyOrElse(OptionsBuilder.scala:245)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$$anonfun$compileFonts$1.applyOrElse(OptionsBuilder.scala:225)
[error]         at scala.PartialFunction$OrElse.apply(PartialFunction.scala:172)
[error]         at scala.Function$.$anonfun$untupled$1(Function.scala:110)
[error]         at cats.instances.ListInstances$$anon$1.step$1(list.scala:153)
[error]         at cats.instances.ListInstances$$anon$1.$anonfun$foldM$2(list.scala:158)
[error]         at cats.package$$anon$1.tailRecM(package.scala:76)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.tailRecM(package.scala:72)
[error]         at cats.instances.ListInstances$$anon$1.foldM(list.scala:158)
[error]         at cats.instances.ListInstances$$anon$1.foldM(list.scala:17)
[error]         at cats.Foldable$Ops.foldM(Foldable.scala:975)
[error]         at cats.Foldable$Ops.foldM$(Foldable.scala:974)
[error]         at cats.Foldable$ToFoldableOps$$anon$6.foldM(Foldable.scala:1008)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$.compile(OptionsBuilder.scala:206)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder.compile(OptionsBuilder.scala:163)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.buildOptions$lzycompute(OptionsBuilderMixin.scala:15)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.buildOptions(OptionsBuilderMixin.scala:15)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.render(OptionsBuilderMixin.scala:32)
[error]         at Test$.delayedEndpoint$Test$1(Test.scala:27)
[error]         at Test$delayedInit$body.apply(Test.scala:8)
[error]         at scala.Function0.apply$mcV$sp(Function0.scala:39)
[error]         at scala.Function0.apply$mcV$sp$(Function0.scala:39)
[error]         at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
[error]         at scala.App.$anonfun$main$1$adapted(App.scala:80)
[error]         at scala.collection.immutable.List.foreach(List.scala:431)
[error]         at scala.App.main(App.scala:80)
[error]         at scala.App.main$(App.scala:78)
[error]         at Test$.main(Test.scala:8)
[error]         at Test.main(Test.scala)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)

Notes

As I wrote in #20, resources always use / path separator, regardless of the OS path separators, thus treating resource paths as Path object is little erroneous. At the very list you'll want to do something like this in the end: .replaceAll(File.pathSeparator, "/").

@arteme arteme added the bug Something isn't working label Jan 14, 2022
@ColOfAbRiX
Copy link
Owner

ColOfAbRiX commented Jan 17, 2022

Thanks for reporting the bug... again!

In the previous release, I ran all tests under Windows and they all passed. That case is not covered (which is weird, I test internal fonts loading) or something else happend.

I'll publish a fix asap.

@ColOfAbRiX ColOfAbRiX mentioned this issue Nov 5, 2022
9 tasks
@ColOfAbRiX
Copy link
Owner

FInally, I released a patch for this issue.
I hope it's finally fixed, I tested as best as I could

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants