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

Load a font? #261

Closed
dredknight opened this issue Jul 2, 2016 · 15 comments
Closed

Load a font? #261

dredknight opened this issue Jul 2, 2016 · 15 comments
Assignees
Milestone

Comments

@dredknight
Copy link
Contributor

@dredknight dredknight commented Jul 2, 2016

Hello everyone,

I am using a font that is not always available on windows systems.
Searching for a method to load the font, shoes provides such but unfortunately it is not documented how exactly to use it. Here is the article -> http://shoesrb.com/manual/Built-in.html#font

A few iterations of this were tried but nothing happened:

font ("path-to-file.ttf")
font (path-to-file.ttf)
font path-to-file.ttf

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jul 2, 2016

here's what the manual does

font "#{DIR}/fonts/Coolvetica.ttf" unless Shoes::FONTS.include? "Coolvetica"

DIR is where Shoes is installed and fonts is directory in there.

@dredknight
Copy link
Contributor Author

@dredknight dredknight commented Jul 3, 2016

Alright, I tried this out:

font "text/fonts/vivaldi.ttf" unless Shoes::FONTS.include? "Vivaldi"
debug("#{Shoes::FONTS.include? "Vivaldi"}")
style Shoes::Subtitle, font: "Vivaldi" 

debug says true! but the Subtitle text do not change. Why is that happening? This happens on Windows 7 system.

This works fine when the font is loaded manually on the system.

style Shoes::Subtitle, font: "Vivaldi" 

Have anyone used this font thing actually?

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jul 3, 2016

Just for fun, copy the Coolvetica font c:"program files (x86)\Shoes\fonts\ to your text/fonts and change and see if it will load in place of your vivaldi.ttf. If if works then we know that there's something in you ttf that Shoes doesn't like. If the font is loaded into Windows, Shoes gets from a different path in the code.

@dredknight
Copy link
Contributor Author

@dredknight dredknight commented Jul 5, 2016

font "#{DIR}/fonts/Coolvetica.ttf" unless Shoes::FONTS.include? "Coolvetica.ttf"
debug("#{Shoes::FONTS.include? "Coolvetica"}")
style Shoes::Subtitle, font: "Coolvetica" 

I tried both ways - take it from program directory and directly from Shoes font directory - but no success.

Actually here is my 0.7 version of the code - https://gist.github.com/dredknight/1f7985976c4fad6a3036
And here is a preproduction - exe file

The files that the code uses are in the exe file so just unzip and unshy it :).
There are a few things which are not yet ok.

  1. text sucks when you dont have vivaldi installed - basically what we are working on
  2. POPup - If there are no issues or new stuff are not added it will be migrated to class and later on to widget. So far it is looking quite promising though!
  3. & 4. I cant recall but there were 2 others... that font thing is really getting my brain out the last few days!!!
@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jul 5, 2016

Coolvettica doesn't load?!? Does the manual look OK? because it does load the font - see help.rb inside shoes\lib\shoes Font handling on Windows has been a big source of problems so I don't discount that their are errors still.

I don't have a dropbox account and unlikely to get one.

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jul 5, 2016

'''ruby
Shoes.app {
para Shoes::FONTS
para "\n----------------------------------------------\n"
para "#{Shoes::FONTS}\n"
para "\n----------------------------------------------\n"
font "vivaldi.ttf"
para "#{Shoes::FONTS}\n", font: "Vivaldi"
para "\n..............................................\n"
Shoes::FONTS.each {|ft| info ft}
}
Displays on Linux, doesn't display on Win 7.

@dredknight
Copy link
Contributor Author

@dredknight dredknight commented Jul 5, 2016

@ccoupe no need for a dropbox account :). there is a button called " No thanks, continue to view → " where you can download the file.

Actually Coolvetica loads (Vivaldi also get loaded). I mean the compiler responds with "true" but there is no change in the text nor you can see the font in windows "Fonts".

Let me know if I can assist in some way.

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jul 6, 2016

As expected, this is a another damn font bug on windows. I don't want to go back to the older fontconfig mess - that would fix this problem but annoy every windows user with slow or inconsistent startup and other oddities when using the command line.

The work around is as you've discovered, install the font in Windows. If you get close to shipping the app and the bug isn't fixed, then you'll have to package using the merge method. which means you'd have to deal with adding an install font step to your NSIS script. If any of your users are on win 10, you'll probably have to do the exe-shoes thing eventually even if this bug does get fixed.

@dredknight
Copy link
Contributor Author

@dredknight dredknight commented Jul 6, 2016

Installing shoes compiler is set as prerequisite for using the app so that is ok.
I will have to learn the Nsis thing now but I guess it is not that complicated.

Thanks for all the help :)!

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jul 6, 2016

I've got a font fix that works for me. @dredknight if you would be so kind, try out this 3.3.2 beta . You'll have to uninstall your current Shoes first. If you want to revert, then uninstall 3.3.2 and re-install the one you had.

I use a simple test script which requires vivaldi.ttf to be in the same dir as the this script

Shoes.app {
   font "vivaldi.ttf"
   para "#{Shoes::FONTS}\n", font: "Vivaldi"
   para "#{Shoes::FONTS}\n", font: "Symbol"
   para "\n..............................................\n"
   button "quit" do exit end 
}
@ccoupe ccoupe added this to the 3.3.2 milestone Jul 6, 2016
ccoupe added a commit that referenced this issue Jul 6, 2016
* I think. Uses fontconfig calls w/o needing the old fc-cache
  voodoo dance. too bad we didn't learn this sooner or maybe the
  time wasn't right for learning.
@ccoupe ccoupe self-assigned this Jul 6, 2016
@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jul 6, 2016

Requiring your users to install Shoes first and then download and run your .shy works just fine on Windows 10. If that fits your desire, then don't go into the NSIS rabbit hole before you need too.

@dredknight
Copy link
Contributor Author

@dredknight dredknight commented Jul 6, 2016

It works!!!!
Yes, only in the folder of the script.

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jul 6, 2016

Good! Thanks for reporting the bug. I'll leave the issue open until I merge the change into the next release.

font will work with a partial or full path. The test script is only a test.

@dredknight
Copy link
Contributor Author

@dredknight dredknight commented Jul 6, 2016

Glad to hear :)!
Well done on the fix!

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jan 21, 2017

Closed in Shoes 3.3.2

@ccoupe ccoupe closed this Jan 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants