GithubHelp home page GithubHelp logo

Comments (21)

ndepaola avatar ndepaola commented on August 29, 2024 1

this issue has been up for a while so I thought I should share an update as to my progress towards resolving it.

This year I've been working on redrawing all of my templates from scratch and I'm almost finished - just need to do the dfc/mdfc planeswalker templates for front/back and normal/extended variants. As soon as they're done I'll publish all of my new templates (which I think are significantly better quality than my old ones, check out images on my gdrive for a comparison as I have a mix of old and new there) and push my code changes that work with the new templates.

I'm also interested in spending some time after the new templates go live on improving the code quality of this repo, as a lot of it is shockingly bad and I've learned a lot since first creating it - that shouldn't entail any functional changes though

from mtg-photoshop-automation.

ndepaola avatar ndepaola commented on August 29, 2024 1

huh, very weird - i'm using CC 2018, but i used to use CS5 and i thought i was being mindful of backwards compatibility. i'll check it out (i think i still have CS5 installed) and see if it's a simple fix. looks like the script didn't read the size of the textbox reference layer properly so it didn't scale down the text at all, but it did rasterise and centre-justify the text relative to the reference.
also feel free to try pulling the refactor branch and see if that fixes the issue for you - i'm not sure why it would but maybe worth a shot!

from mtg-photoshop-automation.

ndepaola avatar ndepaola commented on August 29, 2024 1

