brownplt / code.pyret.org

Website for serving Pyret to folks.
Other
24 stars 45 forks source link

text-font does not respect the font size argument #465

Closed schanzer closed 1 year ago

schanzer commented 1 year ago

It looks like it's defaulting to a very small font size, regardless of what is passed in as the argument. This works in WeScheme, so something must have broken in the Pyret port. Interestingly enough, the regular text function does not have this problem, despite sharing the same underlying JS implementation!

The raw JS code looks identical to the WeScheme version, but I think the culprit may lie in the annotation checker. The wrapper for text uses this checker:

c3("text", maybeString, runtime.String, maybeSize, annByte, maybeColor, annColor);

In contrast, the wrapper for text-font uses this series of checkers:

        c("text-font", 
          maybeString, runtime.String,
          maybeSize, annByte,
          maybeColor, annColor,
          maybeFace, runtime.String,
          maybeFamily, annFontFamily,
          maybeStyle, annFontStyle,
          maybeWeight, annFontWeight,
          maybeUnderline, runtime.Boolean);

Why check the annotation differently?

Other than that, I don't see any reason for the different behavior. @blerner will likely have better insight than I.

blerner commented 1 year ago

I don't see any problem: image That looks like full font-size to me...and it works with the image-typed library as well as the image-untyped one. What call are you trying to make, that doesn't seem to be working?

schanzer commented 1 year ago

Whoa. OK, I can only chalk this up to gremlins or my own creeping insanity.

I opened one of the Bootstrap example games and switched the context to use a newer file I'm working on. Changes made in that file were not reflected in the game (after the usual "publish, refresh, update-context, run" cycle), so eventually I tried to copy/pasting the examples from the documentation in the REPL and getting the same weird result.

But yeah, upon opening a fresh tab and doing the exact same thing, I'm now seeing the expected behavior. Sorry for the false alarm! (But I am curious why we use different annotations for size in the two text functions...)

blerner commented 1 year ago

I think you're misreading -- both maybeSize arguments are checked as annBytes. The checker functions are asking "does this possibly-valid-size value satisfy the annByte annotation?" The difference between c and c3 are just the arities of the checking -- c3 is hard-coded to three argument/annotation pairings.