Swirt / typertools-src

Public builds - https://swirt.github.io/typertools/
MIT License
42 stars 24 forks source link

Changing font style #56

Closed Szeniel closed 12 months ago

Szeniel commented 12 months ago

Hello! I have a problem when I want to create or edit one style i choose ccshotout as a font, but when i try to change it to bold version it also change the font to Acumin Variable Concept which is Photoshop default font. Is there any way to fix this? I tried to reinstall typertool and then importing settings.

Szeniel commented 12 months ago

For more content: image image

Szeniel commented 12 months ago

I've did it, so in summary explaining long story short, I had to delete all adobe default fonts that are hidden here:C:\Users\User\AppData\Roaming\Adobe\Adobe Photoshop 2023\CT Font Cache. So you need to delete/turn of backup version of this folder, otherwise it will just create a copy every time you open Photoshop. And now I had to delete fuc*king all fonts that have bold version of them, but you can't delete system's fonts family, until you do it in registry here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts Then after deleting literally all fonts with bold version it works as it should.

mangkoran commented 4 months ago

~I also encountered this issue with. Photoshop 23.5.2 + TyperTools v.1.4.9.~

~Is deleting fonts the only workaround?~

Edit: Answered by myself here

mangkoran commented 4 months ago

I looked the code a bit and it seems there is issue in the following line.

https://github.com/Swirt/typertools-src/blob/c598f3a367f7940c7b1f10248dd27bb3fc5acc25/app_src/components/modal/editStyle.jsx#L259-L263

At L260, fonts.find(...) will try to look for element of fonts (passed to the callback fn as font argument) that have the style name of style argument (L259) by checking font.style. However, this is done without checking the currently selected font name (font.family) itself which results the first font from all available fonts that have the same style name will be assigned instead (in this case it is Acumin because it has Bold style too). This is in accordance to @Szeniel workaround which require us to remove all fonts that have the same style name and leave only one font that has Bold style.

We could add boolean check in the callback fn to compare current iteration font.family value with textStyle.fontName which is a React state from L235.

 const changeFontStyle = style => { 
-    const font = fonts.find(font => (font.style === style));
+    const font = fonts.find(font => ((font.family === textStyle.fontName) && (font.style === style))); 
     if (!font) return false; 
     changeFont(font); 
 }; 

CMIIW and please guide me on how could I test this code in local as I never work with PS extension before.

Swirt commented 4 months ago

mangkoran, thanks for your contribution. Yeah, you are right, that seems to be the cause of the problem. I'm just not sure if textStyle should be used there, it needs to be checked. I'm focused on rewriting the extension on UXP right now (not very actively), but I'll probably do another release with this fix.

The easiest way to test the code is to put the repository in C:\Users\%Name%\AppData\Roaming\Adobe\CEP\extensions\ and run npm run build. The new version will appear in your Photoshop (PlayerDebugMode must be enabled).

mangkoran commented 4 months ago

@Swirt Thank you for your reply.

Hmm you are right regarding the variable to be use. How about family from L243?

 const changeFontStyle = style => { 
-    const font = fonts.find(font => (font.style === style));
+    const font = fonts.find(font => ((font.family === family) && (font.style === style))); 
     if (!font) return false; 
     changeFont(font); 
 }; 

Also please let us know if we could help with the rewrite.

mangkoran commented 4 months ago

@Swirt May I know what Node version for this project?

Swirt commented 4 months ago

@mangkoran I'm currently using 20.3.

How about family

Yes, it looks right.

Also please let us know if we could help with the rewrite.

Sure. But first I want to try to figure it out for myself. Although, I don't have a lot of free time right now.

Szeniel commented 2 months ago

How great it is about hearing a good news like 'fixed bug'. Now when I look at it I could look at code too, but that's how people are, we learn by expierience and time. Btw kinda stuck with my translation due to laziness and being burned out, but when time comes I will commit it.