i managed to recreate the issue by setting my default units in Photoshop to inches (from pixels) - will post an update when i resolve the bug (don't have much time to work on it atm)

from mtg-photoshop-automation.

hunz-dev avatar hunz-dev commented on August 29, 2024 1

Looks phenomenal, even fixed the mana cost overlap in the previous one!

image

My pleasure helping out, it's the least I could do for all your hard work on this repo. ❤️

from mtg-photoshop-automation.

archangel519 avatar archangel519 commented on August 29, 2024

@Splatypus
I had the same issue when I was trying to proxy Keruga, the Macrosage. It appears that if there is too much text for the text area, there are scaling issues in proxy.jsx around line 730. I have Adobe Photoshop CC 2019. I got my issue "fixed" by removing and adding these lines in proxy.jsx around line 730 (remove the minus lines and add the plus line):

-  var layerHeight = textboxRef.bounds[3] - textboxRef.bounds[1] - tolerance.as("cm");
-  var scaled = scaleTextToFitBox(rulesTextLayer, layerHeight);
+  var scaled = scaleTextToFitBox(rulesTextLayer, getRealTextLayerDimensions(textboxRef).height);

It seems that the layerHeight value is not being correctly calculated by using the bounds, so I just used the rastering and measuring method found in the getRealTextLayerDimensions function.

See if this helps out. I also made some tweaks to the scaleTextToFitBox function from excessFunctions.jsx file while I was testing fixes, but not sure if they were impactful or not. Try this and see if that helps. If you still have issues, I can give you my excessFunctions.jsx changes to see if those do the trick.

from mtg-photoshop-automation.

Splatypus avatar Splatypus commented on August 29, 2024

@archangel519 thanks for the help! You're right in that it seems to be an issue in the scaleTextToFitBox function. Unfortunately, the change on line 730 looks like it gets me the same results. What kind of changes did you make to escessFunctions?

from mtg-photoshop-automation.

Splatypus avatar Splatypus commented on August 29, 2024

I seem to have fixed the issue by commenting out the entire

if(flavourIndex > 0) {

block at formatText.jsx line 940 to line 971.
Not entirely sure what this is for. The comment says "Adjust line break spacing if there's a line break in the flavour text" (same as the next if block). With this section removed, it seems to work as it should, even on any cards with line breaks in the flavour text.

from mtg-photoshop-automation.

archangel519 avatar archangel519 commented on August 29, 2024

Sure, Here is my excessFunctions.jsx updates, beginning around line 26.

// Resize text to fit text box
function scaleTextToFitBox(textLayer, referenceHeight) {
  // Step down font size until text fits within the text box
  startingFontSize = textLayer.textItem.size;
  stepSize = .5;

  var fontSize = startingFontSize;
  var leadSize = fontSize * 1.2;

  var scaled = false;
  var inputWidth = new UnitValue(textLayer.textItem.width, "px");
  var number = textLayer.textItem.height;
  var inputHeight = new UnitValue(2 * (number), "px");

  while (referenceHeight < getRealTextLayerDimensions(textLayer).height) {
    scaled = true;

    // lower font size by 1
    fontSize = fontSize - stepSize;
    textLayer.textItem.size = new UnitValue(fontSize, "px");
    
  }

  return scaled;
}

I think the reason your change fixed your issue is because you are removing the flavor text from the text box, which makes the text not be too big for the text area. The changes I did in the function above basically hard sets the leadSize to 1.2x of the fontSize and does not try to do the previous math. The leadSize was what was causing issues for me if I remember correctly. It's been a few weeks since I had this issue and I'm not sure if my solution is the most elegant way to address this. :)
Your milage may vary.

from mtg-photoshop-automation.

ndepaola avatar ndepaola commented on August 29, 2024

what you guys are seeing with text layers is being caused by two things:

  1. at the start of the year, I updated all of my templates to consistently include the print bleed edge, and have the correct physical dimensions. This means that all of my template's font sizes dropped to starting at 9.18 pt, rather than the 60-something they started at before when I didn't properly account for physical card size. The font size fitter algorithm is currently (as in the version on the repo) set up to step down in 1pt increments.
  2. Photoshop has a known bug where if you transform a text layer - for example, reducing its size to half so the font size drops from 20pt to 10pt - any scripting code will think the font size is 20pt, even though it's clearly 10pt in the photoshop document. The only way to fix this that I'm aware of is to delete the text layer and recreate it.

So currently the repo is pretty broken and I apologise for that. I've been rebuilding all of my templates from scratch to make some tweaks to them (fixing bevels, drop shadows, textures, tweaking a few other things), and these new versions have text layers that have been regenerated to fix this issue. Additionally, I've modified my code to step down in 0.1pt increments and fix a slew of other unitvalue related issues I found. (e.g. the part where leadsize was set to 2x fontsize)

However I'm currently flat out with work and don't have much spare time so work on these templates is on hold atm. My plan was to release all of the new templates and update this repo all at once when the templates are done - I've made good progress on my templates but still have quite a few more to rebuild.

To be honest I wasn't sure that anyone other than myself really used this repo so that's why I haven't prioritised fixing the text layers on my current templates and pushing out a patch earlier haha

re: the purpose of the if (flavourIndex > 0) line and subsequent function call, the text formatter works by:

  1. inserting the specified oracle and flavour text into the layer, then formatting it. When it's formatting the text layer, if the card has flavour text, it'll increase the vertical spacing between rules text and flavour text a bit to match how real cards look (currently broken due to font size issues),
  2. stepping down the font size until the text fits inside the textbox (also currently broken),
  3. rasterising the layer and centering it vertically in the textbox,
  4. if the card is a creature card, it'll make sure the rules text doesn't overlap with the PT box.

from mtg-photoshop-automation.

Splatypus avatar Splatypus commented on August 29, 2024

I know it's probably not enough for the work involved, but if it helps I can drop you a $100 donation with the release of the new working templates/code. This tool is fantastic.

from mtg-photoshop-automation.

ndepaola avatar ndepaola commented on August 29, 2024

holy moly!! you definitely don't have to but that'd be enormously appreciated <3 I'll let you know when I have more to share with regards to my new templates. thank you so much for the kind words!

from mtg-photoshop-automation.

hunz-dev avatar hunz-dev commented on August 29, 2024

Just wanted to drop a comment that I've hit this same issue too when I updated my templates (accidentally overrode the old ones and had to update the repo to work with the new templates). I'd love to help you out @ndepaola if you need, I've been using a fork of your repo for over a year now and am thankful for what you've done to this point!!

Also thank you @Splatypus for the tip on commenting out that block, that did the trick for me too!

from mtg-photoshop-automation.

ndepaola avatar ndepaola commented on August 29, 2024

could you guys try pulling the latest changes and seeing if the updated scripts work w/ the new templates (available on my gdrive)? this should be resolved now

from mtg-photoshop-automation.

hunz-dev avatar hunz-dev commented on August 29, 2024

Opening the new normal.psd in CS6 gave me this prompt:

image

I chose to Keep Layers and overwrote the existing file and ran the scripts, and it looks real close!

image

I'm thinking something may have been lost when I ran that conversion, but I don't think I can get around that.

@ndepaola which version of PS do you use?

from mtg-photoshop-automation.

hunz-dev avatar hunz-dev commented on August 29, 2024

I'll try finding another version of PS to test with, on the refactor branch it looks like I have the same issue plus the mana cost is offset 😬

image

from mtg-photoshop-automation.

ndepaola avatar ndepaola commented on August 29, 2024

hmm, this must have regressed while i was cutting down auto-generated code from format_text - frustrating that i can't recreate the issue locally! format_text on the refactor branch is now resetting the layer's justification to what it was pre-formatting as a final step - when you get a sec could you try pulling the latest changes and see if that fixes it?

re: text not scaling down - the code that drives this sits in scale_text_to_fit_reference in text_layers.jsx, you could try inserting some debugging alerts (like alert(reference_height) on line 41) - it must be something with it not measuring the bounds of the reference layer correctly.

from mtg-photoshop-automation.

hunz-dev avatar hunz-dev commented on August 29, 2024

I pulled 71f8f4c1 and it still renders the same as my last reply unfortunately.

I added a couple print statements and noticed that one of the variables is NaN:

// Reduce the reference height by 64 pixels to avoid text landing on the top/bottom bevels
var reference_height = reference_dimensions.height - new UnitValue(64, "px");
alert(reference_height);  // NaN
alert(reference_dimensions.height);  // 1.04... in
alert(compute_text_layer_dimensions(layer).height);  // 1.17... in

I have no experience with PS scripting so not sure if it was a data type or conversion issue. I'd be happy to jump on a Discord call or something for a debug session if you're interested!

from mtg-photoshop-automation.

hunz-dev avatar hunz-dev commented on August 29, 2024

That fixed it for me, thanks for the tip! Wondering if you should bother fixing it or just include an instruction to set default units to pixels.

image

I'll try playing around with the mana cost again to see if I can get it back to normal for me.

from mtg-photoshop-automation.

hunz-dev avatar hunz-dev commented on August 29, 2024

I extended the execute() function with some custom logic to force justify which seemed to do the trick, I tried it in a few places but this was the one that worked.

image

templates.jsx -- line 367:

    execute: function () {
        return_value = this.super();
        var mana_cost = app.activeDocument.layers.getByName(LayerNames.TEXT_AND_ICONS).layers.getByName(LayerNames.MANA_COST);
        mana_cost.textItem.justification = Justification.RIGHT;
        return return_value;
    }

from mtg-photoshop-automation.

ndepaola avatar ndepaola commented on August 29, 2024

i thought i'd fixed the justification issue (in format_text.jsx), but rereading my code now i must've been half asleep when i wrote it bc it was obviously wrong. also finally had time to play around with UnitValue maths with different photoshop settings and converting everything to pixels before doing any maths/comparisons seems to work. fixes for those two just went up, could you try pulling latest changes and testing again? appreciate your help with this!!

from mtg-photoshop-automation.

ndepaola avatar ndepaola commented on August 29, 2024

excellent!! i'll merge in that branch and leave this issue open for a bit longer in case anyone else in this thread is still having issues <3

from mtg-photoshop-automation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.